aboutsummaryrefslogtreecommitdiff
path: root/src/backends/cl/ClBackendContext.hpp
blob: af988a96dce2799c3ebd6531bd05bb98287dfc4b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
//
// Copyright © 2017 Arm Ltd. All rights reserved.
// SPDX-License-Identifier: MIT
//
#pragma once

#include <armnn/backends/IBackendContext.hpp>
#include <unordered_set>
#include <mutex>

#include <arm_compute/runtime/CL/CLTuner.h>
#include <arm_compute/runtime/CL/CLGEMMHeuristicsHandle.h>

namespace armnn
{

class ClBackendContext : public IBackendContext
{
public:
    ClBackendContext(const IRuntime::CreationOptions& options);

    bool BeforeLoadNetwork(NetworkId networkId) override;
    bool AfterLoadNetwork(NetworkId networkId) override;

    bool BeforeUnloadNetwork(NetworkId networkId) override;
    bool AfterUnloadNetwork(NetworkId networkId) override;

    ~ClBackendContext() override;

private:
    std::mutex m_Mutex;
    struct ClContextControlWrapper;
    std::unique_ptr<ClContextControlWrapper> m_ClContextControlWrapper;

    std::unordered_set<NetworkId> m_NetworkIds;

    std::unique_ptr<arm_compute::CLTuner> m_Tuner;
    std::string m_TuningFile;

protected:
    arm_compute::CLGEMMHeuristicsHandle m_MLGOTuner;
    std::string m_MLGOTuningFile;
};

} // namespace armnn