MCPcopy Create free account
hub / github.com/ARM-software/armnn / ArmNNExecutor

Method ArmNNExecutor

tests/ExecuteNetwork/ArmNNExecutor.cpp:126–209  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

124#endif
125
126ArmNNExecutor::ArmNNExecutor(const ExecuteNetworkParams& params, armnn::IRuntime::CreationOptions runtimeOptions)
127 : m_Params(params)
128{
129 runtimeOptions.m_EnableGpuProfiling = params.m_EnableProfiling;
130 runtimeOptions.m_DynamicBackendsPath = params.m_DynamicBackendsPath;
131
132 // Create/Get the static ArmNN Runtime. Note that the m_Runtime will be shared by all ArmNNExecutor
133 // instances so the RuntimeOptions cannot be altered for different ArmNNExecutor instances.
134 m_Runtime = GetRuntime(runtimeOptions);
135
136 auto parser = CreateParser();
137 auto network = parser->CreateNetwork(m_Params);
138 auto optNet = OptimizeNetwork(network.get());
139
140 // If the user has asked for detailed data write out the .armnn amd .dot files.
141 if (params.m_SerializeToArmNN)
142 {
143#if defined(ARMNN_SERIALIZER)
144 // .armnn first.
145 // This could throw multiple exceptions if the directory cannot be created or the file cannot be written.
146 std::string targetDirectory(armnnUtils::Filesystem::CreateDirectory("/ArmNNSerializeNetwork"));
147 std::string fileName;
148 fileName = SerializeNetwork(*network, targetDirectory);
149 ARMNN_LOG(info) << "The pre-optimized network has been serialized to:" << fileName;
150 // and the .dot file.
151 // Most of the possible exceptions should have already occurred with the .armnn file.
152 fileName =
153 SerializeNetworkToDotFile(*optNet, targetDirectory);
154 ARMNN_LOG(info) << "The optimized network has been serialized to:" << fileName;
155#else
156 ARMNN_LOG(info) << "Arm NN has not been built with ARMNN_SERIALIZER enabled.";
157#endif
158 }
159 m_IOInfo = GetIOInfo(optNet.get());
160
161 armnn::ProfilingDetailsMethod profilingDetailsMethod = ProfilingDetailsMethod::Undefined;
162 if (params.m_OutputDetailsOnlyToStdOut)
163 {
164 profilingDetailsMethod = armnn::ProfilingDetailsMethod::DetailsOnly;
165 }
166 else if (params.m_OutputDetailsToStdOut)
167 {
168 profilingDetailsMethod = armnn::ProfilingDetailsMethod::DetailsWithEvents;
169 }
170
171 INetworkProperties networkProperties{MemorySource::Undefined,
172 MemorySource::Undefined,
173 params.m_EnableProfiling,
174 profilingDetailsMethod};
175
176 std::string errorMsg;
177 Status status = m_Runtime->LoadNetwork(m_NetworkId, std::move(optNet), errorMsg, networkProperties);
178 if (status != Status::Success)
179 {
180 std::string message("Failed to create Arm NN Executor: ");
181 message.append(errorMsg);
182 // Throwing an exception at this point in the constructor causes lots of problems. We'll instead mark this
183 // executor as not constructed.

Callers

nothing calls this directly

Calls 8

CreateDirectoryFunction · 0.85
CreateNetworkMethod · 0.80
LoadNetworkMethod · 0.80
appendMethod · 0.80
SerializeNetworkFunction · 0.70
getMethod · 0.45
strMethod · 0.45

Tested by

no test coverage detected