Laurent Carlier | 749294b | 2020-06-01 09:03:17 +0100 | [diff] [blame] | 1 | // |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 2 | // Copyright © 2017 Arm Ltd. All rights reserved. |
David Beck | ecb56cd | 2018-09-05 12:52:57 +0100 | [diff] [blame] | 3 | // SPDX-License-Identifier: MIT |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 4 | // |
| 5 | #pragma once |
| 6 | |
Derek Lamberti | 836b27b | 2019-11-20 10:51:57 +0000 | [diff] [blame] | 7 | #include "BackendOptions.hpp" |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8 | #include "INetwork.hpp" |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 9 | #include "IProfiler.hpp" |
Mike Kelly | 55a8ffd | 2021-04-07 20:10:49 +0100 | [diff] [blame] | 10 | #include "IWorkingMemHandle.hpp" |
Keith Davis | e813d67 | 2021-04-22 10:10:34 +0100 | [diff] [blame] | 11 | #include "IAsyncExecutionCallback.hpp" |
Matthew Bentham | 313e1c8 | 2019-03-25 17:37:47 +0000 | [diff] [blame] | 12 | #include "Tensor.hpp" |
| 13 | #include "Types.hpp" |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 14 | #include "TypesUtils.hpp" |
Jim Flynn | 4e755a5 | 2020-03-29 17:48:26 +0100 | [diff] [blame] | 15 | #include "profiling/ILocalPacketHandler.hpp" |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 16 | |
Matthew Bentham | 313e1c8 | 2019-03-25 17:37:47 +0000 | [diff] [blame] | 17 | #include <memory> |
| 18 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 19 | namespace armnn |
| 20 | { |
| 21 | |
| 22 | using NetworkId = int; |
| 23 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 24 | class IGpuAccTunedParameters; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 25 | |
Kevin May | d92a6e4 | 2021-02-04 10:27:41 +0000 | [diff] [blame] | 26 | struct RuntimeImpl; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 27 | class IRuntime; |
| 28 | using IRuntimePtr = std::unique_ptr<IRuntime, void(*)(IRuntime* runtime)>; |
| 29 | |
David Monahan | 4f1e8e4 | 2019-09-04 09:22:10 +0100 | [diff] [blame] | 30 | struct INetworkProperties |
| 31 | { |
Francis Murtagh | 73d3e2e | 2021-04-29 14:23:04 +0100 | [diff] [blame] | 32 | ARMNN_DEPRECATED_MSG("Please use INetworkProperties constructor with MemorySource argument") |
| 33 | INetworkProperties(bool importEnabled = false, |
| 34 | bool exportEnabled = false, |
Finn Williams | f364d53 | 2021-06-09 17:07:33 +0100 | [diff] [blame^] | 35 | bool asyncEnabled = false) |
Francis Murtagh | 73d3e2e | 2021-04-29 14:23:04 +0100 | [diff] [blame] | 36 | : m_ImportEnabled(importEnabled) |
| 37 | , m_ExportEnabled(exportEnabled) |
| 38 | , m_AsyncEnabled(asyncEnabled) |
Narumol Prangnawarat | e5f0b24 | 2021-05-07 17:52:36 +0100 | [diff] [blame] | 39 | , m_InputSource(m_ImportEnabled ? MemorySource::Malloc : MemorySource::Undefined) |
| 40 | , m_OutputSource(m_ExportEnabled ? MemorySource::Malloc : MemorySource::Undefined) |
| 41 | {} |
David Monahan | 4f1e8e4 | 2019-09-04 09:22:10 +0100 | [diff] [blame] | 42 | |
Finn Williams | f364d53 | 2021-06-09 17:07:33 +0100 | [diff] [blame^] | 43 | ARMNN_DEPRECATED_MSG("Please use INetworkProperties constructor without numThreads argument") |
Francis Murtagh | 73d3e2e | 2021-04-29 14:23:04 +0100 | [diff] [blame] | 44 | INetworkProperties(bool asyncEnabled, |
| 45 | MemorySource m_InputSource, |
Keith Davis | e813d67 | 2021-04-22 10:10:34 +0100 | [diff] [blame] | 46 | MemorySource m_OutputSource, |
Finn Williams | f364d53 | 2021-06-09 17:07:33 +0100 | [diff] [blame^] | 47 | size_t numThreads) |
| 48 | : m_ImportEnabled(m_InputSource != MemorySource::Undefined) |
| 49 | , m_ExportEnabled(m_OutputSource != MemorySource::Undefined) |
| 50 | , m_AsyncEnabled(asyncEnabled) |
| 51 | , m_InputSource(m_InputSource) |
| 52 | , m_OutputSource(m_OutputSource) |
| 53 | { |
| 54 | armnn::IgnoreUnused(numThreads); |
| 55 | } |
| 56 | |
| 57 | INetworkProperties(bool asyncEnabled, |
| 58 | MemorySource m_InputSource, |
| 59 | MemorySource m_OutputSource) |
Francis Murtagh | 73d3e2e | 2021-04-29 14:23:04 +0100 | [diff] [blame] | 60 | : m_ImportEnabled(m_InputSource != MemorySource::Undefined) |
| 61 | , m_ExportEnabled(m_OutputSource != MemorySource::Undefined) |
| 62 | , m_AsyncEnabled(asyncEnabled) |
| 63 | , m_InputSource(m_InputSource) |
| 64 | , m_OutputSource(m_OutputSource) |
| 65 | {} |
| 66 | |
| 67 | /// Deprecated and will be removed in future release. |
David Monahan | 4f1e8e4 | 2019-09-04 09:22:10 +0100 | [diff] [blame] | 68 | const bool m_ImportEnabled; |
Francis Murtagh | 73d3e2e | 2021-04-29 14:23:04 +0100 | [diff] [blame] | 69 | /// Deprecated and will be removed in future release. |
David Monahan | 4f1e8e4 | 2019-09-04 09:22:10 +0100 | [diff] [blame] | 70 | const bool m_ExportEnabled; |
Francis Murtagh | 73d3e2e | 2021-04-29 14:23:04 +0100 | [diff] [blame] | 71 | |
Keith Davis | e813d67 | 2021-04-22 10:10:34 +0100 | [diff] [blame] | 72 | const bool m_AsyncEnabled; |
Keith Davis | e813d67 | 2021-04-22 10:10:34 +0100 | [diff] [blame] | 73 | |
Francis Murtagh | 73d3e2e | 2021-04-29 14:23:04 +0100 | [diff] [blame] | 74 | const MemorySource m_InputSource; |
| 75 | const MemorySource m_OutputSource; |
David Monahan | 4f1e8e4 | 2019-09-04 09:22:10 +0100 | [diff] [blame] | 76 | |
| 77 | virtual ~INetworkProperties() {} |
| 78 | }; |
| 79 | |
Mike Kelly | 386ff1a | 2021-03-29 15:04:50 +0100 | [diff] [blame] | 80 | using namespace armnn::experimental; |
| 81 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 82 | class IRuntime |
| 83 | { |
| 84 | public: |
| 85 | struct CreationOptions |
| 86 | { |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 87 | CreationOptions() |
| 88 | : m_GpuAccTunedParameters(nullptr) |
| 89 | , m_EnableGpuProfiling(false) |
Matteo Martincigh | e7d4498 | 2019-08-05 12:16:47 +0100 | [diff] [blame] | 90 | , m_DynamicBackendsPath("") |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 91 | {} |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 92 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 93 | /// If set, uses the GpuAcc tuned parameters from the given object when executing GPU workloads. |
| 94 | /// It will also be updated with new tuned parameters if it is configured to do so. |
| 95 | std::shared_ptr<IGpuAccTunedParameters> m_GpuAccTunedParameters; |
| 96 | |
Ryan OShea | 2bbfaa7 | 2020-02-12 16:15:27 +0000 | [diff] [blame] | 97 | /// Setting this flag will allow the user to obtain GPU profiling information from the runtime. |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 98 | bool m_EnableGpuProfiling; |
Matteo Martincigh | e7d4498 | 2019-08-05 12:16:47 +0100 | [diff] [blame] | 99 | |
Ryan OShea | 2bbfaa7 | 2020-02-12 16:15:27 +0000 | [diff] [blame] | 100 | /// Setting this value will override the paths set by the DYNAMIC_BACKEND_PATHS compiler directive |
| 101 | /// Only a single path is allowed for the override |
Matteo Martincigh | e7d4498 | 2019-08-05 12:16:47 +0100 | [diff] [blame] | 102 | std::string m_DynamicBackendsPath; |
Aron Virginas-Tar | 1a0f691 | 2019-08-23 15:18:44 +0100 | [diff] [blame] | 103 | |
| 104 | struct ExternalProfilingOptions |
| 105 | { |
| 106 | ExternalProfilingOptions() |
| 107 | : m_EnableProfiling(false) |
Jim Flynn | 4e755a5 | 2020-03-29 17:48:26 +0100 | [diff] [blame] | 108 | , m_TimelineEnabled(false) |
Aron Virginas-Tar | 1a0f691 | 2019-08-23 15:18:44 +0100 | [diff] [blame] | 109 | , m_OutgoingCaptureFile("") |
| 110 | , m_IncomingCaptureFile("") |
| 111 | , m_FileOnly(false) |
Colm Donelan | 0270524 | 2019-11-14 14:19:07 +0000 | [diff] [blame] | 112 | , m_CapturePeriod(LOWEST_CAPTURE_PERIOD) |
Isabella Gottardi | a0687ee | 2020-03-11 18:04:20 +0000 | [diff] [blame] | 113 | , m_FileFormat("binary") |
Jim Flynn | 4e755a5 | 2020-03-29 17:48:26 +0100 | [diff] [blame] | 114 | , m_LocalPacketHandlers() |
Aron Virginas-Tar | 1a0f691 | 2019-08-23 15:18:44 +0100 | [diff] [blame] | 115 | {} |
| 116 | |
| 117 | bool m_EnableProfiling; |
Jim Flynn | 4e755a5 | 2020-03-29 17:48:26 +0100 | [diff] [blame] | 118 | bool m_TimelineEnabled; |
Aron Virginas-Tar | 1a0f691 | 2019-08-23 15:18:44 +0100 | [diff] [blame] | 119 | std::string m_OutgoingCaptureFile; |
| 120 | std::string m_IncomingCaptureFile; |
| 121 | bool m_FileOnly; |
| 122 | uint32_t m_CapturePeriod; |
Isabella Gottardi | a0687ee | 2020-03-11 18:04:20 +0000 | [diff] [blame] | 123 | std::string m_FileFormat; |
Jim Flynn | 4e755a5 | 2020-03-29 17:48:26 +0100 | [diff] [blame] | 124 | std::vector<armnn::profiling::ILocalPacketHandlerSharedPtr> m_LocalPacketHandlers; |
Aron Virginas-Tar | 1a0f691 | 2019-08-23 15:18:44 +0100 | [diff] [blame] | 125 | }; |
Jim Flynn | 4951b8c | 2019-10-03 10:04:30 -0700 | [diff] [blame] | 126 | ExternalProfilingOptions m_ProfilingOptions; |
Derek Lamberti | 836b27b | 2019-11-20 10:51:57 +0000 | [diff] [blame] | 127 | |
| 128 | /// Pass backend specific options. |
| 129 | /// |
| 130 | /// For example, to enable GpuAcc tuning add the following |
Ryan OShea | 2bbfaa7 | 2020-02-12 16:15:27 +0000 | [diff] [blame] | 131 | /// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~.cpp |
Derek Lamberti | 836b27b | 2019-11-20 10:51:57 +0000 | [diff] [blame] | 132 | /// m_BackendOption.emplace_back( |
| 133 | /// BackendOptions{"GpuAcc", |
| 134 | /// { |
| 135 | /// {"TuningLevel", 2}, |
| 136 | /// {"TuningFile", filename} |
| 137 | /// } |
| 138 | /// }); |
Ryan OShea | 2bbfaa7 | 2020-02-12 16:15:27 +0000 | [diff] [blame] | 139 | /// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
Derek Lamberti | 836b27b | 2019-11-20 10:51:57 +0000 | [diff] [blame] | 140 | /// Execute representative workloads through the runtime to generate tuning data. |
| 141 | /// The tuning file is written once the runtime is destroyed |
| 142 | |
| 143 | /// To execute with the tuning data, start up with just the tuning file specified. |
Ryan OShea | 2bbfaa7 | 2020-02-12 16:15:27 +0000 | [diff] [blame] | 144 | /// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~.cpp |
Derek Lamberti | 836b27b | 2019-11-20 10:51:57 +0000 | [diff] [blame] | 145 | /// m_BackendOption.emplace_back( |
| 146 | /// BackendOptions{"GpuAcc", |
| 147 | /// { |
| 148 | /// {"TuningFile", filename} |
| 149 | /// } |
| 150 | /// }); |
Ryan OShea | 2bbfaa7 | 2020-02-12 16:15:27 +0000 | [diff] [blame] | 151 | /// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
Derek Lamberti | 836b27b | 2019-11-20 10:51:57 +0000 | [diff] [blame] | 152 | |
| 153 | /// The following backend options are available: |
| 154 | /// GpuAcc: |
| 155 | /// "TuningLevel" : int [0..3] (0=UseOnly(default) | 1=RapidTuning | 2=NormalTuning | 3=ExhaustiveTuning) |
| 156 | /// "TuningFile" : string [filenameString] |
| 157 | /// "KernelProfilingEnabled" : bool [true | false] |
| 158 | std::vector<BackendOptions> m_BackendOptions; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 159 | }; |
| 160 | |
| 161 | static IRuntime* CreateRaw(const CreationOptions& options); |
| 162 | static IRuntimePtr Create(const CreationOptions& options); |
| 163 | static void Destroy(IRuntime* runtime); |
| 164 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 165 | /// Loads a complete network into the IRuntime. |
| 166 | /// @param [out] networkIdOut - Unique identifier for the network is returned in this reference. |
| 167 | /// @param [in] network - Complete network to load into the IRuntime. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 168 | /// The runtime takes ownership of the network once passed in. |
| 169 | /// @return armnn::Status |
Kevin May | d92a6e4 | 2021-02-04 10:27:41 +0000 | [diff] [blame] | 170 | Status LoadNetwork(NetworkId& networkIdOut, IOptimizedNetworkPtr network); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 171 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 172 | /// Load a complete network into the IRuntime. |
| 173 | /// @param [out] networkIdOut Unique identifier for the network is returned in this reference. |
| 174 | /// @param [in] network Complete network to load into the IRuntime. |
| 175 | /// @param [out] errorMessage Error message if there were any errors. |
| 176 | /// The runtime takes ownership of the network once passed in. |
| 177 | /// @return armnn::Status |
Kevin May | d92a6e4 | 2021-02-04 10:27:41 +0000 | [diff] [blame] | 178 | Status LoadNetwork(NetworkId& networkIdOut, |
| 179 | IOptimizedNetworkPtr network, |
| 180 | std::string& errorMessage); |
David Monahan | 4f1e8e4 | 2019-09-04 09:22:10 +0100 | [diff] [blame] | 181 | |
Kevin May | d92a6e4 | 2021-02-04 10:27:41 +0000 | [diff] [blame] | 182 | Status LoadNetwork(NetworkId& networkIdOut, |
| 183 | IOptimizedNetworkPtr network, |
| 184 | std::string& errorMessage, |
| 185 | const INetworkProperties& networkProperties); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 186 | |
Kevin May | d92a6e4 | 2021-02-04 10:27:41 +0000 | [diff] [blame] | 187 | TensorInfo GetInputTensorInfo(NetworkId networkId, LayerBindingId layerId) const; |
| 188 | TensorInfo GetOutputTensorInfo(NetworkId networkId, LayerBindingId layerId) const; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 189 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 190 | /// Evaluates a network using input in inputTensors and outputs filled into outputTensors |
Kevin May | d92a6e4 | 2021-02-04 10:27:41 +0000 | [diff] [blame] | 191 | Status EnqueueWorkload(NetworkId networkId, |
| 192 | const InputTensors& inputTensors, |
| 193 | const OutputTensors& outputTensors); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 194 | |
Mike Kelly | 55a8ffd | 2021-04-07 20:10:49 +0100 | [diff] [blame] | 195 | /// This is an experimental function. |
| 196 | /// Evaluates a network using input in inputTensors and outputs filled into outputTensors. |
| 197 | /// This function performs a thread safe execution of the network. Returns once execution is complete. |
| 198 | /// Will block until this and any other thread using the same workingMem object completes. |
| 199 | Status Execute(IWorkingMemHandle& workingMemHandle, |
| 200 | const InputTensors& inputTensors, |
| 201 | const OutputTensors& outputTensors); |
| 202 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 203 | /// Unloads a network from the IRuntime. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 204 | /// At the moment this only removes the network from the m_Impl->m_Network. |
| 205 | /// This might need more work in the future to be AndroidNN compliant. |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 206 | /// @param [in] networkId - Unique identifier for the network to be unloaded. Generated in LoadNetwork(). |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 207 | /// @return armnn::Status |
Kevin May | d92a6e4 | 2021-02-04 10:27:41 +0000 | [diff] [blame] | 208 | Status UnloadNetwork(NetworkId networkId); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 209 | |
Kevin May | d92a6e4 | 2021-02-04 10:27:41 +0000 | [diff] [blame] | 210 | const IDeviceSpec& GetDeviceSpec() const; |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 211 | |
Mike Kelly | 55a8ffd | 2021-04-07 20:10:49 +0100 | [diff] [blame] | 212 | /// Create a new unique WorkingMemHandle object. Create multiple handles if you wish to have |
| 213 | /// overlapped Execution by calling this function from different threads. |
| 214 | std::unique_ptr<IWorkingMemHandle> CreateWorkingMemHandle(NetworkId networkId); |
| 215 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 216 | /// Gets the profiler corresponding to the given network id. |
| 217 | /// @param networkId The id of the network for which to get the profile. |
| 218 | /// @return A pointer to the requested profiler, or nullptr if not found. |
Kevin May | d92a6e4 | 2021-02-04 10:27:41 +0000 | [diff] [blame] | 219 | const std::shared_ptr<IProfiler> GetProfiler(NetworkId networkId) const; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 220 | |
Nattapat Chaimanowong | 6e94820 | 2019-03-22 14:01:46 +0000 | [diff] [blame] | 221 | /// Registers a callback function to debug layers performing custom computations on intermediate tensors. |
| 222 | /// @param networkId The id of the network to register the callback. |
| 223 | /// @param func callback function to pass to the debug layer. |
Kevin May | d92a6e4 | 2021-02-04 10:27:41 +0000 | [diff] [blame] | 224 | void RegisterDebugCallback(NetworkId networkId, const DebugCallbackFunction& func); |
Nattapat Chaimanowong | 6e94820 | 2019-03-22 14:01:46 +0000 | [diff] [blame] | 225 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 226 | protected: |
Kevin May | d92a6e4 | 2021-02-04 10:27:41 +0000 | [diff] [blame] | 227 | IRuntime(); |
| 228 | IRuntime(const IRuntime::CreationOptions& options); |
| 229 | ~IRuntime(); |
| 230 | |
| 231 | std::unique_ptr<RuntimeImpl> pRuntimeImpl; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 232 | }; |
| 233 | |
Derek Lamberti | 836b27b | 2019-11-20 10:51:57 +0000 | [diff] [blame] | 234 | |
| 235 | /// The following API is replaced by the backend options API. |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 236 | using IGpuAccTunedParametersPtr = std::shared_ptr<IGpuAccTunedParameters>; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 237 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 238 | /// Manages a set of GpuAcc parameters which have been tuned for maximum performance. |
| 239 | /// Passes an instance of this object to the IRuntime::Create() method (via IRuntime::CreationOptions) to use it |
| 240 | /// for all GPU workload execution. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 241 | /// |
| 242 | /// Can be created in two modes: |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 243 | /// - In UseTunedParameters mode, the parameters stored in this object are used to execute GPU workloads. |
| 244 | /// - In UpdateTunedParameters mode, additionally, whenever a GPU workload is executed for the first time, the |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 245 | /// optimum parameters will be found and stored in this object. WARNING - This tuning can be slow. |
| 246 | /// |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 247 | /// The parameters can be loaded from and saved to a file so that you can first run a slow initial read-write |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 248 | /// execution, save the parameters for later and then run fast read-only executions using the optimised parameters. |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 249 | class IGpuAccTunedParameters |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 250 | { |
| 251 | public: |
| 252 | enum class Mode |
| 253 | { |
| 254 | UseTunedParameters, |
| 255 | UpdateTunedParameters |
| 256 | }; |
| 257 | |
Ruomei Yan | 49937f3 | 2019-04-25 14:24:05 +0100 | [diff] [blame] | 258 | enum class TuningLevel |
| 259 | { |
Inki Dae | 23dbe3d | 2021-03-16 16:24:09 +0900 | [diff] [blame] | 260 | Rapid = 1, |
| 261 | Normal = 2, |
| 262 | Exhaustive = 3 |
Ruomei Yan | 49937f3 | 2019-04-25 14:24:05 +0100 | [diff] [blame] | 263 | }; |
| 264 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 265 | /// Creates an IClTunedParameters with the given mode. |
| 266 | /// @{ |
Ruomei Yan | 49937f3 | 2019-04-25 14:24:05 +0100 | [diff] [blame] | 267 | static IGpuAccTunedParameters* CreateRaw(Mode mode, TuningLevel tunerMode); |
| 268 | static IGpuAccTunedParametersPtr Create(Mode mode, TuningLevel tunerMode); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 269 | /// @} |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 270 | static void Destroy(IGpuAccTunedParameters* params); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 271 | |
| 272 | /// Loads an existing set of tuned parameters from the given file. |
| 273 | /// If there is an error loading the file, an armnn::Exception is thrown. |
| 274 | virtual void Load(const char* filename) = 0; |
| 275 | |
| 276 | /// Saves the current set of tuned parameters to the given file. |
| 277 | /// If there is an error saving to the file, an armnn::Exception is thrown. |
| 278 | virtual void Save(const char* filename) const = 0; |
| 279 | |
| 280 | protected: |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 281 | virtual ~IGpuAccTunedParameters() {}; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 282 | }; |
| 283 | |
David Monahan | 4f1e8e4 | 2019-09-04 09:22:10 +0100 | [diff] [blame] | 284 | } // namespace armnn |