aboutsummaryrefslogtreecommitdiff
path: root/include/armnn/IAsyncNetwork.hpp
blob: c234ae55ac70103d0a4c5eebc49e7c5a68bd5ee8 (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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
//
// Copyright © 2021 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//

#pragma once

#include <armnn/NetworkFwd.hpp>

#include "INetwork.hpp"
#include "IProfiler.hpp"
#include "IWorkingMemHandle.hpp"
#include "Tensor.hpp"
#include "Types.hpp"

#include <mutex>

namespace armnn
{
struct INetworkProperties;

namespace profiling
{
class ProfilingService;
}

namespace experimental
{
class AsyncNetworkImpl;

class IAsyncNetwork
{
public:
    IAsyncNetwork(std::unique_ptr<IOptimizedNetwork> net,
                  const INetworkProperties& networkProperties,
                  profiling::ProfilingService& profilingService);
    ~IAsyncNetwork();

    TensorInfo GetInputTensorInfo(LayerBindingId layerId) const;
    TensorInfo GetOutputTensorInfo(LayerBindingId layerId) const;

    /// Thread safe execution of the network. Returns once execution is complete.
    /// Will block until this and any other thread using the same workingMem object completes.
    Status Execute(const InputTensors& inputTensors,
                   const OutputTensors& outputTensors,
                   IWorkingMemHandle& workingMemHandle);

    /// Create a new unique WorkingMemHandle object. Create multiple handles if you wish to have
    /// overlapped Execution by calling this function from different threads.
    std::unique_ptr<IWorkingMemHandle> CreateWorkingMemHandle();

    /// Get the profiler used for this network
    std::shared_ptr<IProfiler> GetProfiler() const;

    /// Register a debug callback function to be used with this network
    void RegisterDebugCallback(const DebugCallbackFunction& func);

private:
    std::unique_ptr<AsyncNetworkImpl> pAsyncNetworkImpl;
};

} // end experimental namespace

} // end armnn namespace