66 return pNetworkImpl->AddComparisonLayer(comparisonDescriptor, name);
73 return pNetworkImpl->AddConcatLayer(concatDescriptor, name);
82 return pNetworkImpl->AddConvolution2dLayer(convolution2dDescriptor, weights, biases, name);
91 return pNetworkImpl->AddConvolution2dLayer(convolution2dDescriptor, weights, biases, name);
101 return pNetworkImpl->AddConvolution2dLayer(convolution2dDescriptor,
111 return pNetworkImpl->AddDepthToSpaceLayer(depthToSpaceDescriptor, name);
121 return pNetworkImpl->AddDepthwiseConvolution2dLayer(convolution2dDescriptor, weights, biases, name);
131 return pNetworkImpl->AddDepthwiseConvolution2dLayer(convolution2dDescriptor, weights, biases, name);
141 return pNetworkImpl->AddDepthwiseConvolution2dLayer(convolution2dDescriptor, weights,
157 return pNetworkImpl->AddDetectionPostProcessLayer(descriptor, anchors, name);
164 return pNetworkImpl->AddElementwiseUnaryLayer(elementwiseUnaryDescriptor, name);
171 return pNetworkImpl->AddFillLayer(fillDescriptor, name);
180 return pNetworkImpl->AddFullyConnectedLayer(fullyConnectedDescriptor, weights, biases, name);
188 return pNetworkImpl->AddFullyConnectedLayer(fullyConnectedDescriptor, weights, biases, name);
196 return pNetworkImpl->AddFullyConnectedLayer(fullyConnectedDescriptor, weights,
203 return pNetworkImpl->AddPermuteLayer(permuteDescriptor, name);
209 return pNetworkImpl->AddBatchToSpaceNdLayer(batchToSpaceNdDescriptor, name);
215 return pNetworkImpl->AddPooling2dLayer(pooling2dDescriptor, name);
221 return pNetworkImpl->AddActivationLayer(activationDescriptor, name);
227 return pNetworkImpl->AddNormalizationLayer(normalizationDescriptor, name);
232 return pNetworkImpl->AddSliceLayer(sliceDescriptor, name);
237 return pNetworkImpl->AddSoftmaxLayer(softmaxDescriptor, name);
243 return pNetworkImpl->AddSplitterLayer(splitterDescriptor, name);
254 return pNetworkImpl->AddConcatLayer(mergerDescriptor, name);
279 return pNetworkImpl->AddBatchNormalizationLayer(desc, mean, variance, beta, gamma, name);
298 return pNetworkImpl->AddResizeLayer(resizeDescriptor, name);
304 return pNetworkImpl->AddResizeLayer(resizeDescriptor, name);
310 return pNetworkImpl->AddReduceLayer(reduceDescriptor, name);
316 return pNetworkImpl->AddInstanceNormalizationLayer(desc, name);
322 return pNetworkImpl->AddL2NormalizationLayer(desc, name);
328 return pNetworkImpl->AddLogSoftmaxLayer(logSoftmaxDescriptor, name);
340 return pNetworkImpl->AddReshapeLayer(reshapeDescriptor, name);
346 return pNetworkImpl->AddSpaceToBatchNdLayer(spaceToBatchNdDescriptor, name);
352 return pNetworkImpl->AddSpaceToDepthLayer(spaceToDepthDescriptor, name);
368 return pNetworkImpl->AddLstmLayer(descriptor, params, name);
388 return pNetworkImpl->AddMeanLayer(meanDescriptor, name);
405 return pNetworkImpl->AddStridedSliceLayer(stridedSliceDescriptor, name);
431 return pNetworkImpl->AddGatherLayer(gatherDescriptor, name);
455 return pNetworkImpl->AddTransposeConvolution2dLayer(descriptor, weights, biases, name);
461 return pNetworkImpl->AddTransposeLayer(transposeDescriptor, name);
479 return pNetworkImpl->AddQuantizedLstmLayer(params, name);
486 return pNetworkImpl->AddQLstmLayer(descriptor, params, name);
492 return pNetworkImpl->AddLogicalBinaryLayer(descriptor, name);
507 return new INetwork(networkOptions);
560 return m_Graph->SerializeToDot(stream);
564 Optional<std::vector<std::string>&> errorMessages)
566 std::stringstream fullErrorMessage;
567 fullErrorMessage <<
"ERROR: " << errorMessage;
571 errorMessages.value().push_back(fullErrorMessage.str());
576 Optional<std::vector<std::string>&> warningMessages)
578 std::stringstream fullWarningMessage;
579 fullWarningMessage <<
"WARNING: " << warningMessage;
583 warningMessages.value().push_back(fullWarningMessage.str());
590 Optional<std::vector<std::string>&> errMessages)
592 std::stringstream failureMsg;
604 bool noErrors =
true;
606 for (
unsigned int i = 0; i < numOutputs; i++) {
612 std::stringstream ss;
614 <<
" (" << layer->
GetNameStr() <<
") is of type" 615 <<
" Quantized 8 bit but its scale parameter has not been set";
623 std::stringstream ss;
624 ss <<
"Quantization parameters for Softmax layer (Scale: " <<
626 ") are incorrect and have been updated to Scale: 0.00390625 and Offset: 0";
637 template <
typename LayerT>
640 LayerT* layer = PolymorphicDowncast<LayerT*>(l);
651 layer->m_Weight->template GetTensor<armnn::BFloat16>(), info.
GetNumElements(), newValues.data());
667 const std::vector<BackendId>& availablePreferredBackends,
668 std::string& reasonIfUnsupported,
669 Optional<std::vector<std::string>&> errMessages)
674 auto ReturnError = [&](
const Layer* layer)
691 std::vector<ConvertFp16ToFp32Layer*> convertFp16ToFp32Layers;
694 convertFp16ToFp32Layers =
699 std::vector<ConvertFp32ToFp16Layer*> convertFp32ToFp16Layers;
702 convertFp32ToFp16Layers =
707 auto AssignFirstSupportedBackend = [&](
Layer* layer,
BackendId preferredBackend)
709 bool supportedBackendFound =
false;
710 std::string reasonIfUnsupported;
716 reasonIfUnsupported))
718 supportedBackendFound =
true;
722 for (
const auto& backend : availablePreferredBackends)
725 if (backend == preferredBackend)
733 reasonIfUnsupported))
735 supportedBackendFound =
true;
741 return supportedBackendFound;
746 if (!AssignFirstSupportedBackend(convertLayer, backend))
748 return ReturnError(convertLayer);
754 if (!AssignFirstSupportedBackend(convertLayer, backend))
756 return ReturnError(convertLayer);
770 std::vector<ConvertBf16ToFp32Layer*> convertBf16ToFp32Layers;
773 convertBf16ToFp32Layers =
777 ConvertBf16ToFp32Weight<Convolution2dLayer>(layer);
781 ConvertBf16ToFp32Weight<FullyConnectedLayer>(layer);
786 std::vector<ConvertFp32ToBf16Layer*> convertFp32ToBf16Layers;
789 convertFp32ToBf16Layers =
794 auto AssignFirstSupportedBackend = [&](
Layer* layer,
BackendId preferredBackend)
796 bool supportedBackendFound =
false;
797 std::string reasonIfUnsupported;
803 reasonIfUnsupported))
805 supportedBackendFound =
true;
809 for (
const auto& backend : availablePreferredBackends)
812 if (backend == preferredBackend)
820 reasonIfUnsupported))
822 supportedBackendFound =
true;
828 return supportedBackendFound;
833 if (!AssignFirstSupportedBackend(convertLayer, backend))
835 return ReturnError(convertLayer);
841 if (!AssignFirstSupportedBackend(convertLayer, backend))
843 return ReturnError(convertLayer);
851 std::stringstream warningMsg;
853 <<
" is not supported on requested backend " << layer->
GetBackendId().
Get()
856 <<
" (reason: " << reasonIfUnsupported
857 <<
"), falling back to the next backend.";
873 Optional<std::vector<std::string>&> errMessages)
878 auto ReturnError = [&](
const Layer* layer)
885 if (availablePreferredBackends.empty())
887 std::stringstream failureMsg;
888 failureMsg <<
"No preferred backends are available";
895 for (
auto it = firstLayer; it != lastLayer; ++it)
900 layer->GetInputSlot(0).GetConnectedOutputSlot()->GetTensorInfo().GetDataType();
902 layer->GetOutputSlot(0).GetTensorInfo().GetDataType();
904 std::string reasonIfUnsupported;
914 if (layer->GetBackendHint().has_value() &&
919 layer->GetBackendHint().value(),
922 availablePreferredBackends,
932 for (
const auto& backend : availablePreferredBackends)
934 if (layer->GetBackendHint().has_value() &&
935 layer->GetBackendHint().value() == backend)
946 availablePreferredBackends,
982 layer->SetBackendId(cpuBackendId);
987 return ReturnError(layer);
998 Optional<std::vector<std::string>&> errMessages)
1016 auto backendFactory = backendRegistry.GetFactory(selectedBackend);
1017 auto backendObjPtr = backendFactory();
1020 backendObjPtr->RegisterTensorHandleFactories(handleFactoryRegistry);
1022 backends[backendObjPtr->GetId()] = std::move(backendObjPtr);
1032 Optional<std::vector<std::string>&> errMessages)
1044 auto backendObjPtr = backends.find(selectedBackend)->second.get();
1051 [&backendObjPtr](
const Layer& layer)
1057 if (subgraphs.empty())
1064 for (
auto& subgraph : subgraphs)
1067 OptimizationViews optimizationViews = backendObjPtr->OptimizeSubgraphView(*subgraph, modelOptions);
1074 SubgraphView& replacementSubgraph = substitution.m_ReplacementSubgraph;
1075 SubgraphView& substitutableSubgraph = substitution.m_SubstitutableSubgraph;
1079 std::for_each(replacementSubgraph.
begin(), replacementSubgraph.
end(), [&selectedBackend](
Layer* l)
1082 l->SetBackendId(selectedBackend);
1088 std::stringstream warningMsg;
1089 warningMsg <<
"Some sub-graph(s) failed to optimized on " << backendObjPtr->GetId() <<
" backend.";
1094 if (!backendObjPtr->GetId().IsCpuRef())
1097 settingsCopy.m_IgnoredBackends.insert(backendObjPtr->GetId());
1104 std::stringstream subgraphMsg;
1105 subgraphMsg <<
"Re-assigning backends to " << failedSubgraph.GetLayers().size()
1106 <<
" layers inside sub-graph " << count++;
1113 if (reassignmentResult.m_Error)
1136 if (srcFactory && dstFactory &&
1161 if (frmBackend == backends.end() ||
1162 !frmBackend->second->SupportsTensorAllocatorAPI())
1169 std::map<ITensorHandleFactory::FactoryId, int> factoryScores;
1175 const Layer& connectedLayer = connection->GetOwningLayer();
1177 auto toBackend = backends.find(connectedLayer.
GetBackendId());
1178 ARMNN_ASSERT_MSG(toBackend != backends.end(),
"Backend id not found for the connected layer");
1180 if (!toBackend->second.get()->SupportsTensorAllocatorAPI())
1186 auto dstPrefs = toBackend->second.get()->GetHandleFactoryPreferences();
1187 for (
auto&& dst : dstPrefs)
1200 auto it = factoryScores.find(dst);
1201 if (it == factoryScores.end())
1204 factoryScores[dst] = 0;
1213 factoryScores[dst]++;
1216 if (factoryScores[dst] > topScore)
1218 topScore = factoryScores[dst];
1246 if (frmBackend == backends.end() ||
1247 !frmBackend->second->SupportsTensorAllocatorAPI())
1253 bool requiresMapUnmap =
false;
1256 const Layer& connectedLayer = connection->GetOwningLayer();
1259 requiresMapUnmap =
true;
1267 std::map<ITensorHandleFactory::FactoryId, int> factoryScores;
1268 for (
auto&& pref : srcPrefs)
1270 if (requiresMapUnmap)
1280 auto it = factoryScores.find(pref);
1281 if (it == factoryScores.end())
1284 factoryScores[pref] = 0;
1291 const Layer& connectedLayer = connection->GetOwningLayer();
1293 auto toBackend = backends.find(connectedLayer.
GetBackendId());
1294 ARMNN_ASSERT_MSG(toBackend != backends.end(),
"Backend id not found for the connected layer");
1296 auto dstPrefs = toBackend->second.get()->GetHandleFactoryPreferences();
1297 for (
auto&& src : srcPrefs)
1299 if (factoryScores.find(src) == factoryScores.end())
1304 for (
auto&& dst : dstPrefs)
1309 factoryScores[src]++;
1317 int minScore = std::numeric_limits<int>::max();
1318 for (
auto it : factoryScores)
1320 minScore = std::min(minScore, it.second);
1324 std::vector<ITensorHandleFactory::FactoryId> optimalFactories;
1325 for (
auto it : factoryScores)
1327 if (it.second == minScore)
1329 optimalFactories.push_back(it.first);
1334 for (
auto&& srcPref : srcPrefs)
1336 for (
auto&& comp : optimalFactories)
1338 if (comp == srcPref)
1351 const Layer& connectedLayer,
1355 auto toBackend = backends.find(connectedLayer.
GetBackendId());
1356 ARMNN_ASSERT_MSG(toBackend != backends.end(),
"Backend id not found for the connected layer");
1358 auto dstPrefs = toBackend->second.get()->GetHandleFactoryPreferences();
1381 for (
auto&& pref : dstPrefs)
1383 if (pref == srcFactoryId)
1393 for (
auto&& pref : dstPrefs)
1409 if (srcCapability.empty() && dstCapability.empty())
1420 for (
auto&& pref : dstPrefs)
1438 Optional<std::vector<std::string>&> errMessages)
1442 optGraph.
ForEachLayer([&backends, ®istry, &result, &errMessages, importEnabled](
Layer* layer)
1473 unsigned int connectionIdx = 0;
1476 const Layer& connectedLayer = connection->GetOwningLayer();
1479 registry, importEnabled);
1486 errMessages.value().emplace_back(
"Could not find valid strategy required for compatibility" 1487 " between backends.");
1503 const std::vector<BackendId>& backendPreferences,
1506 Optional<std::vector<std::string>&> messages)
1508 if (backendPreferences.empty())
1518 std::unique_ptr<Graph> graph = std::make_unique<Graph>(inNetwork.
pNetworkImpl->GetGraph());
1529 using namespace optimizations;
1573 std::stringstream failureMsg;
1574 failureMsg <<
"None of the preferred backends " << backendPreferences
1592 if (assignBackendsResult.
m_Error)
1607 if (backendOptimizationResult.
m_Error)
1623 tensorHandleFactoryRegistry,
1643 auto backendPtr = factoryFun();
1647 auto backendSpecificOptimizations = backendPtr->GetOptimizations();
1650 if (!backendSpecificOptimizations.empty())
1658 bool NetworkImpl::GetShapeInferenceMethod()
1660 if (m_NetworkOptions.size() > 0 && m_NetworkOptions[0].GetBackendId().Get() ==
"ShapeInferenceMethod")
1662 return m_NetworkOptions[0].GetOption(0).GetValue().AsBool();
1668 : m_NetworkOptions(networkOptions),
1669 m_Graph(
std::make_unique<
Graph>(GetShapeInferenceMethod()))
1684 return m_Graph->AddLayer<
InputLayer>(id, name);
1696 return m_Graph->AddLayer<
ComparisonLayer>(comparisonDescriptor, name);
1708 return m_Graph->AddLayer<
FillLayer>(fillDescriptor, name);
1721 const auto layer = m_Graph->AddLayer<
FullyConnectedLayer>(fullyConnectedDescriptor, name);
1723 layer->
m_Weight = std::make_unique<ScopedCpuTensorHandle>(weights);
1725 if (fullyConnectedDescriptor.m_BiasEnabled)
1727 layer->m_Bias = std::make_unique<ScopedCpuTensorHandle>(biases.
value());
1738 return AddFullyConnectedLayerImpl(fullyConnectedDescriptor, weights, biases, name);
1746 return AddFullyConnectedLayerImpl(fullyConnectedDescriptor, weights, biases, name);
1755 return AddFullyConnectedLayerImpl(fullyConnectedDescriptor, weights, optionalBiases, name);
1761 return m_Graph->AddLayer<
ConcatLayer>(concatDescriptor, name);
1774 const auto layer = m_Graph->AddLayer<
Convolution2dLayer>(convolution2dDescriptor, name);
1776 layer->
m_Weight = std::make_unique<ScopedCpuTensorHandle>(weights);
1778 if (convolution2dDescriptor.m_BiasEnabled)
1780 layer->m_Bias = std::make_unique<ScopedCpuTensorHandle>(biases.
value());
1791 return AddConvolution2dLayerImpl(convolution2dDescriptor, weights, biases, name);
1799 return AddConvolution2dLayerImpl(convolution2dDescriptor, weights, biases, name);
1808 return AddConvolution2dLayerImpl(convolution2dDescriptor, weights, optionalBiases, name);
1824 layer->
m_Weight = std::make_unique<ScopedCpuTensorHandle>(weights);
1826 if (convolution2dDescriptor.m_BiasEnabled)
1828 layer->m_Bias = std::make_unique<ScopedCpuTensorHandle>(biases.
value());
1846 return AddDepthwiseConvolution2dLayerImpl(convolution2dDescriptor, weights, biases, name);
1855 return AddDepthwiseConvolution2dLayerImpl(convolution2dDescriptor, weights, biases, name);
1865 return AddDepthwiseConvolution2dLayerImpl(convolution2dDescriptor, weights, optionalBiases, name);
1881 return m_Graph->AddLayer<
PermuteLayer>(permuteDescriptor, name);
1887 return m_Graph->AddLayer<
Pooling2dLayer>(pooling2dDescriptor, name);
1893 return m_Graph->AddLayer<
ActivationLayer>(activationDescriptor, name);
1899 return m_Graph->AddLayer<
ArgMinMaxLayer>(argMinMaxDescriptor, name);
1903 normalizationDescriptor,
1911 return m_Graph->AddLayer<
SliceLayer>(sliceDescriptor, name);
1917 return m_Graph->AddLayer<
SoftmaxLayer>(softmaxDescriptor, name);
1923 return m_Graph->AddLayer<
SplitterLayer>(splitterDescriptor, name);
1971 layer->
m_Mean = std::make_unique<ScopedCpuTensorHandle>(mean);
1972 layer->m_Variance = std::make_unique<ScopedCpuTensorHandle>(variance);
1973 layer->m_Beta = std::make_unique<ScopedCpuTensorHandle>(beta);
1974 layer->m_Gamma = std::make_unique<ScopedCpuTensorHandle>(gamma);
1981 return m_Graph->AddLayer<
RankLayer>(name);
1987 return m_Graph->AddLayer<
ReduceLayer>(reduceDescriptor, name);
2001 return m_Graph->AddLayer<
ResizeLayer>(resizeDescriptor, name);
2006 return m_Graph->AddLayer<
ResizeLayer>(resizeDescriptor, name);
2031 layer->
m_LayerOutput = std::make_unique<ScopedCpuTensorHandle>(input);
2039 return m_Graph->AddLayer<
ReshapeLayer>(reshapeDescriptor, name);
2063 const auto layer = m_Graph->AddLayer<
LstmLayer>(descriptor, name);
2068 layer->m_BasicParameters.m_InputToCellWeights =
2070 layer->m_BasicParameters.m_InputToOutputWeights =
2072 layer->m_BasicParameters.m_RecurrentToForgetWeights =
2074 layer->m_BasicParameters.m_RecurrentToCellWeights =
2076 layer->m_BasicParameters.m_RecurrentToOutputWeights =
2078 layer->m_BasicParameters.m_ForgetGateBias =
2080 layer->m_BasicParameters.m_CellBias =
2081 std::make_unique<ScopedCpuTensorHandle>(*(params.
m_CellBias));
2082 layer->m_BasicParameters.m_OutputGateBias =
2086 if(!descriptor.m_CifgEnabled)
2091 "when CIFG is disabled.");
2096 "AddLstmLayer: Recurrent To Input Weights cannot be NULL " 2097 "when CIFG is disabled.");
2102 "when CIFG is disabled.");
2104 layer->m_CifgParameters.m_InputToInputWeights =
2106 layer->m_CifgParameters.m_RecurrentToInputWeights =
2108 layer->m_CifgParameters.m_InputGateBias =
2113 if(descriptor.m_ProjectionEnabled)
2118 "when projection is enabled.");
2120 layer->m_ProjectionParameters.m_ProjectionWeights =
2124 layer->m_ProjectionParameters.m_ProjectionBias =
2130 if(descriptor.m_PeepholeEnabled)
2132 if(!descriptor.m_CifgEnabled)
2137 "when Peephole is enabled and CIFG disabled.");
2140 layer->m_PeepholeParameters.m_CellToInputWeights =
2147 "when Peephole is enabled.");
2152 "when Peephole is enabled.");
2155 layer->m_PeepholeParameters.m_CellToForgetWeights =
2157 layer->m_PeepholeParameters.m_CellToOutputWeights =
2162 if(descriptor.m_LayerNormEnabled)
2164 if(!descriptor.m_CifgEnabled)
2169 "when layer normalization is enabled and CIFG disabled.");
2171 layer->m_LayerNormParameters.m_InputLayerNormWeights =
2178 "when layer normalization is enabled.");
2183 "when layer normalization is enabled.");
2188 "when layer normalization is enabled.");
2190 layer->m_LayerNormParameters.m_ForgetLayerNormWeights =
2192 layer->m_LayerNormParameters.m_CellLayerNormWeights =
2194 layer->m_LayerNormParameters.m_OutputLayerNormWeights =
2212 return m_Graph->AddLayer<
MeanLayer>(meanDescriptor,name);
2217 return m_Graph->AddLayer<
PadLayer>(padDescriptor,name);
2260 return m_Graph->AddLayer<
GatherLayer>(gatherDescriptor, name);
2290 layer->
m_Weight = std::make_unique<ScopedCpuTensorHandle>(weights);
2292 if (descriptor.m_BiasEnabled)
2294 layer->m_Bias = std::make_unique<ScopedCpuTensorHandle>(biases.
value());
2303 return m_Graph->AddLayer<
TransposeLayer>(transposeDescriptor, name);
2309 return m_Graph->AddLayer<
StackLayer>(stackDescriptor, name);
2327 layer->m_QuantizedLstmParameters.m_InputToForgetWeights =
2329 layer->m_QuantizedLstmParameters.m_InputToCellWeights =
2331 layer->m_QuantizedLstmParameters.m_InputToOutputWeights =
2335 layer->m_QuantizedLstmParameters.m_RecurrentToInputWeights =
2337 layer->m_QuantizedLstmParameters.m_RecurrentToForgetWeights =
2339 layer->m_QuantizedLstmParameters.m_RecurrentToCellWeights =
2341 layer->m_QuantizedLstmParameters.m_RecurrentToOutputWeights =
2345 layer->m_QuantizedLstmParameters.m_InputGateBias =
2347 layer->m_QuantizedLstmParameters.m_ForgetGateBias =
2349 layer->m_QuantizedLstmParameters.m_CellBias =
2350 std::make_unique<ScopedCpuTensorHandle>(params.
GetCellBias());
2351 layer->m_QuantizedLstmParameters.m_OutputGateBias =
2361 const auto layer = m_Graph->AddLayer<
QLstmLayer>(descriptor, name);
2366 layer->m_BasicParameters.m_InputToCellWeights =
2368 layer->m_BasicParameters.m_InputToOutputWeights =
2370 layer->m_BasicParameters.m_RecurrentToForgetWeights =
2372 layer->m_BasicParameters.m_RecurrentToCellWeights =
2374 layer->m_BasicParameters.m_RecurrentToOutputWeights =
2376 layer->m_BasicParameters.m_ForgetGateBias =
2378 layer->m_BasicParameters.m_CellBias =
2379 std::make_unique<ScopedCpuTensorHandle>(*(params.
m_CellBias));
2380 layer->m_BasicParameters.m_OutputGateBias =
2384 if(!descriptor.m_CifgEnabled)
2394 "AddQLstmLayer: Recurrent To Input Weights cannot be NULL");
2402 layer->m_CifgParameters.m_InputToInputWeights =
2404 layer->m_CifgParameters.m_RecurrentToInputWeights =
2406 layer->m_CifgParameters.m_InputGateBias =
2411 if(descriptor.m_ProjectionEnabled)
2418 layer->m_ProjectionParameters.m_ProjectionWeights =
2424 layer->m_ProjectionParameters.m_ProjectionBias =
2431 if(descriptor.m_PeepholeEnabled)
2443 if(!descriptor.m_CifgEnabled)
2450 layer->m_PeepholeParameters.m_CellToInputWeights =
2454 layer->m_PeepholeParameters.m_CellToForgetWeights =
2456 layer->m_PeepholeParameters.m_CellToOutputWeights =
2461 if(descriptor.m_LayerNormEnabled)
2478 if(!descriptor.m_CifgEnabled)
2485 layer->m_LayerNormParameters.m_InputLayerNormWeights =
2489 layer->m_LayerNormParameters.m_ForgetLayerNormWeights =
2491 layer->m_LayerNormParameters.m_CellLayerNormWeights =
2493 layer->m_LayerNormParameters.m_OutputLayerNormWeights =
2509 layer->Accept(visitor);
2517 layer->ExecuteStrategy(strategy);
2527 : m_Graph(
std::move(graph)), m_Guid(profiling::
ProfilingService::GetNextGuid()), m_ModelOptions(modelOptions)
A layer that the constant data can be bound to.
OptimizeForConnection< Layer, PermuteLayer, SquashEqualSiblingsImpl< PermuteLayer > > SquashEqualPermuteSiblings
void ReportError(const std::string &errorMessage, Optional< std::vector< std::string > &> errorMessages)
Iterator begin()
Returns iterator pointing to the beginning of the list. Lowercase for range-based for loops...
IConnectableLayer * AddSubtractionLayer(const char *name=nullptr)
Adds a subtraction layer to the network.
bool m_BiasEnabled
Enable/disable bias.
IConnectableLayer * AddReduceLayer(const ReduceDescriptor &reduceDescriptor, const char *name=nullptr)
ModelOptions m_ModelOptions
IConnectableLayer * AddRsqrtLayer(const char *name=nullptr)
IConnectableLayer * AddActivationLayer(const ActivationDescriptor &activationDescriptor, const char *name=nullptr)
Adds an activation layer to the network.
bool m_HalfPixelCenters
Half Pixel Centers.
bool m_AlignCorners
Aligned corners.
This layer represents a minimum operation.
static const FactoryId DeferredFactoryId
Use the workload factory to create the tensor handle.
This layer represents a split operation.
OptimizationResult AssignBackends(OptimizedNetworkImpl *optNetObjPtr, BackendSettings &backendSettings, Graph::Iterator &firstLayer, Graph::Iterator &lastLayer, Optional< std::vector< std::string > &> errMessages)
LstmBasicParameters m_BasicParameters
const std::vector< InputSlot * > & GetConnections() const
FactoryFunction GetFactory(const BackendId &id) const
This layer represents a batch normalization operation.
static void Destroy(INetwork *network)
A ViewsDescriptor for the SplitterLayer.
Interface for a layer that is connectable to other layers via InputSlots and OutputSlots.
OptimizeForConnection< PermuteLayer, PermuteLayer, OptimizeInversePermutesImpl< PermuteLayer > > OptimizeInversePermutes
virtual bool SupportsMapUnmap() const final
std::vector< ConvertFp32ToFp16Layer * > InsertConvertFp32ToFp16LayersAfter(Graph &graph, Layer &layer)
bool m_BiasEnabled
Enable/disable bias.
void ExecuteStrategy(IStrategy &strategy) const
void SetEdgeStrategy(unsigned int connectionIndex, EdgeStrategy strategy)
QuantizedLstmParameters m_QuantizedLstmParameters
This layer represents a 2D transpose convolution operation.
virtual Status PrintGraph()
No strategy has been defined. Used internally to verify integrity of optimizations.
std::vector< ConvertFp16ToFp32Layer * > InsertConvertFp16ToFp32LayersBefore(Graph &graph, Layer &layer, bool expectCorrectInputType)
IConnectableLayer * AddResizeLayer(const ResizeDescriptor &resizeDescriptor, const char *name=nullptr)
virtual ~OptimizedNetworkImpl()
A TransposeConvolution2dDescriptor for the TransposeConvolution2dLayer.
const TensorShape & GetShape() const
CPU Execution: Reference C++ kernels.
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.
IConnectableLayer * AddQuantizeLayer(const char *name=nullptr)
IConnectableLayer * AddFullyConnectedLayer(const FullyConnectedDescriptor &fullyConnectedDescriptor, const ConstTensor &weights, const Optional< ConstTensor > &biases, const char *name=nullptr)
Optimizer::Optimizations MakeOptimizations(Args &&... args)
std::unique_ptr< ScopedCpuTensorHandle > m_Weight
A unique pointer to store Weight values.
IConnectableLayer * AddQLstmLayer(const QLstmDescriptor &descriptor, const LstmInputParams ¶ms, const char *name=nullptr)
Add a QLstm layer to the network.
IConnectableLayer * AddRankLayer(const char *name=nullptr)
A ReshapeDescriptor for the ReshapeLayer.
ITensorHandleFactory::FactoryId CalculateSlotOption(BackendsMap &backends, OutputSlot &outputSlot, TensorHandleFactoryRegistry ®istry)
OptimizeForConnection< TransposeLayer, TransposeLayer, OptimizeInversePermutesImpl< TransposeLayer > > OptimizeInverseTransposes
IConnectableLayer * AddAdditionLayer(const char *name=nullptr)
OptimizeForConnection< TransposeLayer, BatchToSpaceNdLayer, PermuteAndBatchToSpaceAsDepthToSpaceImpl< TransposeLayer > > TransposeAndBatchToSpaceAsDepthToSpace
OptimizeForExclusiveConnection< DepthwiseConvolution2dLayer, BatchNormalizationLayer, FuseBatchNorm< DepthwiseConvolution2dLayer, armnn::DataType::Float32 > > FuseBatchNormIntoDepthwiseConvolution2DFloat32
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...
#define ARMNN_NO_DEPRECATE_WARN_BEGIN
IConnectableLayer * AddDepthwiseConvolution2dLayer(const DepthwiseConvolution2dDescriptor &convolution2dDescriptor, const ConstTensor &weights, const Optional< ConstTensor > &biases, const char *name=nullptr)
Adds a 2D depthwise convolution layer to the network.
ITensorHandleFactory::FactoryId CalculateSlotOptionForOutput(BackendsMap &backends, OutputSlot &slot, TensorHandleFactoryRegistry ®istry)
A ComparisonDescriptor for the ComparisonLayer.
IConnectableLayer * AddAbsLayer(const char *name=nullptr)
This layer represents a depthwise convolution 2d operation.
static void ConvertBFloat16ToFloat32(const void *srcBFloat16Buffer, size_t numElements, float *dstFloat32Buffer)
bool RequiresCopy(ITensorHandleFactory::FactoryId src, ITensorHandleFactory::FactoryId dst, TensorHandleFactoryRegistry ®istry)
IConnectableLayer * AddPooling2dLayer(const Pooling2dDescriptor &pooling2dDescriptor, const char *name=nullptr)
NetworkImpl(NetworkOptions networkOptions={})
IConnectableLayer * AddStackLayer(const StackDescriptor &descriptor, const char *name=nullptr)
Adds a stack layer to the network.
uint32_t m_TargetWidth
Target width value.
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
std::vector< BackendOptions > ModelOptions
void Accept(ILayerVisitor &visitor) const
IConnectableLayer * AddMergeLayer(const char *name=nullptr)
IConnectableLayer * AddRsqrtLayer(const char *name=nullptr)
Add Reciprocal of square root layer to the network.
A Convolution2dDescriptor for the Convolution2dLayer.
Layer & GetOwningLayer() const
Source backends tensor data can be exported to destination backend tensor without copy...
IConnectableLayer * AddQuantizeLayer(const char *name=nullptr)
Add a quantize layer to the network.
This layer converts data type Float 16 to Float 32.
IConnectableLayer * AddMinimumLayer(const char *name=nullptr)
Add a Minimum layer to the network.
IConnectableLayer * AddQuantizedLstmLayer(const QuantizedLstmInputParams ¶ms, const char *name=nullptr)
IConnectableLayer * AddL2NormalizationLayer(const L2NormalizationDescriptor &desc, const char *name=nullptr)
Adds an L2 normalization layer to the network.
bool m_BiasEnabled
Enable/disable bias.
IConnectableLayer * AddConstantLayer(const ConstTensor &input, const char *name=nullptr)
IConnectableLayer * AddElementwiseUnaryLayer(const ElementwiseUnaryDescriptor &elementwiseUnaryDescriptor, const char *name=nullptr)
IConnectableLayer * AddMergeLayer(const char *name=nullptr)
Adds a merge layer to the network.
IConnectableLayer * AddPermuteLayer(const PermuteDescriptor &permuteDescriptor, const char *name=nullptr)
Adds a permute layer to the network.
ResizeMethod m_Method
The Interpolation method to use (Bilinear, NearestNeighbor).
IConnectableLayer * AddNormalizationLayer(const NormalizationDescriptor &normalizationDescriptor, const char *name=nullptr)
IConnectableLayer * AddSliceLayer(const SliceDescriptor &sliceDescriptor, const char *name=nullptr)
Adds a slice layer to the network.
static void Pass(Graph &graph, const Optimizations &optimizations)
OptimizeForExclusiveConnection< DepthwiseConvolution2dLayer, BatchNormalizationLayer, FuseBatchNorm< DepthwiseConvolution2dLayer, armnn::DataType::Float16 > > FuseBatchNormIntoDepthwiseConvolution2DFloat16
IConnectableLayer * AddFloorLayer(const char *name=nullptr)
Adds a floor layer to the network.
IConnectableLayer * AddPooling2dLayer(const Pooling2dDescriptor &pooling2dDescriptor, const char *name=nullptr)
Adds a pooling layer to the network.
This layer represents a SpaceToDepth operation.
IConnectableLayer * AddMeanLayer(const MeanDescriptor &meanDescriptor, const char *name=nullptr)
This layer represents a reshape operation.
void ExecuteStrategy(IStrategy &strategy) const
std::unique_ptr< ScopedCpuTensorHandle > m_InputToInputWeights
A unique pointer to represent 2D weights tensor with dimensions [outputSize, inputSize] (QAsymm8)...
OptimizeForExclusiveConnection< Convolution2dLayer, BatchNormalizationLayer, FuseBatchNorm< Convolution2dLayer, armnn::DataType::Float16 > > FuseBatchNormIntoConvolution2DFloat16
OptimizeForExclusiveConnection< Convolution2dLayer, BatchNormalizationLayer, FuseBatchNorm< Convolution2dLayer, armnn::DataType::Float32 > > FuseBatchNormIntoConvolution2DFloat32
#define ARMNN_LOG(severity)
std::unique_ptr< ScopedCpuTensorHandle > m_InputToForgetWeights
A unique pointer to represent 2D weights tensor with dimensions [num_units, inputSize] (QSymmS8)...
IConnectableLayer * AddMinimumLayer(const char *name=nullptr)
IConnectableLayer * AddFillLayer(const FillDescriptor &fillDescriptor, const char *name=nullptr)
Add an Fill layer to the network.
Main network class which provides the interface for building up a neural network. ...
This layer represents an activation operation with the specified activation function.
IConnectableLayer * AddSpaceToDepthLayer(const SpaceToDepthDescriptor &spaceToDepthDescriptor, const char *name=nullptr)
BackendRegistry & BackendRegistryInstance()
This layer converts data type BFloat16 to Float32.
LayerT * ConvertBf16ToFp32Weight(Layer *l)
std::vector< BackendOptions > NetworkOptions
A LogicalBinaryDescriptor for the LogicalBinaryLayer.
IConnectableLayer * AddConvolution2dLayer(const Convolution2dDescriptor &convolution2dDescriptor, const ConstTensor &weights, const Optional< ConstTensor > &biases, const char *name=nullptr)
Adds a 2D convolution layer to the network.
This layer represents an unknown operation in the input graph.
OptimizeForConnection< Layer, ReshapeLayer, SquashEqualSiblingsImpl< ReshapeLayer > > SquashEqualReshapeSiblings
IConnectableLayer * AddLogSoftmaxLayer(const LogSoftmaxDescriptor &logSoftmaxDescriptor, const char *name=nullptr)
Adds a log softmax layer to the network.
IConnectableLayer * AddResizeLayer(const ResizeDescriptor &resizeDescriptor, const char *name=nullptr)
Adds a resize layer to the network.
IConnectableLayer * AddActivationLayer(const ActivationDescriptor &activationDescriptor, const char *name=nullptr)
This layer represents a detection postprocess operator.
BackendIdSet m_SupportedBackends
OptimizeForConnection< Layer, TransposeLayer, MoveTransposeUpImpl > MoveTransposeUp
IConnectableLayer * AddBatchToSpaceNdLayer(const BatchToSpaceNdDescriptor &batchToSpaceNdDescriptor, const char *name=nullptr)
Adds a batch to space ND layer to the network.
OptimizationResult ReturnWithError(OptimizationResult res, const Layer *layer, const BackendSettings &backendSettings, Optional< std::vector< std::string > &> errMessages)
std::unique_ptr< ScopedCpuTensorHandle > m_Weight
A unique pointer to store weight values.
Copyright (c) 2021 ARM Limited and Contributors.
This layer represents a pad operation.
This layer represents a LSTM operation.
void IgnoreUnused(Ts &&...)
OptimizeForConnection< PadLayer, Convolution2dLayer, FoldPadIntoConvolution2dImpl > FoldPadIntoConvolution2d
IConnectableLayer * AddDivisionLayer(const char *name=nullptr)
Adds a division layer to the network.
void SetBackendId(const BackendId &id)
bool IsBackendSupported(const BackendId &backend) const
LayerList::const_iterator Iterator
This layer represents a reduction operation.
IConnectableLayer * AddDepthwiseConvolution2dLayer(const DepthwiseConvolution2dDescriptor &convolution2dDescriptor, const ConstTensor &weights, const Optional< ConstTensor > &biases, const char *name=nullptr)
IConnectableLayer * AddLogSoftmaxLayer(const LogSoftmaxDescriptor &logSoftmaxDescriptor, const char *name=nullptr)
A SpaceToDepthDescriptor for the SpaceToDepthLayer.
This layer represents a permutation operation.
unsigned int GetNumOutputSlots() const override
Returns the number of connectable output slots.
This layer represents a SpaceToBatchNd operation.
IConnectableLayer * AddFullyConnectedLayer(const FullyConnectedDescriptor &fullyConnectedDescriptor, const ConstTensor &weights, const Optional< ConstTensor > &biases, const char *name=nullptr)
Adds a fully connected layer to the network.
A BatchToSpaceNdDescriptor for the BatchToSpaceNdLayer.
OptimizeForType< Layer, AddDebugImpl > InsertDebugLayer
virtual Status SerializeToDot(std::ostream &stream) const
OptimizeForConnection< ReshapeLayer, ReshapeLayer, OptimizeConsecutiveReshapesImpl > OptimizeConsecutiveReshapes
IConnectableLayer * AddMeanLayer(const MeanDescriptor &meanDescriptor, const char *name=nullptr)
Add a Mean layer to the network.
Private implementation of INetwork.
int LayerBindingId
Type of identifiers for bindable layers (inputs, outputs).
IConnectableLayer * AddInputLayer(LayerBindingId id, const char *name=nullptr)
Adds an input layer to the network.
This layer represents a elementwiseUnary operation.
constexpr const char * GetDataTypeName(DataType dataType)
IConnectableLayer * AddStridedSliceLayer(const StridedSliceDescriptor &stridedSliceDescriptor, const char *name=nullptr)
Adds a strided slice layer to the network.
A ResizeDescriptor for the ResizeLayer.
A StackDescriptor for the StackLayer.
Destination backend can work directly with tensors on source backend.
virtual std::vector< ITensorHandleFactory::FactoryId > GetHandleFactoryPreferences() const
(Optional) Returns a vector of supported TensorHandleFactory ids in preference order.
IConnectableLayer * AddSpaceToDepthLayer(const SpaceToDepthDescriptor &spaceToDepthDescriptor, const char *name=nullptr)
Adds a space to depth layer to the network.
OptimizeForConnection< ConvertFp16ToFp32Layer, ConvertFp32ToFp16Layer, OptimizeInverseConversionsImpl > OptimizeInverseConversionsFp16
IConnectableLayer * AddSoftmaxLayer(const SoftmaxDescriptor &softmaxDescriptor, const char *name=nullptr)
Adds a softmax layer to the network.
The SubgraphView class represents a subgraph of a Graph.
IConnectableLayer * AddMergerLayer(const MergerDescriptor &mergerDescriptor, const char *name=nullptr)
profiling::ProfilingGuid GetGuid() const
IConnectableLayer * AddFloorLayer(const char *name=nullptr)
A PadDescriptor for the PadLayer.
This layer represents an instance normalization operation.
IConnectableLayer * AddMultiplicationLayer(const char *name=nullptr)
OptimizeForConnection< PermuteLayer, BatchToSpaceNdLayer, PermuteAndBatchToSpaceAsDepthToSpaceImpl< PermuteLayer > > PermuteAndBatchToSpaceAsDepthToSpace
IConnectableLayer * AddQLstmLayer(const QLstmDescriptor &descriptor, const LstmInputParams ¶ms, const char *name=nullptr)
OptimizeForConnection< Layer, PermuteLayer, MovePermuteUpImpl > MovePermuteUp
This layer represents a Logical Binary operation.
std::unique_ptr< ScopedCpuTensorHandle > m_LayerOutput
IConnectableLayer * AddStridedSliceLayer(const StridedSliceDescriptor &stridedSliceDescriptor, const char *name=nullptr)
std::unique_ptr< NetworkImpl > pNetworkImpl
A layer user-provided data can be bound to (e.g. inputs, outputs).
IOptimizedNetwork(std::unique_ptr< Graph > graph)
IConnectableLayer * AddResizeBilinearLayer(const ResizeBilinearDescriptor &resizeDesc, const char *name=nullptr)
Adds a resize bilinear layer to the network.
friend IOptimizedNetworkPtr Optimize(const INetwork &inNetwork, const std::vector< BackendId > &backendPreferences, const IDeviceSpec &deviceSpec, const OptimizerOptions &options, Optional< std::vector< std::string > &> messages)
Create an optimized version of the network.
void ForEachLayer(Func func) const
virtual std::vector< Capability > GetCapabilities(const IConnectableLayer *layer, const IConnectableLayer *connectedLayer, CapabilityClass capabilityClass)
IConnectableLayer * AddInputLayer(LayerBindingId id, const char *name=nullptr)
This layer dequantizes the input tensor.
ConvertConstants< Float32ToFloat16, IsFloat16Layer > ConvertConstantsFloatToHalf
OptimizeForType< TransposeLayer, TransposeAsReshapeImpl > TransposeAsReshape
This layer represents a Gather operator.
std::unique_ptr< ScopedCpuTensorHandle > m_Anchors
A unique pointer to store Anchor values.
This layer represents a fully connected operation.
An LstmDescriptor for the LstmLayer.
#define ARMNN_NO_DEPRECATE_WARN_END
IConnectableLayer * AddLstmLayer(const LstmDescriptor &descriptor, const LstmInputParams ¶ms, const char *name=nullptr)
Add a Lstm layer to the network.
IConnectableLayer * AddTransposeConvolution2dLayer(const TransposeConvolution2dDescriptor &descriptor, const ConstTensor &weights, const Optional< ConstTensor > &biases, const char *name=nullptr)
#define ARMNN_ASSERT_MSG(COND, MSG)
IConnectableLayer * AddRankLayer(const char *name=nullptr)
Adds a rank layer to the network.
This layer represents a QuantizedLstm operation.
This layer represents a log softmax operation.
OptimizationResult ApplyBackendOptimizations(OptimizedNetworkImpl *optNetObjPtr, BackendSettings &backendSettings, BackendsMap &backends, const ModelOptions &modelOptions, Optional< std::vector< std::string > &> errMessages)
std::unique_ptr< ScopedCpuTensorHandle > m_Mean
A unique pointer to store Mean values.
IConnectableLayer * AddPreluLayer(const char *name=nullptr)
A L2NormalizationDescriptor for the L2NormalizationLayer.
int32_t GetQuantizationOffset() const
An ArgMinMaxDescriptor for ArgMinMaxLayer.
float GetQuantizationScale() const
DataType GetDataType() const
An OriginsDescriptor for the ConcatLayer.
A ReduceDescriptor for the REDUCE operators.
IConnectableLayer * AddDetectionPostProcessLayer(const DetectionPostProcessDescriptor &descriptor, const ConstTensor &anchors, const char *name=nullptr)
bool has_value() const noexcept
A FullyConnectedDescriptor for the FullyConnectedLayer.
std::unique_ptr< ScopedCpuTensorHandle > m_Weight
A unique pointer to store Weight values.
bool m_BiasEnabled
Enable/disable bias.
This layer represents a stack operation.
A tensor defined by a TensorInfo (shape and data type) and an immutable backing store.
const Subgraphs & GetFailedSubgraphs() const
This layer represents a merge operation.
This layer represents a softmax operation.
IConnectableLayer * AddInstanceNormalizationLayer(const InstanceNormalizationDescriptor &desc, const char *name=nullptr)
Adds an instance normalization layer to the network.
const std::string & GetNameStr() const
LayerType GetType() const override
Returns the armnn::LayerType of this layer.
uint32_t m_TargetWidth
Target width value.
std::vector< ConvertBf16ToFp32Layer * > InsertConvertBf16ToFp32LayersBefore(Graph &graph, Layer &layer, bool expectCorrectInputType)
A GatherDescriptor for the GatherLayer.
std::unique_ptr< OptimizedNetworkImpl > pOptimizedNetworkImpl
IConnectableLayer * AddDivisionLayer(const char *name=nullptr)
This layer represents a BatchToSpaceNd operation.
IConnectableLayer * AddOutputLayer(LayerBindingId id, const char *name=nullptr)
Adds an output layer to the network.
std::vector< SubgraphViewPtr > Subgraphs
std::unique_ptr< IOptimizedNetwork, void(*)(IOptimizedNetwork *network)> IOptimizedNetworkPtr
bool m_HalfPixelCenters
Half Pixel Centers.
IConnectableLayer * AddArgMinMaxLayer(const ArgMinMaxDescriptor &desc, const char *name=nullptr)
IConnectableLayer * AddOutputLayer(LayerBindingId id, const char *name=nullptr)
IConnectableLayer * AddDequantizeLayer(const char *name=nullptr)
void SetQuantizationScale(float scale)
This layer represents a ArgMinMax operation.
IConnectableLayer * AddConcatLayer(const ConcatDescriptor &concatDescriptor, const char *name=nullptr)
#define ARMNN_ASSERT(COND)
A StandInDescriptor for the StandIn layer.
A QLstmDescriptor for the QLstmLayer.
BackendIdVector GetAvailablePreferredBackends() const
Device specific knowledge to be passed to the optimizer.
IConnectableLayer * AddSwitchLayer(const char *name=nullptr)
static bool IsLayerSupported(const BackendId &backendId, const IConnectableLayer &layer, Optional< DataType > dataType, std::string &outReasonIfUnsupported)
IConnectableLayer * AddEqualLayer(const char *name=nullptr)
Add a Equal layer to the network.
IConnectableLayer * AddAbsLayer(const char *name=nullptr)
Add absolute layer to the network.
IConnectableLayer * AddSubtractionLayer(const char *name=nullptr)
IConnectableLayer * AddResizeBilinearLayer(const ResizeBilinearDescriptor &resizeDesc, const char *name=nullptr)
bool Validate(const SubgraphView &originalSubgraph) const
An ActivationDescriptor for the ActivationLayer.
IConnectableLayer * AddLogicalBinaryLayer(const LogicalBinaryDescriptor &logicalBinaryDescriptor, const char *name=nullptr)
std::vector< ConvertFp32ToBf16Layer * > InsertConvertFp32ToBf16LayersAfter(Graph &graph, Layer &layer)
const BackendId & GetBackendId() const
uint32_t m_TargetHeight
Target height value.
This layer represents a floor operation.
void Accept(ILayerVisitor &visitor) const
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.
INetwork(NetworkOptions networkOptions={})
uint32_t m_TargetHeight
Target height value.
A SliceDescriptor for the SliceLayer.
IConnectableLayer * AddSpaceToBatchNdLayer(const SpaceToBatchNdDescriptor &spaceToBatchNdDescriptor, const char *name=nullptr)
Adds a space to batch layer to the network.
This layer represents a normalization operation.
virtual MemorySourceFlags GetExportFlags() const
IConnectableLayer * AddStandInLayer(const StandInDescriptor &descriptor, const char *name=nullptr)
This layer represents a pooling 2d operation.
This layer converts data type Float 32 to Float 16.
This layer represents a transpose operation.
IConnectableLayer * AddPermuteLayer(const PermuteDescriptor &permuteDescriptor, const char *name=nullptr)
This layer represents an addition operation.
IConnectableLayer * AddComparisonLayer(const ComparisonDescriptor &comparisonDescriptor, const char *name=nullptr)
Add a Comparison layer to the network.
QLstmBasicParameters m_BasicParameters
void SubstituteSubgraph(SubgraphView &subgraph, IConnectableLayer *substituteLayer)
Substitutes the given sub-graph with either a new layer or a new sub-graph.
IConnectableLayer * AddL2NormalizationLayer(const L2NormalizationDescriptor &desc, const char *name=nullptr)
IConnectableLayer * AddArgMinMaxLayer(const ArgMinMaxDescriptor &desc, const char *name=nullptr)
Adds an ArgMinMax layer to the network.
bool CheckScaleSetOnQuantizedType(Layer *layer, Optional< std::vector< std::string > &> errMessages)
IConnectableLayer * AddSplitterLayer(const ViewsDescriptor &splitterDescriptor, const char *name=nullptr)
Adds a splitter layer to the network.
void SetTensorHandleFactory(const ITensorHandleFactory::FactoryId &id)
A SpaceToBatchNdDescriptor for the SpaceToBatchNdLayer.
OptimizeForType< PermuteLayer, PermuteAsReshapeImpl > PermuteAsReshape
bool IsWarningOnly() const
OptimizeForConnection< Layer, TransposeLayer, SquashEqualSiblingsImpl< TransposeLayer > > SquashEqualTransposeSiblings
This layer represents a QLstm operation.
IConnectableLayer * AddAdditionLayer(const char *name=nullptr)
Adds an addition layer to the network.
const Substitutions & GetSubstitutions() const
BackendIdVector m_PreferredBackends
This layer represents a subtraction operation.
IConnectableLayer * AddTransposeLayer(const TransposeDescriptor &transposeDescriptor, const char *name=nullptr)
This layer calculates both true and false outputs for input.
IConnectableLayer * AddReshapeLayer(const ReshapeDescriptor &reshapeDescriptor, const char *name=nullptr)
Adds a reshape layer to the network.
EmptyOptional is used to initialize the Optional class in case we want to have default value for an O...
IConnectableLayer * AddPadLayer(const PadDescriptor &padDescriptor, const char *name=nullptr)
Adds a fully pad layer to the network.
ConvertConstants< Float16ToFloat32, IsFloat32Layer > ConvertConstantsHalfToFloat
bool m_AlignCorners
Aligned corners.
A ElementwiseUnaryDescriptor for the ElementwiseUnaryLayer.
static Subgraphs SelectSubgraphs(Graph &graph, const LayerSelectorFunction &selector)
Selects subgraphs from a graph based on the selector function and the algorithm.
IConnectableLayer * AddReshapeLayer(const ReshapeDescriptor &reshapeDescriptor, const char *name=nullptr)
This layer represents a L2 normalization operation.
IConnectableLayer * AddMaximumLayer(const char *name=nullptr)
BackendsMap CreateSupportedBackends(TensorHandleFactoryRegistry &handleFactoryRegistry, BackendSettings &backendSettings)
OptimizeForConnection< ConvertFp32ToFp16Layer, ConvertFp16ToFp32Layer, OptimizeInverseConversionsImpl > OptimizeInverseConversionsFp32
ITensorHandleFactory::FactoryId CalculateSlotOptionForInput(BackendsMap &backends, OutputSlot &slot, TensorHandleFactoryRegistry ®istry)
IConnectableLayer * AddStackLayer(const StackDescriptor &stackDescriptor, const char *name=nullptr)
IConnectableLayer * AddSoftmaxLayer(const SoftmaxDescriptor &softmaxDescriptor, const char *name=nullptr)
const std::string & Get() const
IConnectableLayer * AddGreaterLayer(const char *name=nullptr)
IConnectableLayer * AddNormalizationLayer(const NormalizationDescriptor &normalizationDescriptor, const char *name=nullptr)
Adds a normalization layer to the network.
BackendIdSet m_SelectedBackends
IConnectableLayer * AddEqualLayer(const char *name=nullptr)
IConnectableLayer * AddFillLayer(const FillDescriptor &fillDescriptor, const char *name=nullptr)
Iterator end()
Returns iterator pointing to the end of the list. Lowercase for range-based for loops.
const Graph & GetGraph() 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)
ITensorHandleFactory * GetFactory(ITensorHandleFactory::FactoryId id) const
Find a TensorHandleFactory by Id Returns nullptr if not found.
void SetTensorInfo(const TensorInfo &tensorInfo) override
OptimizedNetworkImpl(std::unique_ptr< Graph > graph)
A MeanDescriptor for the MeanLayer.
This layer represents a division operation.
Status SerializeToDot(std::ostream &stream) const
IConnectableLayer * AddSpaceToBatchNdLayer(const SpaceToBatchNdDescriptor &spaceToBatchNdDescriptor, const char *name=nullptr)
IConnectableLayer * AddQuantizedLstmLayer(const QuantizedLstmInputParams ¶ms, const char *name=nullptr)
Add a QuantizedLstm layer to the network.
This layer represents a strided slice operation.
This layer represents a maximum operation.
const OutputSlot & GetOutputSlot(unsigned int index=0) const override
Get the const output slot handle by slot index.
OptimizeForType< Layer, ConvertFp32NetworkToFp16Impl > Fp32NetworkToFp16Converter
A TransposeDescriptor for the TransposeLayer.
A StridedSliceDescriptor for the StridedSliceLayer.
IConnectableLayer * AddComparisonLayer(const ComparisonDescriptor &comparisonDescriptor, const char *name=nullptr)
OptimizationResult SelectTensorHandleStrategy(Graph &optGraph, BackendsMap &backends, TensorHandleFactoryRegistry ®istry, bool importEnabled, Optional< std::vector< std::string > &> errMessages)
void ReportWarning(const std::string &warningMessage, Optional< std::vector< std::string > &> warningMessages)
This layer represents a convolution 2d operation.
This layer converts data type Float32 to BFloat16.
bool CheckFlag(MemorySourceFlags flags, MemorySource source)
void SetQuantizationOffset(int32_t offset)
IConnectableLayer * AddSwitchLayer(const char *name=nullptr)
Adds a switch layer to the network.
IConnectableLayer * AddDetectionPostProcessLayer(const DetectionPostProcessDescriptor &descriptor, const ConstTensor &anchors, const char *name=nullptr)
Adds a Detection PostProcess layer to the network.
static INetwork * CreateRaw(NetworkOptions networkOptions={})
IConnectableLayer * AddMergerLayer(const MergerDescriptor &mergerDescriptor, const char *name=nullptr)
Adds a concat layer to the network.
IConnectableLayer * AddMultiplicationLayer(const char *name=nullptr)
Adds a multiplication layer to the network.
IConnectableLayer * AddStandInLayer(const StandInDescriptor &descriptor, const char *name=nullptr)
Add a stand-in layer for a type unknown to the Arm NN framework.
This layer represents a mean operation.
This layer represents a comparison operation.
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
IConnectableLayer * AddBatchNormalizationLayer(const BatchNormalizationDescriptor &desc, const ConstTensor &mean, const ConstTensor &variance, const ConstTensor &beta, const ConstTensor &gamma, const char *name=nullptr)
IConnectableLayer * AddReduceLayer(const ReduceDescriptor &reduceDescriptor, const char *name=nullptr)
Adds a reduce layer to the network.
IConnectableLayer * AddElementwiseUnaryLayer(const ElementwiseUnaryDescriptor &elementwiseUnaryDescriptor, const char *name=nullptr)
Add an ElementwiseUnary layer to the network.
OptimizeForType< Layer, AddBroadcastReshapeLayerImpl > AddBroadcastReshapeLayer
IConnectableLayer * AddGatherLayer(const char *name=nullptr)
IConnectableLayer * AddDequantizeLayer(const char *name=nullptr)
Adds a Dequantize layer to the network.
std::unique_ptr< ScopedCpuTensorHandle > m_Weight
A unique pointer to store Weight values.
A Pooling2dDescriptor for the Pooling2dLayer.
This layer dequantizes the input tensor.
A NormalizationDescriptor for the NormalizationLayer.
IConnectableLayer * AddPreluLayer(const char *name=nullptr)
Adds a PReLU layer to the network.
IConnectableLayer * AddGreaterLayer(const char *name=nullptr)
Add a Greater layer to the network.
IConnectableLayer * AddDepthToSpaceLayer(const DepthToSpaceDescriptor &depthToSpaceDescriptor, const char *name=nullptr)
IConnectableLayer * AddMaximumLayer(const char *name=nullptr)
Add a Maximum layer to the network.
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
An InstanceNormalizationDescriptor for InstanceNormalizationLayer.
This layer represents a multiplication operation.
IConnectableLayer * AddConvolution2dLayer(const Convolution2dDescriptor &convolution2dDescriptor, const ConstTensor &weights, const Optional< ConstTensor > &biases, const char *name=nullptr)
IConnectableLayer * AddSplitterLayer(const ViewsDescriptor &splitterDescriptor, const char *name=nullptr)
IConnectableLayer * AddBatchToSpaceNdLayer(const BatchToSpaceNdDescriptor &batchToSpaceNdDescriptor, const char *name=nullptr)
A ResizeBilinearDescriptor for the ResizeBilinearLayer.
IConnectableLayer * AddLstmLayer(const LstmDescriptor &descriptor, const LstmInputParams ¶ms, const char *name=nullptr)
IConnectableLayer * AddPadLayer(const PadDescriptor &padDescriptor, const char *name=nullptr)
const TensorInfo & GetTensorInfo() const override
static INetworkPtr Create(NetworkOptions networkOptions={})
IConnectableLayer * AddLogicalBinaryLayer(const LogicalBinaryDescriptor &descriptor, const char *name=nullptr)
Adds a Logical Binary layer to the network.
IConnectableLayer * AddGatherLayer(const char *name=nullptr)
Add Gather layer to the network.
EdgeStrategy CalculateEdgeStrategy(BackendsMap &backends, ITensorHandleFactory::FactoryId srcFactoryId, const Layer &layer, const Layer &connectedLayer, TensorHandleFactoryRegistry ®istry, bool importEnabled)
static void Destroy(IOptimizedNetwork *network)
IConnectableLayer * AddConcatLayer(const ConcatDescriptor &concatDescriptor, const char *name=nullptr)
Adds a concatenation layer to the network.
virtual MemorySourceFlags GetImportFlags() const
std::unique_ptr< ScopedCpuTensorHandle > m_InputToForgetWeights
A unique pointer to represent 2D weights tensor with dimensions [input_size, num_units].
OptimizeForType< Layer, ConvertFp32NetworkToBf16Impl > Fp32NetworkToBf16Converter
A SoftmaxDescriptor for the SoftmaxLayer.
const char * GetLayerTypeAsCString(LayerType type)
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...
bool IsCpuRefUsed() const
static const FactoryId LegacyFactoryId
This layer represents a fill operation.
A DepthwiseConvolution2dDescriptor for the DepthwiseConvolution2dLayer.
A FillDescriptor for the FillLayer.
This layer represents a DepthToSpace operation.
A BatchNormalizationDescriptor for the BatchNormalizationLayer.
IConnectableLayer * AddTransposeLayer(const TransposeDescriptor &transposeDescriptor, const char *name=nullptr)
Adds a transpose layer to the network.
unsigned int GetNumElements() const
std::map< BackendId, std::unique_ptr< class IBackendInternal > > BackendsMap
This layer represents a resize operation.
A PermuteDescriptor for the PermuteLayer.
IConnectableLayer * AddSliceLayer(const SliceDescriptor &sliceDescriptor, const char *name=nullptr)
IConnectableLayer * AddDepthToSpaceLayer(const DepthToSpaceDescriptor &depthToSpaceDescriptor, const char *name=nullptr)
Adds a depth to space layer to the network.
LayerType
When adding a new layer, adapt also the LastLayer enum value in the enum class LayerType below...
IConnectableLayer * AddInstanceNormalizationLayer(const InstanceNormalizationDescriptor &desc, const char *name=nullptr)
std::vector< float > anchors({ 0.5f, 0.5f, 1.0f, 1.0f, 0.5f, 0.5f, 1.0f, 1.0f, 0.5f, 0.5f, 1.0f, 1.0f, 0.5f, 10.5f, 1.0f, 1.0f, 0.5f, 10.5f, 1.0f, 1.0f, 0.5f, 100.5f, 1.0f, 1.0f })