24.02
|
Go to the documentation of this file.
30 #include <client/include/IProfilingService.hpp>
32 #include <common/include/ProfilingGuid.hpp>
34 #include <fmt/format.h>
62 bool importEnabled,
ModelOptions modelOptions,
bool exportEnabled,
65 importEnabled, modelOptions,
66 exportEnabled, debugToFile))
72 bool importEnabled,
ModelOptions modelOptions,
bool exportEnabled,
73 bool debugToFile,
bool allowExpandedDims)
75 shapeInferenceMethod, importEnabled,
76 modelOptions, exportEnabled,
77 debugToFile, allowExpandedDims))
84 p_OptimizerOptionsImpl->m_ImportEnabled = OptimizerStruct.
m_ImportEnabled;
86 p_OptimizerOptionsImpl->m_ModelOptions = OptimizerStruct.
m_ModelOptions;
88 p_OptimizerOptionsImpl->m_DebugToFile = OptimizerStruct.
m_DebugToFile;
89 p_OptimizerOptionsImpl->m_Debug = OptimizerStruct.
m_Debug;
91 p_OptimizerOptionsImpl->m_ExportEnabled = OptimizerStruct.
m_ExportEnabled;
113 p_OptimizerOptionsImpl->m_ImportEnabled = ImportState;
118 p_OptimizerOptionsImpl->m_ExportEnabled = ExportState;
123 p_OptimizerOptionsImpl->m_ProfilingEnabled = ProfilingState;
128 p_OptimizerOptionsImpl->m_Debug = DebugState;
133 p_OptimizerOptionsImpl->m_DebugToFile = DebugFileState;
138 p_OptimizerOptionsImpl->m_ReduceFp32ToFp16 = ReduceFp32ToFp16State;
143 p_OptimizerOptionsImpl->m_shapeInferenceMethod = ShapeInferenceMethodType;
148 p_OptimizerOptionsImpl->m_AllowExpandedDims = ExpandedDimsAllowed;
153 p_OptimizerOptionsImpl->m_ModelOptions.push_back(NewModelOption);
158 return p_OptimizerOptionsImpl->m_ProfilingEnabled;
163 return p_OptimizerOptionsImpl->m_ImportEnabled;
168 return p_OptimizerOptionsImpl->m_ExportEnabled;
173 return p_OptimizerOptionsImpl->m_ReduceFp32ToFp16;
178 return p_OptimizerOptionsImpl->m_ReduceFp32ToBf16;
183 return p_OptimizerOptionsImpl->m_Debug;
188 return p_OptimizerOptionsImpl->m_DebugToFile;
193 return p_OptimizerOptionsImpl->m_AllowExpandedDims;
198 return p_OptimizerOptionsImpl->m_ModelOptions;
203 return p_OptimizerOptionsImpl->m_shapeInferenceMethod;
208 std::stringstream stream;
209 stream <<
"OptimizerOptions: \n";
210 stream <<
"\tReduceFp32ToFp16: " << p_OptimizerOptionsImpl->m_ReduceFp32ToFp16 <<
"\n";
211 stream <<
"\tReduceFp32ToBf16: " << p_OptimizerOptionsImpl->m_ReduceFp32ToBf16 <<
"\n";
212 stream <<
"\tDebug: " << p_OptimizerOptionsImpl->m_Debug <<
"\n";
213 stream <<
"\tDebug to file: " << p_OptimizerOptionsImpl->m_DebugToFile <<
"\n";
214 stream <<
"\tShapeInferenceMethod: " <<
216 "ValidateOnly" :
"InferAndValidate") <<
"\n";
217 stream <<
"\tImportEnabled: " << p_OptimizerOptionsImpl->m_ImportEnabled <<
"\n";
218 stream <<
"\tExportEnabled: " << p_OptimizerOptionsImpl->m_ExportEnabled <<
"\n";
219 stream <<
"\tProfilingEnabled: " << p_OptimizerOptionsImpl->m_ProfilingEnabled <<
"\n";
220 stream <<
"\tAllowExpandedDims: " << p_OptimizerOptionsImpl->m_AllowExpandedDims <<
"\n";
222 stream <<
"\tModelOptions: \n";
223 for (
auto optionsGroup : p_OptimizerOptionsImpl->m_ModelOptions)
225 for (
size_t i=0; i < optionsGroup.GetOptionCount(); i++)
228 stream <<
"\t\tBackend: " << optionsGroup.GetBackendId() <<
"\n"
229 <<
"\t\t\tOption: " << option.
GetName() <<
"\n"
261 return pNetworkImpl->AddComparisonLayer(comparisonDescriptor, name);
268 return pNetworkImpl->AddConcatLayer(concatDescriptor, name);
275 return pNetworkImpl->AddConvolution2dLayer(convolution2dDescriptor, name);
281 return pNetworkImpl->AddConvolution3dLayer(convolution3dDescriptor, name);
288 return pNetworkImpl->AddDepthToSpaceLayer(depthToSpaceDescriptor, name);
296 return pNetworkImpl->AddDepthwiseConvolution2dLayer(convolution2dDescriptor, name);
311 return pNetworkImpl->AddDetectionPostProcessLayer(descriptor, anchors, name);
317 return pNetworkImpl->AddElementwiseBinaryLayer(elementwiseBinaryDescriptor, name);
323 return pNetworkImpl->AddElementwiseUnaryLayer(elementwiseUnaryDescriptor, name);
329 return pNetworkImpl->AddFillLayer(fillDescriptor, name);
335 return pNetworkImpl->AddFullyConnectedLayer(fullyConnectedDescriptor, name);
341 return pNetworkImpl->AddFusedLayer(fusedDescriptor, name);
347 return pNetworkImpl->AddPermuteLayer(permuteDescriptor, name);
353 return pNetworkImpl->AddBatchToSpaceNdLayer(batchToSpaceNdDescriptor, name);
359 return pNetworkImpl->AddPooling2dLayer(pooling2dDescriptor, name);
365 return pNetworkImpl->AddPooling3dLayer(pooling3dDescriptor, name);
373 return pNetworkImpl->AddPrecompiledLayer(preCompiledDescriptor, std::move(compiledBlobPtr), backend, name);
379 return pNetworkImpl->AddActivationLayer(activationDescriptor, name);
385 return pNetworkImpl->AddNormalizationLayer(normalizationDescriptor, name);
390 return pNetworkImpl->AddSliceLayer(sliceDescriptor, name);
395 return pNetworkImpl->AddSoftmaxLayer(softmaxDescriptor, name);
401 return pNetworkImpl->AddSplitterLayer(splitterDescriptor, name);
430 return pNetworkImpl->AddBatchNormalizationLayer(desc, mean, variance, beta, gamma, name);
441 return pNetworkImpl->AddResizeLayer(resizeDescriptor, name);
447 return pNetworkImpl->AddReduceLayer(reduceDescriptor, name);
453 return pNetworkImpl->AddInstanceNormalizationLayer(desc, name);
459 return pNetworkImpl->AddL2NormalizationLayer(desc, name);
465 return pNetworkImpl->AddLogSoftmaxLayer(logSoftmaxDescriptor, name);
477 return pNetworkImpl->AddReshapeLayer(reshapeDescriptor, name);
483 return pNetworkImpl->AddSpaceToBatchNdLayer(spaceToBatchNdDescriptor, name);
489 return pNetworkImpl->AddSpaceToDepthLayer(spaceToDepthDescriptor, name);
505 return pNetworkImpl->AddLstmLayer(descriptor, params, name);
531 return pNetworkImpl->AddMeanLayer(meanDescriptor, name);
548 return pNetworkImpl->AddStridedSliceLayer(stridedSliceDescriptor, name);
584 return pNetworkImpl->AddTransposeConvolution2dLayer(descriptor, weights, biases, name);
590 return pNetworkImpl->AddTransposeLayer(transposeDescriptor, name);
613 return pNetworkImpl->AddQuantizedLstmLayer(params, name);
620 return pNetworkImpl->AddQLstmLayer(descriptor, params, name);
626 return pNetworkImpl->AddLogicalBinaryLayer(descriptor, name);
634 return pNetworkImpl->AddUnidirectionalSequenceLstmLayer(descriptor, params, name);
640 return pNetworkImpl->AddChannelShuffleLayer(descriptor, name);
646 return pNetworkImpl->AddBatchMatMulLayer(descriptor, name);
663 return pNetworkImpl->AddBroadcastToLayer(descriptor, name);
673 return new INetwork(networkOptions);
687 : pOptimizedNetworkImpl(new
OptimizedNetworkImpl(*other.pOptimizedNetworkImpl.get(), modelOptions)) {}
693 : pOptimizedNetworkImpl(
std::move(impl)) {}
743 return m_Graph->SerializeToDot(stream);
748 return m_Graph->GetNumInputs();
753 return m_Graph->GetNumOutputs();
757 Optional<std::vector<std::string>&> errorMessages)
759 std::stringstream fullErrorMessage;
760 fullErrorMessage <<
"ERROR: " << errorMessage;
764 errorMessages.value().push_back(fullErrorMessage.str());
769 Optional<std::vector<std::string>&> warningMessages)
771 std::stringstream fullWarningMessage;
772 fullWarningMessage <<
"WARNING: " << warningMessage;
776 warningMessages.value().push_back(fullWarningMessage.str());
783 Optional<std::vector<std::string>&> errMessages)
785 std::stringstream failureMsg;
797 bool noErrors =
true;
799 for (
unsigned int i = 0; i < numOutputs; i++) {
802 auto quantizationDataType =
info.GetDataType();
803 auto quantizationScales =
info.GetQuantizationScales();
805 switch(quantizationDataType) {
811 &&
info.HasPerAxisQuantization()) {
813 "Asymmetric Quantization Datatype.");
815 if ((!
info.HasPerAxisQuantization() &&
info.GetQuantizationScale() == 0.f)
816 || (
info.HasPerAxisQuantization() && (quantizationScales.end() !=
817 std::find(quantizationScales.begin(), quantizationScales.end(), 0.f)))) {
819 std::stringstream ss;
821 <<
" (" << layer->
GetNameStr() <<
") is of type"
822 <<
" Quantized value but the scale parameter has not been set";
827 (
info.GetQuantizationScale() != (1.0f / 256.0f) ||
828 info.GetQuantizationOffset() != 0) &&
830 std::stringstream ss;
831 ss <<
"Quantization parameters for Softmax layer (Scale: " <<
832 info.GetQuantizationScale() <<
" and Offset: " <<
info.GetQuantizationOffset() <<
833 ") are incorrect and have been updated to Scale: 0.00390625 and Offset: 0";
835 info.SetQuantizationScale((1.0f / 256.0f));
836 info.SetQuantizationOffset(0);
853 const std::vector<BackendId>& availablePreferredBackends,
854 std::string& reasonIfUnsupported,
855 Optional<std::vector<std::string>&> errMessages)
860 auto ReturnError = [&](
const Layer* layer)
868 std::string currentReasonIfUnsupported;
874 reasonIfUnsupported += currentReasonIfUnsupported;
878 std::string checkStr =
"This CPU architecture does not support F16 data type, you need v8.2 or above";
879 if (!isLayerSupported || currentReasonIfUnsupported.find(checkStr) != std::string::npos)
887 auto ConstantLayerFromFp16ToFp32 = [](
Layer& layer)
891 ConstantLayer* constantLayer = PolymorphicDowncast<ConstantLayer*>(&layer);
897 std::vector<float> newValues(
info.GetNumElements());
901 info.GetNumElements(),
914 bool checkType =
false;
918 auto connectedOutputSlot = inputSlot.GetConnectedOutputSlot();
921 if (connectedOutputSlot->GetNumConnections() == 1)
924 ConstantLayerFromFp16ToFp32(connectedOutputSlot->GetOwningLayer());
930 std::vector<ConvertFp16ToFp32Layer*> convertFp16ToFp32Layers;
933 convertFp16ToFp32Layers =
938 std::vector<ConvertFp32ToFp16Layer*> convertFp32ToFp16Layers;
941 convertFp32ToFp16Layers =
946 auto AssignFirstSupportedBackend = [&](
Layer* layer,
BackendId preferredBackend)
948 bool supportedBackendFound =
false;
949 std::string reasonIfUnsupported;
955 reasonIfUnsupported))
957 supportedBackendFound =
true;
961 for (
const auto& backend : availablePreferredBackends)
964 if (backend == preferredBackend)
972 reasonIfUnsupported))
974 supportedBackendFound =
true;
980 return supportedBackendFound;
985 if (!AssignFirstSupportedBackend(convertLayer, backend))
987 return ReturnError(convertLayer);
993 if (!AssignFirstSupportedBackend(convertLayer, backend))
995 return ReturnError(convertLayer);
1003 std::stringstream warningMsg;
1005 <<
" is not supported on requested backend " << layer->
GetBackendId().
Get()
1008 <<
" (reason: " << reasonIfUnsupported
1009 <<
"), falling back to the next backend.";
1026 return {dataTypeIn, dataTypeOut};
1030 const std::vector<BackendId>& availablePreferredBackends)
1032 bool hasFp16 =
false;
1034 auto firstBackend = availablePreferredBackends[0];
1035 auto backendObjPtr = backends.find(firstBackend)->second.get();
1038 auto backendCapabilities = backendObjPtr->GetCapabilities();
1044 ARMNN_LOG(
debug) <<
"The first available preferred backend: " << firstBackend
1045 <<
", has FP16 support.";
1049 ARMNN_LOG(
warning) <<
"The first available preferred backend: " << firstBackend
1050 <<
", does not have FP16 support. "
1051 <<
"The FP16 turbo mode option will be disable. It will run using FP32.";
1055 for (
size_t i = 1; i < availablePreferredBackends.size(); ++i)
1057 auto backend = availablePreferredBackends[i];
1058 backendObjPtr = backends.find(backend)->second.get();
1059 backendCapabilities = backendObjPtr->GetCapabilities();
1062 ARMNN_LOG(
warning) <<
"Next preferred backend: " << backend <<
", does not have FP16 support. "
1063 <<
"It will run using FP32 when falling back to this backend.";
1067 ARMNN_LOG(
debug) <<
"Next preferred backend: " << backend <<
", has FP16 support.";
1078 Optional<std::vector<std::string>&> errMessages,
1081 std::vector<BackendId>& availablePreferredBackends)
1083 auto ReturnError = [&](
const Layer* layer)
1088 auto layer = PolymorphicDowncast<Layer*>(it);
1097 std::string reasonIfUnsupported;
1107 if (layer->GetBackendHint().has_value() &&
1112 layer->GetBackendHint().value(),
1115 availablePreferredBackends,
1116 reasonIfUnsupported,
1117 errMessages).
IsOk())
1125 for (
const auto& backend : availablePreferredBackends)
1127 if (layer->GetBackendHint().has_value() &&
1128 layer->GetBackendHint().value() == backend)
1139 availablePreferredBackends,
1140 reasonIfUnsupported,
1175 layer->SetBackendId(cpuBackendId);
1180 result = ReturnError(layer);
1190 Optional<std::vector<std::string>&> errMessages)
1196 if (availablePreferredBackends.empty())
1198 std::stringstream failureMsg;
1199 failureMsg <<
"No preferred backends are available";
1206 for (
auto it = firstLayer; it != lastLayer; ++it)
1208 auto layer = PolymorphicDowncast<Layer*>(*it);
1216 bool isFloat16 =
false;
1217 for (
auto type : inOutDataType)
1226 if (layer->GetBackendId() ==
"Unknown" || isFloat16)
1233 availablePreferredBackends);
1237 for (
auto it = firstLayer; it != lastLayer; ++it)
1239 auto layer = PolymorphicDowncast<Layer*>(*it);
1243 BackendId connectedBackendId = layer->GetOutputSlot(0).GetConnection(0)->GetOwningLayer().GetBackendId();
1244 layer->SetBackendId(connectedBackendId);
1255 Optional<std::vector<std::string>&> errMessages)
1261 if (availablePreferredBackends.empty())
1263 std::stringstream failureMsg;
1264 failureMsg <<
"No preferred backends are available";
1271 for (
auto it = firstLayer; it != lastLayer; ++it)
1278 availablePreferredBackends);
1281 for (
auto it = firstLayer; it != lastLayer; ++it)
1283 auto layer = PolymorphicDowncast<Layer*>(*it);
1287 BackendId connectedBackendId = layer->GetOutputSlot(0).GetConnection(0)->GetOwningLayer().GetBackendId();
1288 layer->SetBackendId(connectedBackendId);
1298 Optional<std::vector<std::string>&> errMessages)
1316 auto backendFactory = backendRegistry.GetFactory(selectedBackend);
1317 auto backendObjPtr = backendFactory();
1320 backendObjPtr->RegisterTensorHandleFactories(handleFactoryRegistry);
1322 backends[backendObjPtr->GetId()] = std::move(backendObjPtr);
1332 Optional<std::vector<std::string>&> errMessages)
1344 auto backendObjPtr = backends.find(selectedBackend)->second.get();
1357 [&backendObjPtr](
const Layer& layer)
1364 if (subgraphs.empty())
1371 for (
auto& subgraph : subgraphs)
1375 OptimizationViews optimizationViews = backendObjPtr->OptimizeSubgraphView(*subgraph, modelOptions);
1382 SubgraphView& replacementSubgraph = substitution.m_ReplacementSubgraph;
1383 SubgraphView& substitutableSubgraph = substitution.m_SubstitutableSubgraph;
1388 std::for_each(subgraphLayers.begin(), subgraphLayers.end(), [&selectedBackend](
IConnectableLayer* l)
1391 PolymorphicDowncast<Layer*>(l)->SetBackendId(selectedBackend);
1398 for (
auto& l : deletedSubgraph.GetIConnectableLayers())
1400 Layer* deletedLayer = PolymorphicDowncast<Layer*>(l);
1404 OutputSlot* parentOut = inputSlot.GetConnectedOutputSlot();
1419 std::stringstream warningMsg;
1420 warningMsg <<
"Some sub-graph(s) failed to optimized on " << backendObjPtr->GetId() <<
" backend.";
1425 if (!backendObjPtr->GetId().IsCpuRef())
1435 std::stringstream subgraphMsg;
1436 subgraphMsg <<
"Re-assigning backends to " << failedSubgraph.GetIConnectableLayers().size()
1437 <<
" layers inside sub-graph " << count++;
1444 if (reassignmentResult.
m_Error)
1467 if (srcFactory && dstFactory &&
1493 if (frmBackend == backends.end() ||
1494 !frmBackend->second->SupportsTensorAllocatorAPI())
1501 std::map<ITensorHandleFactory::FactoryId, int> factoryScores;
1508 const Layer& connectedLayer = connection->GetOwningLayer();
1510 auto toBackend = backends.find(connectedLayer.
GetBackendId());
1511 ARMNN_ASSERT_MSG(toBackend != backends.end(),
"Backend id not found for the connected layer");
1513 if (!toBackend->second.get()->SupportsTensorAllocatorAPI())
1519 auto dstPrefs = toBackend->second.get()->GetHandleFactoryPreferences();
1520 for (
auto&& dst : dstPrefs)
1534 auto it = factoryScores.find(dst);
1535 if (it == factoryScores.end())
1538 factoryScores[dst] = 0;
1547 factoryScores[dst]++;
1550 if (factoryScores[dst] > topScore)
1552 topScore = factoryScores[dst];
1581 if (frmBackend == backends.end() ||
1582 !frmBackend->second->SupportsTensorAllocatorAPI())
1587 bool outputConnection =
false;
1590 const Layer& connectedLayer = connection->GetOwningLayer();
1593 outputConnection =
true;
1601 std::map<ITensorHandleFactory::FactoryId, int> factoryScores;
1602 for (
auto&& pref : srcPrefs)
1607 if (outputConnection)
1610 bool fallbackConnection =
false;
1613 if (inputSlot.GetConnectedOutputSlot()->GetOwningLayer().GetBackendId() != layer.
GetBackendId())
1615 fallbackConnection =
true;
1618 if (fallbackConnection)
1622 if (!factoryCap.empty())
1632 if (!outputConnection)
1636 if (!factoryCap.empty())
1655 auto it = factoryScores.find(pref);
1656 if (it == factoryScores.end())
1659 factoryScores[pref] = 0;
1666 const Layer& connectedLayer = connection->GetOwningLayer();
1668 auto toBackend = backends.find(connectedLayer.
GetBackendId());
1669 ARMNN_ASSERT_MSG(toBackend != backends.end(),
"Backend id not found for the connected layer");
1671 auto dstPrefs = toBackend->second.get()->GetHandleFactoryPreferences();
1672 for (
auto&& src : srcPrefs)
1674 if (factoryScores.find(src) == factoryScores.end())
1679 for (
auto&& dst : dstPrefs)
1684 factoryScores[src]++;
1692 int minScore = std::numeric_limits<int>::max();
1693 for (
auto it : factoryScores)
1695 minScore = std::min(minScore, it.second);
1699 std::vector<ITensorHandleFactory::FactoryId> optimalFactories;
1700 for (
auto it : factoryScores)
1702 if (it.second == minScore)
1704 optimalFactories.push_back(it.first);
1709 for (
auto&& srcPref : srcPrefs)
1711 for (
auto&& comp : optimalFactories)
1713 if (comp == srcPref)
1726 const Layer& connectedLayer,
1730 auto toBackend = backends.find(connectedLayer.
GetBackendId());
1731 ARMNN_ASSERT_MSG(toBackend != backends.end(),
"Backend id not found for the connected layer");
1733 auto dstPrefs = toBackend->second.get()->GetHandleFactoryPreferences();
1756 for (
auto&& pref : dstPrefs)
1758 if (pref == srcFactoryId)
1768 for (
auto&& pref : dstPrefs)
1787 if (srcCapability.empty() && dstCapability.empty() && srcFallback.empty() && dstFallback.empty())
1798 for (
auto&& pref : dstPrefs)
1817 Optional<std::vector<std::string>&> errMessages)
1822 optGraph.
ForEachLayer([&backends, ®istry, &result, &errMessages, importEnabled, exportEnabled](
Layer* layer)
1853 unsigned int connectionIdx = 0;
1856 const Layer& connectedLayer = connection->GetOwningLayer();
1859 registry, importEnabled);
1866 errMessages.value().emplace_back(
"Could not find valid strategy required for compatibility"
1867 " between backends.");
1884 const std::vector<BackendId>& backendPreferences,
1887 Optional<std::vector<std::string>&> messages)
1897 const std::vector<BackendId>& backendPreferences,
1900 Optional<std::vector<std::string>&> messages)
1911 std::set<BackendId> backendSet(backendPreferences.begin(), backendPreferences.end());
1913 if (backendSet.find(
"GpuFsa") != backendSet.end() &&
1914 backendSet.find(
"GpuAcc") != backendSet.end())
1917 "for the same optimized network.");
1922 if (backendPreferences.empty())
1930 "Please use the FastMathEnabled backend option for CpuAcc or GpuAcc.");
1941 std::unique_ptr<Graph> graph = std::make_unique<Graph>(inGraph);
1949 optimizedOptions.push_back(importExport);
1966 using namespace optimizations;
2010 if (availablePreferredBackends.empty())
2012 std::stringstream failureMsg;
2013 failureMsg <<
"None of the preferred backends " << backendPreferences
2042 if (assignBackendsResult.
m_Error)
2057 if (backendOptimizationResult.
m_Error)
2082 #if !defined(ARMNN_DISABLE_FILESYSTEM)
2084 ARMNN_LOG(
info) <<
"Intermediate tensors will be written to: " << result;
2098 tensorHandleFactoryRegistry,
2120 const std::vector<BackendId>& backendPreferences,
2123 Optional<std::vector<std::string>&> messages)
2133 const std::vector<BackendId>& backendPreferences,
2136 Optional<std::vector<std::string>&> messages)
2145 bool NetworkImpl::GetShapeInferenceMethod()
2147 bool shapeInferenceMethod =
false;
2149 ParseOptions(m_NetworkOptions,
"ShapeInferenceMethod", [&](std::string name,
const BackendOptions::Var& value)
2151 if (name ==
"InferAndValidate")
2153 shapeInferenceMethod |= value.AsBool();
2156 return shapeInferenceMethod;
2159 bool NetworkImpl::GetAllowExpandedDims()
2161 bool allowExpandedDims =
false;
2163 ParseOptions(m_NetworkOptions,
"AllowExpandedDims", [&](std::string name,
const BackendOptions::Var& value)
2165 if (name ==
"AllowExpandedDims")
2167 allowExpandedDims |= value.AsBool();
2170 return allowExpandedDims;
2174 : m_NetworkOptions(networkOptions),
2175 m_Graph(
std::make_unique<
Graph>(GetShapeInferenceMethod(), GetAllowExpandedDims()))
2190 return m_Graph->AddLayer<
InputLayer>(id, name);
2201 return m_Graph->AddLayer<
CastLayer>(name);
2212 return m_Graph->AddLayer<
ComparisonLayer>(comparisonDescriptor, name);
2230 return m_Graph->AddLayer<
FillLayer>(fillDescriptor, name);
2242 return m_Graph->AddLayer<
FusedLayer>(fusedDescriptor, name);
2248 return m_Graph->AddLayer<
ConcatLayer>(concatDescriptor, name);
2291 layer->
m_Anchors = std::make_shared<ScopedTensorHandle>(anchors);
2299 return m_Graph->AddLayer<
PermuteLayer>(permuteDescriptor, name);
2305 return m_Graph->AddLayer<
Pooling2dLayer>(pooling2dDescriptor, name);
2311 return m_Graph->AddLayer<
Pooling3dLayer>(pooling3dDescriptor, name);
2317 return m_Graph->AddLayer<
ActivationLayer>(activationDescriptor, name);
2323 return m_Graph->AddLayer<
ArgMinMaxLayer>(argMinMaxDescriptor, name);
2327 normalizationDescriptor,
2335 return m_Graph->AddLayer<
SliceLayer>(sliceDescriptor, name);
2341 return m_Graph->AddLayer<
SoftmaxLayer>(softmaxDescriptor, name);
2347 return m_Graph->AddLayer<
SplitterLayer>(splitterDescriptor, name);
2384 layer->
m_Mean = std::make_shared<ScopedTensorHandle>(mean);
2385 layer->m_Variance = std::make_shared<ScopedTensorHandle>(variance);
2386 layer->m_Beta = std::make_shared<ScopedTensorHandle>(beta);
2387 layer->m_Gamma = std::make_shared<ScopedTensorHandle>(gamma);
2394 return m_Graph->AddLayer<
RankLayer>(name);
2400 return m_Graph->AddLayer<
ReduceLayer>(reduceDescriptor, name);
2405 return m_Graph->AddLayer<
ResizeLayer>(resizeDescriptor, name);
2435 layer->
m_LayerOutput = std::make_shared<ScopedTensorHandle>(input);
2443 return m_Graph->AddLayer<
ReshapeLayer>(reshapeDescriptor, name);
2467 const auto layer = m_Graph->AddLayer<
LstmLayer>(descriptor, name);
2472 layer->m_BasicParameters.m_InputToCellWeights =
2474 layer->m_BasicParameters.m_InputToOutputWeights =
2476 layer->m_BasicParameters.m_RecurrentToForgetWeights =
2478 layer->m_BasicParameters.m_RecurrentToCellWeights =
2480 layer->m_BasicParameters.m_RecurrentToOutputWeights =
2482 layer->m_BasicParameters.m_ForgetGateBias =
2484 layer->m_BasicParameters.m_CellBias =
2485 std::make_shared<ScopedTensorHandle>(*(params.
m_CellBias));
2486 layer->m_BasicParameters.m_OutputGateBias =
2490 if(!descriptor.m_CifgEnabled)
2495 "when CIFG is disabled.");
2500 "AddLstmLayer: Recurrent To Input Weights cannot be NULL "
2501 "when CIFG is disabled.");
2506 "when CIFG is disabled.");
2508 layer->m_CifgParameters.m_InputToInputWeights =
2510 layer->m_CifgParameters.m_RecurrentToInputWeights =
2512 layer->m_CifgParameters.m_InputGateBias =
2517 if(descriptor.m_ProjectionEnabled)
2522 "when projection is enabled.");
2524 layer->m_ProjectionParameters.m_ProjectionWeights =
2528 layer->m_ProjectionParameters.m_ProjectionBias =
2534 if(descriptor.m_PeepholeEnabled)
2536 if(!descriptor.m_CifgEnabled)
2541 "when Peephole is enabled and CIFG disabled.");
2544 layer->m_PeepholeParameters.m_CellToInputWeights =
2551 "when Peephole is enabled.");
2556 "when Peephole is enabled.");
2559 layer->m_PeepholeParameters.m_CellToForgetWeights =
2561 layer->m_PeepholeParameters.m_CellToOutputWeights =
2566 if(descriptor.m_LayerNormEnabled)
2568 if(!descriptor.m_CifgEnabled)
2573 "when layer normalization is enabled and CIFG disabled.");
2575 layer->m_LayerNormParameters.m_InputLayerNormWeights =
2582 "when layer normalization is enabled.");
2587 "when layer normalization is enabled.");
2592 "when layer normalization is enabled.");
2594 layer->m_LayerNormParameters.m_ForgetLayerNormWeights =
2596 layer->m_LayerNormParameters.m_CellLayerNormWeights =
2598 layer->m_LayerNormParameters.m_OutputLayerNormWeights =
2616 return m_Graph->AddLayer<
MeanLayer>(meanDescriptor,name);
2621 return m_Graph->AddLayer<
PadLayer>(padDescriptor,name);
2643 return m_Graph->AddLayer<
GatherLayer>(gatherDescriptor, name);
2678 layer->
m_Weight = std::make_shared<ScopedTensorHandle>(weights);
2680 if (descriptor.m_BiasEnabled)
2682 layer->m_Bias = std::make_shared<ScopedTensorHandle>(biases.
value());
2691 return m_Graph->AddLayer<
TransposeLayer>(transposeDescriptor, name);
2697 return m_Graph->AddLayer<
StackLayer>(stackDescriptor, name);
2715 layer->m_QuantizedLstmParameters.m_InputToForgetWeights =
2717 layer->m_QuantizedLstmParameters.m_InputToCellWeights =
2719 layer->m_QuantizedLstmParameters.m_InputToOutputWeights =
2723 layer->m_QuantizedLstmParameters.m_RecurrentToInputWeights =
2725 layer->m_QuantizedLstmParameters.m_RecurrentToForgetWeights =
2727 layer->m_QuantizedLstmParameters.m_RecurrentToCellWeights =
2729 layer->m_QuantizedLstmParameters.m_RecurrentToOutputWeights =
2733 layer->m_QuantizedLstmParameters.m_InputGateBias =
2735 layer->m_QuantizedLstmParameters.m_ForgetGateBias =
2737 layer->m_QuantizedLstmParameters.m_CellBias =
2738 std::make_shared<ScopedTensorHandle>(params.
GetCellBias());
2739 layer->m_QuantizedLstmParameters.m_OutputGateBias =
2749 const auto layer = m_Graph->AddLayer<
QLstmLayer>(descriptor, name);
2754 layer->m_BasicParameters.m_InputToCellWeights =
2756 layer->m_BasicParameters.m_InputToOutputWeights =
2758 layer->m_BasicParameters.m_RecurrentToForgetWeights =
2760 layer->m_BasicParameters.m_RecurrentToCellWeights =
2762 layer->m_BasicParameters.m_RecurrentToOutputWeights =
2764 layer->m_BasicParameters.m_ForgetGateBias =
2766 layer->m_BasicParameters.m_CellBias =
2767 std::make_shared<ScopedTensorHandle>(*(params.
m_CellBias));
2768 layer->m_BasicParameters.m_OutputGateBias =
2772 if(!descriptor.m_CifgEnabled)
2782 "AddQLstmLayer: Recurrent To Input Weights cannot be NULL");
2790 layer->m_CifgParameters.m_InputToInputWeights =
2792 layer->m_CifgParameters.m_RecurrentToInputWeights =
2794 layer->m_CifgParameters.m_InputGateBias =
2799 if(descriptor.m_ProjectionEnabled)
2806 layer->m_ProjectionParameters.m_ProjectionWeights =
2812 layer->m_ProjectionParameters.m_ProjectionBias =
2819 if(descriptor.m_PeepholeEnabled)
2831 if(!descriptor.m_CifgEnabled)
2838 layer->m_PeepholeParameters.m_CellToInputWeights =
2842 layer->m_PeepholeParameters.m_CellToForgetWeights =
2844 layer->m_PeepholeParameters.m_CellToOutputWeights =
2849 if(descriptor.m_LayerNormEnabled)
2866 if(!descriptor.m_CifgEnabled)
2873 layer->m_LayerNormParameters.m_InputLayerNormWeights =
2877 layer->m_LayerNormParameters.m_ForgetLayerNormWeights =
2879 layer->m_LayerNormParameters.m_CellLayerNormWeights =
2881 layer->m_LayerNormParameters.m_OutputLayerNormWeights =
2903 layer->m_BasicParameters.m_InputToCellWeights =
2905 layer->m_BasicParameters.m_InputToOutputWeights =
2907 layer->m_BasicParameters.m_RecurrentToForgetWeights =
2909 layer->m_BasicParameters.m_RecurrentToCellWeights =
2911 layer->m_BasicParameters.m_RecurrentToOutputWeights =
2913 layer->m_BasicParameters.m_ForgetGateBias =
2915 layer->m_BasicParameters.m_CellBias =
2916 std::make_shared<ScopedTensorHandle>(*(params.
m_CellBias));
2917 layer->m_BasicParameters.m_OutputGateBias =
2921 if(!descriptor.m_CifgEnabled)
2926 "when CIFG is disabled.");
2931 "AddUnidirectionalSequenceLstmLayer: Recurrent To Input Weights cannot be NULL "
2932 "when CIFG is disabled.");
2937 "when CIFG is disabled.");
2939 layer->m_CifgParameters.m_InputToInputWeights =
2941 layer->m_CifgParameters.m_RecurrentToInputWeights =
2943 layer->m_CifgParameters.m_InputGateBias =
2948 if(descriptor.m_ProjectionEnabled)
2953 "when projection is enabled.");
2955 layer->m_ProjectionParameters.m_ProjectionWeights =
2959 layer->m_ProjectionParameters.m_ProjectionBias =
2965 if(descriptor.m_PeepholeEnabled)
2967 if(!descriptor.m_CifgEnabled)
2972 "cannot be NULL when Peephole is enabled and CIFG disabled.");
2975 layer->m_PeepholeParameters.m_CellToInputWeights =
2982 "when Peephole is enabled.");
2987 "when Peephole is enabled.");
2990 layer->m_PeepholeParameters.m_CellToForgetWeights =
2992 layer->m_PeepholeParameters.m_CellToOutputWeights =
2997 if(descriptor.m_LayerNormEnabled)
2999 if(!descriptor.m_CifgEnabled)
3004 "cannot be NULL when layer normalization is enabled and CIFG disabled.");
3006 layer->m_LayerNormParameters.m_InputLayerNormWeights =
3013 "cannot be NULL when layer normalization is enabled.");
3018 "cannot be NULL when layer normalization is enabled.");
3023 "cannot be NULL when layer normalization is enabled.");
3025 layer->m_LayerNormParameters.m_ForgetLayerNormWeights =
3027 layer->m_LayerNormParameters.m_CellLayerNormWeights =
3029 layer->m_LayerNormParameters.m_OutputLayerNormWeights =
3047 return m_Graph->AddLayer<
TileLayer>(desc, name);
3063 layer = m_Graph->AddLayer<
PreCompiledLayer>(preCompiledDescriptor,
"pre-compiled");
3092 layer->ExecuteStrategy(strategy);
3097 : m_Graph(new
Graph(*other.m_Graph.get()))
3098 , m_Guid(
arm::pipe::IProfilingService::GetNextGuid())
3099 , m_ModelOptions(modelOptions)
3104 : m_Graph(
std::move(graph)), m_Guid(
arm::pipe::IProfilingService::GetNextGuid())
3109 : m_Graph(
std::move(graph)), m_Guid(
arm::pipe::IProfilingService::GetNextGuid()), m_ModelOptions(modelOptions)
3126 layer->ExecuteStrategy(strategy);
IConnectableLayer * AddReshapeLayer(const ReshapeDescriptor &reshapeDescriptor, const char *name=nullptr)
Adds a reshape layer to the network.
IConnectableLayer * AddDepthToSpaceLayer(const DepthToSpaceDescriptor &depthToSpaceDescriptor, const char *name=nullptr)
#define ARMNN_ASSERT(COND)
A BatchNormalizationDescriptor for the BatchNormalizationLayer.
IConnectableLayer * AddTransposeConvolution2dLayer(const TransposeConvolution2dDescriptor &descriptor, const ConstTensor &weights, const Optional< ConstTensor > &biases, const char *name=nullptr)
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
OptimizeForType< Layer, AddDebugToFileImpl > InsertDebugToFileLayer
IConnectableLayer * AddReverseV2Layer(const char *name=nullptr)
Add a ReverseV2 layer to the network.
std::unique_ptr< IOptimizedNetwork, void(*)(IOptimizedNetwork *network)> IOptimizedNetworkPtr
void ExecuteStrategy(IStrategy &strategy) const
OptimizationResult ApplyBackendOptimizations(OptimizedNetworkImpl *optNetObjPtr, BackendSettings &backendSettings, BackendsMap &backends, const ModelOptions &modelOptions, Optional< std::vector< std::string > & > errMessages)
std::shared_ptr< ConstTensorHandle > m_InputToInputWeights
A unique pointer to represent 2D weights tensor with dimensions [outputSize, inputSize] (QAsymm8).
void SetExportEnabled(bool ExportState)
IConnectableLayer * AddConstantLayer(const ConstTensor &input, const char *name=nullptr)
Adds a layer with no inputs and a single output, which always corresponds to the passed in constant t...
void ExecuteStrategy(IStrategy &strategy) const
IConnectableLayer * AddLogicalBinaryLayer(const LogicalBinaryDescriptor &logicalBinaryDescriptor, const char *name=nullptr)
void SetTensorHandleFactory(const ITensorHandleFactory::FactoryId &id)
OptimizeForType< Layer, AddDebugImpl > InsertDebugLayer
A ViewsDescriptor for the SplitterLayer.
const std::shared_ptr< IProfiler > & GetProfiler() const
An ActivationDescriptor for the ActivationLayer.
IConnectableLayer * AddFullyConnectedLayer(const FullyConnectedDescriptor &fullyConnectedDescriptor, const char *name=nullptr)
IConnectableLayer * AddQLstmLayer(const QLstmDescriptor &descriptor, const LstmInputParams ¶ms, const char *name=nullptr)
Add a QLstm layer to the network.
OptimizeForExclusiveConnection< Convolution2dLayer, BatchNormalizationLayer, FuseBatchNorm< Convolution2dLayer, armnn::DataType::Float32 > > FuseBatchNormIntoConvolution2DFloat32
A FullyConnectedDescriptor for the FullyConnectedLayer.
IConnectableLayer * AddReverseV2Layer(const char *name=nullptr)
bool IsWarningOnly() const
IConnectableLayer * AddCastLayer(const char *name=nullptr)
Adds a cast layer to the network.
IConnectableLayer * AddReduceLayer(const ReduceDescriptor &reduceDescriptor, const char *name=nullptr)
Adds a reduce layer to the network.
IConnectableLayer * AddMaximumLayer(const char *name=nullptr)
Add a Maximum layer to the network.
This layer represents a comparison operation.
bool m_ImportEnabled
Enable Import.
A QLstmDescriptor for the QLstmLayer.
virtual bool SupportsMapUnmap() const
const char * GetLayerTypeAsCString(LayerType type)
This layer represents a DepthToSpace operation.
This layer represents a split operation.
This layer represents a merge operation.
@ GpuAcc
GPU Execution: OpenCL: ArmCompute.
IConnectableLayer * AddTransposeLayer(const TransposeDescriptor &transposeDescriptor, const char *name=nullptr)
void RegisterProfiler(IProfiler *profiler)
IConnectableLayer * AddAdditionLayer(const char *name=nullptr)
Adds an addition layer to the network.
std::vector< ConvertFp16ToFp32Layer * > InsertConvertFp16ToFp32LayersBefore(Graph &graph, Layer &layer, bool expectCorrectInputType)
This layer represents a QLstm operation.
void ForEachLayer(Func func) const
const TensorInfo & GetTensorInfo() const override
IConnectableLayer * AddConvolution2dLayer(const Convolution2dDescriptor &convolution2dDescriptor, const char *name=nullptr)
std::string GetName() const
IConnectableLayer * AddBroadcastToLayer(const BroadcastToDescriptor &descriptor, const char *name=nullptr)
OptimizerOptionsOpaque & operator=(OptimizerOptionsOpaque other)
virtual Status PrintGraph()
IConnectableLayer * AddSliceLayer(const SliceDescriptor &sliceDescriptor, const char *name=nullptr)
Adds a slice layer to the network.
IConnectableLayer * AddTileLayer(const TileDescriptor &tileDescriptor, const char *name=nullptr)
This layer represents a normalization operation.
A Pooling3dDescriptor for the Pooling3dLayer.
OptimizeForConnection< PermuteLayer, PermuteLayer, OptimizeInversePermutesImpl< PermuteLayer > > OptimizeInversePermutes
BackendIdSet m_IgnoredBackends
This layer represents a log softmax operation.
OptimizeForConnection< TransposeLayer, BatchToSpaceNdLayer, PermuteAndBatchToSpaceAsDepthToSpaceImpl< TransposeLayer > > TransposeAndBatchToSpaceAsDepthToSpace
IConnectableLayer * AddDivisionLayer(const char *name=nullptr)
std::shared_ptr< ConstTensorHandle > m_Mean
A unique pointer to store Mean values.
A ResizeDescriptor for the ResizeLayer.
This layer represents a subtraction operation.
@ DirectCompatibility
No strategy has been defined. Used internally to verify integrity of optimizations.
ITensorHandleFactory::FactoryId CalculateSlotOption(BackendsMap &backends, OutputSlot &outputSlot, TensorHandleFactoryRegistry ®istry, bool exportEnabled)
Optional< BackendId > GetBackendHint() const
An ArgMinMaxDescriptor for ArgMinMaxLayer.
OptimizeForExclusiveConnection< PadLayer, Pooling2dLayer, pad_fold::FoldPadIntoPooling2dImpl > FoldPadIntoPooling2d
@ CpuRef
CPU Execution: Reference C++ kernels.
This layer represents a pooling 3d operation.
An InstanceNormalizationDescriptor for InstanceNormalizationLayer.
OptimizeForType< Layer, ConvertFp32NetworkToFp16Impl > Fp32NetworkToFp16Converter
void EraseLayer(Iterator pos)
Deletes the layer at the specified position.
This layer represents a depthwise convolution 2d operation.
IConnectableLayer * AddAdditionLayer(const char *name=nullptr)
void SetTensorInfo(const TensorInfo &tensorInfo) override
A GatherDescriptor for the GatherLayer.
IConnectableLayer * AddMeanLayer(const MeanDescriptor &meanDescriptor, const char *name=nullptr)
Add a Mean layer to the network.
void SubstituteSubgraph(SubgraphView &subgraph, IConnectableLayer *substituteLayer)
Substitutes the given sub-graph with either a new layer or a new sub-graph.
ITensorHandleFactory * GetFactory(ITensorHandleFactory::FactoryId id) const
Find a TensorHandleFactory by Id Returns nullptr if not found.
This layer represents a floor operation.
virtual Status SerializeToDot(std::ostream &stream) const
IConnectableLayer * AddDequantizeLayer(const char *name=nullptr)
Adds a Dequantize layer to the network.
size_t GetNumInputs() const
IConnectableLayer * AddTileLayer(const TileDescriptor &descriptor, const char *name=nullptr)
Add a Tile layer to the network.
IConnectableLayer * AddSplitterLayer(const ViewsDescriptor &splitterDescriptor, const char *name=nullptr)
OptimizeForExclusiveConnection< PadLayer, Convolution2dLayer, pad_fold::FoldPadIntoConvolution2dImpl > FoldPadIntoConvolution2d
void ExecuteStrategy(IStrategy &strategy) const
A L2NormalizationDescriptor for the L2NormalizationLayer.
This layer represents a mean operation.
void SetReduceFp32ToFp16(bool ReduceFp32ToFp16State)
IConnectableLayer * AddSpaceToBatchNdLayer(const SpaceToBatchNdDescriptor &spaceToBatchNdDescriptor, const char *name=nullptr)
Adds a space to batch layer to the network.
const Subgraphs & GetFailedSubgraphs() const
constexpr const char * GetDataTypeName(DataType dataType)
IConnectableLayer * AddL2NormalizationLayer(const L2NormalizationDescriptor &desc, const char *name=nullptr)
Adds an L2 normalization layer to the network.
void SetDataType(DataType type)
Status SerializeToDot(std::ostream &stream) const
A NormalizationDescriptor for the NormalizationLayer.
OptimizeForConnection< ConstantLayer, DequantizeLayer, ConvertConstDequantisationLayersToConstLayersImpl > ConvertConstDequantisationLayersToConstLayers
arm::pipe::ProfilingGuid GetGuid() const
bool GetExportEnabled() const
IConnectableLayer * AddSubtractionLayer(const char *name=nullptr)
IConnectableLayer * AddComparisonLayer(const ComparisonDescriptor &comparisonDescriptor, const char *name=nullptr)
Add a Comparison layer to the network.
~OptimizerOptionsOpaque()
IConnectableLayer * AddStridedSliceLayer(const StridedSliceDescriptor &stridedSliceDescriptor, const char *name=nullptr)
OptimizeForConnection< Layer, TransposeLayer, MoveTransposeUpImpl > MoveTransposeUp
A ChannelShuffleDescriptor for the ChannelShuffle operator.
IConnectableLayer * AddLogSoftmaxLayer(const LogSoftmaxDescriptor &logSoftmaxDescriptor, const char *name=nullptr)
LstmBasicParameters m_BasicParameters
void VerifyConstantLayerSetTensorInfo() const
For each ConstantLayer in Graph, ensures TensorInfo is set on all output slots.
IConnectableLayer * AddFullyConnectedLayer(const FullyConnectedDescriptor &fullyConnectedDescriptor, const char *name=nullptr)
Adds a fully connected layer to the network.
IConnectableLayer * AddMeanLayer(const MeanDescriptor &meanDescriptor, const char *name=nullptr)
This layer represents a 2D transpose convolution operation.
IConnectableLayer * AddResizeLayer(const ResizeDescriptor &resizeDescriptor, const char *name=nullptr)
IConnectableLayer * AddBatchMatMulLayer(const BatchMatMulDescriptor &descriptor, const char *name=nullptr)
Add a BatchMatMul layer to the network.
virtual MemorySourceFlags GetExportFlags() const
This layer represents a Gather operator.
const OutputSlot & GetOutputSlot(unsigned int index=0) const override
Get the const output slot handle by slot index.
armnn::ModelOptions GetModelOptions() const
OptimizationResult AssignBackends(OptimizedNetworkImpl *optNetObjPtr, BackendSettings &backendSettings, Graph::Iterator &firstLayer, Graph::Iterator &lastLayer, Optional< std::vector< std::string > & > errMessages)
OptimizeForType< BroadcastToLayer, DeleteBroadcastToImpl > BroadcastToOptimizationLayer
IConnectableLayer * AddLogSoftmaxLayer(const LogSoftmaxDescriptor &logSoftmaxDescriptor, const char *name=nullptr)
Adds a log softmax layer to the network.
#define ARMNN_NO_DEPRECATE_WARN_BEGIN
IConnectableLayer * AddBatchMatMulLayer(const BatchMatMulDescriptor &desc, const char *name=nullptr)
LayerList::const_iterator Iterator
IConnectableLayer * AddLstmLayer(const LstmDescriptor &descriptor, const LstmInputParams ¶ms, const char *name=nullptr)
IConnectableLayer * AddReduceLayer(const ReduceDescriptor &reduceDescriptor, const char *name=nullptr)
IConnectableLayer * AddConstantLayer(const ConstTensor &input, const char *name=nullptr)
bool GetImportEnabled() const
This layer represents a ArgMinMax operation.
OptimizeForType< PermuteLayer, PermuteAsReshapeImpl > PermuteAsReshape
IConnectableLayers::iterator IConnectableLayerIterator
void ReportWarning(const std::string &warningMessage, Optional< std::vector< std::string > & > warningMessages)
A StackDescriptor for the StackLayer.
bool GetReduceFp32ToBf16() const
static INetwork * CreateRaw(const NetworkOptions &networkOptions={})
This layer represents a stack operation.
IConnectableLayer * AddDepthwiseConvolution2dLayer(const DepthwiseConvolution2dDescriptor &convolution2dDescriptor, const char *name=nullptr)
const std::vector< InputSlot > & GetInputSlots() const
bool m_ReduceFp32ToFp16
Reduces all Fp32 operators in the model to Fp16 for faster processing.
virtual ~OptimizedNetworkImpl()
int Connect(InputSlot &destination)
OptimizeForConnection< PermuteLayer, BatchToSpaceNdLayer, PermuteAndBatchToSpaceAsDepthToSpaceImpl< PermuteLayer > > PermuteAndBatchToSpaceAsDepthToSpace
OptimizedNetworkImpl(const OptimizedNetworkImpl &other, const ModelOptions &modelOptions)
This layer represents a batch normalization operation.
#define ARMNN_ASSERT_MSG(COND, MSG)
IConnectableLayer * AddPreluLayer(const char *name=nullptr)
Adds a PReLU layer to the network.
bool GetReduceFp32ToFp16() const
OptimizationResult SelectTensorHandleStrategy(Graph &optGraph, BackendsMap &backends, TensorHandleFactoryRegistry ®istry, bool importEnabled, bool exportEnabled, Optional< std::vector< std::string > & > errMessages)
This layer represents a BatchToSpaceNd operation.
IConnectableLayer * AddOutputLayer(LayerBindingId id, const char *name=nullptr)
Adds an output layer to the network.
IConnectableLayer * AddComparisonLayer(const ComparisonDescriptor &comparisonDescriptor, const char *name=nullptr)
const InputSlot & GetInputSlot(unsigned int index) const override
Get a const input slot handle by slot index.
void ExecuteStrategy(IStrategy &strategy) const
IConnectableLayer * AddStridedSliceLayer(const StridedSliceDescriptor &stridedSliceDescriptor, const char *name=nullptr)
Adds a strided slice layer to the network.
IConnectableLayer * AddFusedLayer(const FusedDescriptor &fusedDescriptor, const char *name=nullptr)
Adds a Fused layer to the network.
OptimizeForConnection< Layer, PermuteLayer, MovePermuteUpImpl > MovePermuteUp
OptimizeForConnection< ConvertFp16ToFp32Layer, ConvertFp32ToFp16Layer, OptimizeInverseConversionsImpl > OptimizeInverseConversionsFp16
IConnectableLayer * AddSwitchLayer(const char *name=nullptr)
IConnectableLayer * AddSpaceToDepthLayer(const SpaceToDepthDescriptor &spaceToDepthDescriptor, const char *name=nullptr)
static const FactoryId LegacyFactoryId
IConnectableLayer * AddFloorLayer(const char *name=nullptr)
IConnectableLayer * AddSoftmaxLayer(const SoftmaxDescriptor &softmaxDescriptor, const char *name=nullptr)
Adds a softmax layer to the network.
This layer represents a minimum operation.
BackendIdSet m_SelectedBackends
IConnectableLayer * AddPermuteLayer(const PermuteDescriptor &permuteDescriptor, const char *name=nullptr)
Adds a permute layer to the network.
This layer represents a convolution 2d operation.
virtual const char * what() const noexcept override
IConnectableLayer * AddPermuteLayer(const PermuteDescriptor &permuteDescriptor, const char *name=nullptr)
IConnectableLayer * AddRankLayer(const char *name=nullptr)
#define ARMNN_LOG(severity)
IConnectableLayer * AddTransposeLayer(const TransposeDescriptor &transposeDescriptor, const char *name=nullptr)
Adds a transpose layer to the network.
@ CopyToTarget
Source backends tensor data can be exported to destination backend tensor without copy.
armnn::ShapeInferenceMethod GetShapeInferenceMethod() const
IConnectableLayer * AddArgMinMaxLayer(const ArgMinMaxDescriptor &desc, const char *name=nullptr)
virtual std::vector< Capability > GetCapabilities(const IConnectableLayer *layer, const IConnectableLayer *connectedLayer, CapabilityClass capabilityClass)
void SetShapeInferenceMethod(armnn::ShapeInferenceMethod ShapeInferenceMethodType)
A ElementwiseBinaryDescriptor for the ElementwiseBinaryLayer.
IConnectableLayer * AddStackLayer(const StackDescriptor &descriptor, const char *name=nullptr)
Adds a stack layer to the network.
This layer represents a transpose operation.
This layer represents an addition operation.
BackendsMap CreateSupportedBackends(TensorHandleFactoryRegistry &handleFactoryRegistry, BackendSettings &backendSettings)
IConnectableLayer * AddBatchToSpaceNdLayer(const BatchToSpaceNdDescriptor &batchToSpaceNdDescriptor, const char *name=nullptr)
IConnectableLayer * AddPreluLayer(const char *name=nullptr)
ShapeInferenceMethod m_shapeInferenceMethod
Infer output size when not available.
IConnectableLayer * AddPooling3dLayer(const Pooling3dDescriptor &pooling3dDescriptor, const char *name=nullptr)
Adds a 3D pooling layer to the network.
std::list< IConnectableLayer * > IConnectableLayers
IConnectableLayer * AddUnidirectionalSequenceLstmLayer(const UnidirectionalSequenceLstmDescriptor &descriptor, const LstmInputParams ¶ms, const char *name=nullptr)
IConnectableLayer * AddSoftmaxLayer(const SoftmaxDescriptor &softmaxDescriptor, const char *name=nullptr)
std::vector< BackendOptions > NetworkOptions
A FusedDescriptor for the FusedLayer.
Layer & GetOwningLayer() const
IConnectableLayer * AddBatchNormalizationLayer(const BatchNormalizationDescriptor &desc, const ConstTensor &mean, const ConstTensor &variance, const ConstTensor &beta, const ConstTensor &gamma, const char *name=nullptr)
Iterator begin()
Returns iterator pointing to the beginning of the list. Lowercase for range-based for loops.
IConnectableLayer * AddUnidirectionalSequenceLstmLayer(const UnidirectionalSequenceLstmDescriptor &descriptor, const LstmInputParams ¶ms, const char *name=nullptr)
Add a UnidirectionalSequenceLstm layer to the network.
IConnectableLayer * AddDepthToSpaceLayer(const DepthToSpaceDescriptor &depthToSpaceDescriptor, const char *name=nullptr)
Adds a depth to space layer to the network.
This layer represents a reshape operation.
ConvertConstants< Float32ToFloat16, IsFloat16Layer > ConvertConstantsFloatToHalf
static Subgraphs SelectSubgraphs(Graph &graph, const LayerSelectorFunction &selector)
Selects subgraphs from a graph based on the selector function and the algorithm.
const IConnectableLayers & GetIConnectableLayers() const
OptimizationResult AttemptBackendAssignment(BackendSettings &backendSettings, Graph &graph, Layer *layer, BackendId backend, DataType dataTypeIn, DataType dataTypeOut, const std::vector< BackendId > &availablePreferredBackends, std::string &reasonIfUnsupported, Optional< std::vector< std::string > & > errMessages)
IConnectableLayer * AddMergeLayer(const char *name=nullptr)
Adds a merge layer to the network.
This layer converts data type Float 32 to Float 16.
BackendIdSet m_SupportedBackends
This layer converts data type Float 16 to Float 32.
This layer represents a LSTM operation.
void Disconnect(InputSlot &slot)
IConnectableLayer * AddFillLayer(const FillDescriptor &fillDescriptor, const char *name=nullptr)
IConnectableLayer * AddSpaceToDepthLayer(const SpaceToDepthDescriptor &spaceToDepthDescriptor, const char *name=nullptr)
Adds a space to depth layer to the network.
void AddModelOption(armnn::BackendOptions)
IConnectableLayerIterator begin()
static const FactoryId DeferredFactoryId
Use the workload factory to create the tensor handle.
IConnectableLayer * AddPrecompiledLayer(const PreCompiledDescriptor &preCompiledDescriptor, CompiledBlobPtr compiledBlobPtr, const Optional< BackendId > &backend, const char *name=nullptr)
Adds a Precompiled layer to the network.
std::vector< ConvertFp32ToFp16Layer * > InsertConvertFp32ToFp16LayersAfter(Graph &graph, Layer &layer)
A PadDescriptor for the PadLayer.
IConnectableLayer * AddGatherNdLayer(const char *name=nullptr)
#define ARMNN_SCOPED_PROFILING_EVENT(backendId, name)
This layer represents a reduction operation.
A TransposeDescriptor for the TransposeLayer.
This layer represents a multiplication operation.
unsigned int GetNumConnections() const override
EmptyOptional is used to initialize the Optional class in case we want to have default value for an O...
A SliceDescriptor for the SliceLayer.
static void ConvertFloat16To32(const void *srcFloat16Buffer, size_t numElements, float *dstFloat32Buffer)
void ReportError(const std::string &errorMessage, Optional< std::vector< std::string > & > errorMessages)
bool CheckFp16Support(BackendsMap &backends, const std::vector< BackendId > &availablePreferredBackends)
IConnectableLayer * AddStackLayer(const StackDescriptor &stackDescriptor, const char *name=nullptr)
IConnectableLayer * AddSplitterLayer(const ViewsDescriptor &splitterDescriptor, const char *name=nullptr)
Adds a splitter layer to the network.
IConnectableLayer * AddShapeLayer(const char *name=nullptr)
Adds a shape layer to the network.
IConnectableLayer * AddElementwiseUnaryLayer(const ElementwiseUnaryDescriptor &elementwiseUnaryDescriptor, const char *name=nullptr)
This layer represents a SpaceToDepth operation.
BackendRegistry & BackendRegistryInstance()
IConnectableLayer * AddBatchNormalizationLayer(const BatchNormalizationDescriptor &desc, const ConstTensor &mean, const ConstTensor &variance, const ConstTensor &beta, const ConstTensor &gamma, const char *name=nullptr)
Adds a batch normalization layer to the network.
A ReshapeDescriptor for the ReshapeLayer.
A layer user-provided data can be bound to (e.g. inputs, outputs).
IConnectableLayer * AddConvertFp16ToFp32Layer(const char *name=nullptr)
IConnectableLayer * AddOutputLayer(LayerBindingId id, const char *name=nullptr)
bool m_Debug
Add debug data for easier troubleshooting.
OptimizeForConnection< ConstantLayer, PermuteLayer, ConvertConstPermuteLayersToConstLayers > FusePermuteIntoConstLayer
int LayerBindingId
Type of identifiers for bindable layers (inputs, outputs).
IConnectableLayer * AddReshapeLayer(const ReshapeDescriptor &reshapeDescriptor, const char *name=nullptr)
IConnectableLayer * AddQLstmLayer(const QLstmDescriptor &descriptor, const LstmInputParams ¶ms, const char *name=nullptr)
This layer represents a L2 normalization operation.
bool m_ExportEnabled
Enable Export.
IConnectableLayer * AddMinimumLayer(const char *name=nullptr)
Add a Minimum layer to the network.
const std::string & Get() const
IConnectableLayer * AddConvolution2dLayer(const Convolution2dDescriptor &convolution2dDescriptor, const char *name=nullptr)
Adds a 2D convolution layer to the network.
unsigned int GetNumOutputSlots() const override
Returns the number of connectable output slots.
Optimizer::Optimizations MakeOptimizations(Args &&... args)
IConnectableLayer * AddInputLayer(LayerBindingId id, const char *name=nullptr)
const Graph & GetGraph() const
IConnectableLayer * AddDetectionPostProcessLayer(const DetectionPostProcessDescriptor &descriptor, const ConstTensor &anchors, const char *name=nullptr)
Adds a Detection PostProcess layer to the network.
A PermuteDescriptor for the PermuteLayer.
This layer dequantizes the input tensor.
A BatchMatMulDescriptor for the BatchMatMul operator.
This layer represents a ReverseV2 operation.
IConnectableLayer * AddLogicalBinaryLayer(const LogicalBinaryDescriptor &descriptor, const char *name=nullptr)
Adds a Logical Binary layer to the network.
This layer represents a SpaceToBatchNd operation.
IConnectableLayer * AddMinimumLayer(const char *name=nullptr)
const std::shared_ptr< IProfiler > & GetProfiler() const
virtual size_t GetNumInputs() const
bool RequiresCopy(ITensorHandleFactory::FactoryId src, ITensorHandleFactory::FactoryId dst, TensorHandleFactoryRegistry ®istry)
The SubgraphView class represents a subgraph of a Graph.
This layer represents a fully connected operation.
IConnectableLayer * AddDivisionLayer(const char *name=nullptr)
Adds a division layer to the network.
This layer represents an unknown operation in the input graph.
OptimizationResult ReturnWithError(OptimizationResult res, const Layer *layer, const BackendSettings &backendSettings, Optional< std::vector< std::string > & > errMessages)
virtual MemorySourceFlags GetImportFlags() const
IConnectableLayer * AddElementwiseBinaryLayer(const ElementwiseBinaryDescriptor &elementwiseBinaryDescriptor, const char *name=nullptr)
bool GetDebugToFileEnabled() const
A SpaceToBatchNdDescriptor for the SpaceToBatchNdLayer.
IConnectableLayer * AddRankLayer(const char *name=nullptr)
Adds a rank layer to the network.
IConnectableLayer * AddPadLayer(const PadDescriptor &padDescriptor, const char *name=nullptr)
Adds a fully pad layer to the network.
A Convolution3dDescriptor for the Convolution3dLayer.
This layer represents a QuantizedLstm operation.
This layer represents a elementwiseBinary operation.
This layer represents a pooling 2d operation.
IConnectableLayer * AddQuantizeLayer(const char *name=nullptr)
This layer calculates both true and false outputs for input.
IConnectableLayer * AddNormalizationLayer(const NormalizationDescriptor &normalizationDescriptor, const char *name=nullptr)
This layer represents a division operation.
IConnectableLayer * AddLstmLayer(const LstmDescriptor &descriptor, const LstmInputParams ¶ms, const char *name=nullptr)
Add a Lstm layer to the network.
Private implementation of INetwork.
size_t GetNumOutputs() const
std::vector< DataType > GetLayerInOutDatatype(const Layer *layer)
BackendIdVector GetAvailablePreferredBackends() const
bool m_ProfilingEnabled
Enable profiling dump of the optimizer phase.
IConnectableLayer * AddMergeLayer(const char *name=nullptr)
void SetAllowExpandedDims(bool ExpandedDimsAllowed)
IConnectableLayer * AddShapeLayer(const char *name=nullptr)
DataType GetDataType() const
IConnectableLayer * AddStandInLayer(const StandInDescriptor &descriptor, const char *name=nullptr)
Add a stand-in layer for a type unknown to the Arm NN framework.
const std::string & GetNameStr() const
static bool IsLayerSupported(const BackendId &backendId, const IConnectableLayer &layer, Optional< DataType > dataType, std::string &outReasonIfUnsupported)
This layer represents a fill operation.
IConnectableLayer * AddConcatLayer(const ConcatDescriptor &concatDescriptor, const char *name=nullptr)
bool GetDebugEnabled() const
unsigned int GetNumInputSlots() const override
Returns the number of connectable input slots.
This layer represents an instance normalization operation.
IConnectableLayer * AddCastLayer(const char *name=nullptr)
IConnectableLayer * AddSwitchLayer(const char *name=nullptr)
Adds a switch layer to the network.
IConnectableLayer * AddElementwiseBinaryLayer(const ElementwiseBinaryDescriptor &elementwiseBinaryDescriptor, const char *name=nullptr)
Add an ElementwiseBinary layer to the network.
std::shared_ptr< ConstTensorHandle > m_Anchors
A unique pointer to store Anchor values.
@ ValidateOnly
Validate all output shapes.
This layer represents a cast operation.
This layer represents a LSTM operation.
IConnectableLayer * AddFillLayer(const FillDescriptor &fillDescriptor, const char *name=nullptr)
Add an Fill layer to the network.
A BatchToSpaceNdDescriptor for the BatchToSpaceNdLayer.
@ InferAndValidate
Infer missing output shapes and validate all output shapes.
A Convolution2dDescriptor for the Convolution2dLayer.
IConnectableLayer * AddFusedLayer(const FusedDescriptor &fusedDescriptor, const char *name=nullptr)
IConnectableLayer * AddStandInLayer(const StandInDescriptor &descriptor, const char *name=nullptr)
A ComparisonDescriptor for the ComparisonLayer.
A FillDescriptor for the FillLayer.
IConnectableLayer * AddSubtractionLayer(const char *name=nullptr)
Adds a subtraction layer to the network.
bool m_ReduceFp32ToBf16
@Note This feature has been replaced by enabling Fast Math in compute library backend options.
IConnectableLayer * AddQuantizedLstmLayer(const QuantizedLstmInputParams ¶ms, const char *name=nullptr)
void ParseOptions(const std::vector< BackendOptions > &options, BackendId backend, F f)
A StandInDescriptor for the StandIn layer.
QuantizedLstmParameters m_QuantizedLstmParameters
ModelOptions m_ModelOptions
Enable Model Options.
IConnectableLayer * AddQuantizedLstmLayer(const QuantizedLstmInputParams ¶ms, const char *name=nullptr)
Add a QuantizedLstm layer to the network.
This layer represents a strided slice operation.
LstmBasicParameters m_BasicParameters
bool Validate(const SubgraphView &originalSubgraph) const
OptimizeForConnection< ConvertFp32ToFp16Layer, ConvertFp16ToFp32Layer, OptimizeInverseConversionsImpl > OptimizeInverseConversionsFp32
bool IsCpuRefUsed() const
Struct for the users to pass backend specific options.
IConnectableLayer * AddDequantizeLayer(const char *name=nullptr)
LayerType GetType() const override
Returns the armnn::LayerType of this layer.
void AddCompatibilityLayers(std::map< BackendId, std::unique_ptr< class IBackendInternal >> &backends, TensorHandleFactoryRegistry ®istry)
Modifies the graph in-place, removing edges connecting layers using different compute devices,...
std::shared_ptr< ConstTensorHandle > m_InputToForgetWeights
A unique pointer to represent 2D weights tensor with dimensions [input_size, num_units].
An LstmDescriptor for the LstmLayer.
A StridedSliceDescriptor for the StridedSliceLayer.
ITensorHandleFactory::FactoryId CalculateSlotOptionForOutput(BackendsMap &backends, OutputSlot &slot, TensorHandleFactoryRegistry ®istry)
IConnectableLayer * AddTransposeConvolution2dLayer(const TransposeConvolution2dDescriptor &descriptor, const ConstTensor &weights, const Optional< ConstTensor > &biases, const char *name=nullptr)
Adds a 2D transpose convolution layer to the network.
INetwork(NetworkOptions networkOptions={})
OptimizeForType< TransposeLayer, TransposeAsReshapeImpl > TransposeAsReshape
std::shared_ptr< ConstTensorHandle > m_Weight
A unique pointer to store weight values.
Iterator end()
Returns iterator pointing to the end of the list. Lowercase for range-based for loops.
A LogicalBinaryDescriptor for the LogicalBinaryLayer.
static ProfilerManager & GetInstance()
This layer represents an activation operation with the specified activation function.
bool GetAllowExpandedDims() const
This layer represents a softmax operation.
ITensorHandleFactory::FactoryId CalculateSlotOptionForInput(BackendsMap &backends, OutputSlot &slot, TensorHandleFactoryRegistry ®istry, bool importEnabled)
#define ARMNN_NO_DEPRECATE_WARN_END
IConnectableLayer * AddDepthwiseConvolution2dLayer(const DepthwiseConvolution2dDescriptor &convolution2dDescriptor, const char *name=nullptr)
Adds a 2D depthwise convolution layer to the network.
IConnectableLayer * AddPooling2dLayer(const Pooling2dDescriptor &pooling2dDescriptor, const char *name=nullptr)
Adds a 2D pooling layer to the network.
OptimizeForExclusiveConnection< Convolution2dLayer, BatchNormalizationLayer, FuseBatchNorm< Convolution2dLayer, armnn::DataType::Float16 > > FuseBatchNormIntoConvolution2DFloat16
std::shared_ptr< ConstTensorHandle > m_LayerOutput
IConnectableLayer * AddNormalizationLayer(const NormalizationDescriptor &normalizationDescriptor, const char *name=nullptr)
Adds a normalization layer to the network.
const std::string ToString() const
This layer represents a GatherNd operator.
void IgnoreUnused(Ts &&...)
IConnectableLayer * AddQuantizeLayer(const char *name=nullptr)
Add a quantize layer to the network.
@ ExportToTarget
Destination backend can work directly with tensors on source backend.
static void Destroy(INetwork *network)
const std::vector< InputSlot * > & GetConnections() const
void SetEdgeStrategy(unsigned int connectionIndex, EdgeStrategy strategy)
const Substitutions & GetSubstitutions() const
std::unique_ptr< NetworkImpl > pNetworkImpl
IConnectableLayerIterator end()
static void Destroy(IOptimizedNetwork *network)
const Subgraphs & GetDeletedSubgraphs() const
const BackendId & GetBackendId() const
IConnectableLayer * AddL2NormalizationLayer(const L2NormalizationDescriptor &desc, const char *name=nullptr)
This layer represents a convolution 3d operation.
IConnectableLayer * AddActivationLayer(const ActivationDescriptor &activationDescriptor, const char *name=nullptr)
OptimizeForExclusiveConnection< DepthwiseConvolution2dLayer, BatchNormalizationLayer, FuseBatchNorm< DepthwiseConvolution2dLayer, armnn::DataType::Float16 > > FuseBatchNormIntoDepthwiseConvolution2DFloat16
An OriginsDescriptor for the ConcatLayer.
std::map< BackendId, std::unique_ptr< class IBackendInternal > > BackendsMap
@ CpuAcc
CPU Execution: NEON: ArmCompute.
IConnectableLayer * AddPooling3dLayer(const Pooling3dDescriptor &pooling3dDescriptor, const char *name=nullptr)
bool GetProfilingEnabled() const
OptimizeForConnection< Layer, TransposeLayer, SquashEqualSiblingsImpl< TransposeLayer > > SquashEqualTransposeSiblings
A layer that the constant data can be bound to.
Copyright (c) 2021 ARM Limited and Contributors.
A ElementwiseUnaryDescriptor for the ElementwiseUnaryLayer.
A TransposeConvolution2dDescriptor for the TransposeConvolution2dLayer.
ConvertConstants< Float16ToFloat32, IsFloat32Layer > ConvertConstantsHalfToFloat
void SetPreCompiledObject(PreCompiledObjectPtr preCompiledObject)
void SetBackendId(const BackendId &id) override
Set the backend of the IConnectableLayer.
IConnectableLayer * AddPooling2dLayer(const Pooling2dDescriptor &pooling2dDescriptor, const char *name=nullptr)
This layer represents a elementwiseUnary operation.
This layer represents a detection postprocess operator.
void SetProfilingEnabled(bool ProfilingState)
IOptimizedNetwork(const IOptimizedNetwork &other, const ModelOptions &modelOptions)
Creates a copy of the IOptimizedNetwork.
IConnectableLayer * AddConcatLayer(const ConcatDescriptor &concatDescriptor, const char *name=nullptr)
Adds a concatenation layer to the network.
OptimizeForConnection< Layer, PermuteLayer, SquashEqualSiblingsImpl< PermuteLayer > > SquashEqualPermuteSiblings
void SetDebugToFileEnabled(bool DebugFileState)
This layer represents a Logical Binary operation.
bool m_DebugToFile
Pass debug data to separate output files for easier troubleshooting.
IConnectableLayer * AddMultiplicationLayer(const char *name=nullptr)
Adds a multiplication layer to the network.
IConnectableLayer * AddConvolution3dLayer(const Convolution3dDescriptor &convolution3dDescriptor, const char *name=nullptr)
Adds a 3D convolution layer to the network.
A tensor defined by a TensorInfo (shape and data type) and an immutable backing store.
Interface for a layer that is connectable to other layers via InputSlots and OutputSlots.
This layer represents a permutation operation.
static void Pass(Graph &graph, const Optimizations &optimizations)
Device specific knowledge to be passed to the optimizer.
IConnectableLayer * AddMultiplicationLayer(const char *name=nullptr)
virtual std::vector< ITensorHandleFactory::FactoryId > GetHandleFactoryPreferences() const
(Optional) Returns a vector of supported TensorHandleFactory ids in preference order.
std::vector< BackendOptions > ModelOptions
OptimizeForExclusiveConnection< PadLayer, DepthwiseConvolution2dLayer, pad_fold::FoldPadIntoDepthwiseConvolution2dImpl > FoldPadIntoDepthwiseConvolution2d
IConnectableLayer * AddElementwiseUnaryLayer(const ElementwiseUnaryDescriptor &elementwiseUnaryDescriptor, const char *name=nullptr)
Add an ElementwiseUnary layer to the network.
bool m_BiasEnabled
Enable/disable bias.
A PreCompiledDescriptor for the PreCompiledLayer.
IConnectableLayer * AddConvertFp32ToFp16Layer(const char *name=nullptr)
std::string CreateDirectory(std::string sPath)
Returns full path to temporary folder.
IConnectableLayer * AddInstanceNormalizationLayer(const InstanceNormalizationDescriptor &desc, const char *name=nullptr)
IConnectableLayer * AddChannelShuffleLayer(const ChannelShuffleDescriptor &descriptor, const char *name=nullptr)
Add a ChannelShuffle layer to the network.
IConnectableLayer * AddInstanceNormalizationLayer(const InstanceNormalizationDescriptor &desc, const char *name=nullptr)
Adds an instance normalization layer to the network.
bool IsBackendSupported(const BackendId &backend) const
NetworkImpl(const NetworkOptions &networkOptions={})
OptimizeForConnection< Layer, ReshapeLayer, SquashEqualSiblingsImpl< ReshapeLayer > > SquashEqualReshapeSiblings
IConnectableLayer * AddFloorLayer(const char *name=nullptr)
Adds a floor layer to the network.
IConnectableLayer * AddConvolution3dLayer(const Convolution3dDescriptor &convolution3dDescriptor, const char *name=nullptr)
This layer represents a resize operation.
This layer represents a maximum operation.
EdgeStrategy CalculateEdgeStrategy(BackendsMap &backends, ITensorHandleFactory::FactoryId srcFactoryId, const Layer &layer, const Layer &connectedLayer, TensorHandleFactoryRegistry ®istry, bool importEnabled)
A Pooling2dDescriptor for the Pooling2dLayer.
IOptimizedNetworkPtr Optimize(const INetwork &network, const std::vector< BackendId > &backendPreferences, const IDeviceSpec &deviceSpec, const OptimizerOptionsOpaque &options=OptimizerOptionsOpaque(), Optional< std::vector< std::string > & > messages=EmptyOptional())
Create an optimized version of the network.
IConnectableLayer * AddChannelShuffleLayer(const ChannelShuffleDescriptor &channelShuffleDescriptor, const char *name=nullptr)
A DepthwiseConvolution2dDescriptor for the DepthwiseConvolution2dLayer.
ShapeInferenceMethod
The ShapeInferenceMethod modify how the output shapes are treated.
bool m_AllowExpandedDims
When calculating tensor sizes, dimensions of size == 1 will be ignored.
IConnectableLayer * AddGatherLayer(const GatherDescriptor &descriptor, const char *name=nullptr)
Add Gather layer to the network.
OptimizeForConnection< TransposeLayer, TransposeLayer, OptimizeInversePermutesImpl< TransposeLayer > > OptimizeInverseTransposes
QLstmBasicParameters m_BasicParameters
A ReduceDescriptor for the REDUCE operators.
IConnectableLayer * AddSpaceToBatchNdLayer(const SpaceToBatchNdDescriptor &spaceToBatchNdDescriptor, const char *name=nullptr)
IConnectableLayer * AddSliceLayer(const SliceDescriptor &sliceDescriptor, const char *name=nullptr)
IConnectableLayer * AddBroadcastToLayer(const BroadcastToDescriptor &descriptor, const char *name=nullptr)
Add a BroadcastTo layer to the network.
static INetworkPtr Create(const NetworkOptions &networkOptions={})
OptimizeForType< Layer, AddBroadcastReshapeLayerImpl > AddBroadcastReshapeLayer
OptimizeForExclusiveConnection< DepthwiseConvolution2dLayer, BatchNormalizationLayer, FuseBatchNorm< DepthwiseConvolution2dLayer, armnn::DataType::Float32 > > FuseBatchNormIntoDepthwiseConvolution2DFloat32
LayerType
When adding a new layer, adapt also the LastLayer enum value in the enum class LayerType below.
const InputSlot * GetConnection(unsigned int index) const override
OptimizeForConnection< ReshapeLayer, ReshapeLayer, OptimizeConsecutiveReshapesImpl > OptimizeConsecutiveReshapes
virtual size_t GetNumOutputs() const
A MeanDescriptor for the MeanLayer.
std::unique_ptr< void, CompiledBlobDeleter > CompiledBlobPtr
std::vector< SubgraphView::SubgraphViewPtr > Subgraphs
IConnectableLayer * AddGatherLayer(const GatherDescriptor &gatherDescriptor, const char *name=nullptr)
IConnectableLayer * AddPrecompiledLayer(const PreCompiledDescriptor &preCompiledDescriptor, CompiledBlobPtr compiledBlobPtr, const Optional< BackendId > &backend, const char *name=nullptr)
bool CheckScaleSetOnQuantizedType(Layer *layer, Optional< std::vector< std::string > & > errMessages)
void SetDebugEnabled(bool DebugState)
IConnectableLayer * AddBatchToSpaceNdLayer(const BatchToSpaceNdDescriptor &batchToSpaceNdDescriptor, const char *name=nullptr)
Adds a batch to space ND layer to the network.
This layer represents a pad operation.
IConnectableLayer * AddPadLayer(const PadDescriptor &padDescriptor, const char *name=nullptr)
A SoftmaxDescriptor for the SoftmaxLayer.
BackendIdVector m_PreferredBackends
std::shared_ptr< ConstTensorHandle > m_InputToForgetWeights
A unique pointer to represent 2D weights tensor with dimensions [num_units, inputSize] (QSymmS8).
IConnectableLayer * AddResizeLayer(const ResizeDescriptor &resizeDescriptor, const char *name=nullptr)
Adds a resize layer to the network.
IConnectableLayer * AddInputLayer(LayerBindingId id, const char *name=nullptr)
Adds an input layer to the network.
A SpaceToDepthDescriptor for the SpaceToDepthLayer.
bool has_value() const noexcept
IConnectableLayer * AddMaximumLayer(const char *name=nullptr)
IConnectableLayer * AddDetectionPostProcessLayer(const DetectionPostProcessDescriptor &descriptor, const ConstTensor &anchors, const char *name=nullptr)
This layer dequantizes the input tensor.
IConnectableLayer * AddArgMinMaxLayer(const ArgMinMaxDescriptor &desc, const char *name=nullptr)
Adds an ArgMinMax layer to the network.
std::unique_ptr< OptimizedNetworkImpl > pOptimizedNetworkImpl
void AssignBackendsIConnectable(OptimizedNetworkImpl *optNetObjPtr, IConnectableLayer *it, Optional< std::vector< std::string > & > errMessages, OptimizationResult &result, BackendSettings &backendSettings, std::vector< BackendId > &availablePreferredBackends)
IConnectableLayer * AddGatherNdLayer(const char *name=nullptr)
Add GatherNd layer to the network.
IConnectableLayer * AddActivationLayer(const ActivationDescriptor &activationDescriptor, const char *name=nullptr)
Adds an activation layer to the network.
bool HasMatchingCapability(const BackendOptions::BackendOption &capability, const BackendCapabilities &capabilities)
Convenience function to check if a given capability matches a capability in a BackendCapabilities str...
Main network class which provides the interface for building up a neural network.
void SetImportEnabled(bool ImportState)