35 #include <boost/assert.hpp> 36 #include <boost/format.hpp> 37 #include <boost/numeric/conversion/converter_policies.hpp> 38 #include <boost/cast.hpp> 55 delete boost::polymorphic_downcast<Network*>(network);
60 delete boost::polymorphic_downcast<OptimizedNetwork*>(network);
71 return m_Graph->SerializeToDot(stream);
75 Optional<std::vector<std::string>&> errorMessages)
77 std::stringstream fullErrorMessage;
78 fullErrorMessage <<
"ERROR: " << errorMessage;
82 errorMessages.value().push_back(fullErrorMessage.str());
87 Optional<std::vector<std::string>&> warningMessages)
89 std::stringstream fullWarningMessage;
90 fullWarningMessage <<
"WARNING: " << warningMessage;
94 warningMessages.value().push_back(fullWarningMessage.str());
100 bool noErrors =
true;
102 for (
unsigned int i = 0; i < numOutputs; i++) {
108 std::stringstream ss;
110 <<
" (" << layer->
GetNameStr() <<
") is of type" 111 <<
" Quantized 8 bit but its scale parameter has not been set";
119 std::stringstream ss;
120 ss <<
"Quantization parameters for Softmax layer (Scale: " <<
122 ") are incorrect and have been updated to Scale: 0.00390625 and Offset: 0";
137 Optional<std::vector<std::string>&> errMessages)
142 auto ReturnWithError = [&](
const Layer* layer)
144 std::stringstream failureMsg;
154 if (availablePreferredBackends.empty())
156 std::stringstream failureMsg;
157 failureMsg <<
"No preferred backends are available";
164 for (
auto it = firstLayer; it != lastLayer; ++it)
169 layer->GetInputSlot(0).GetConnectedOutputSlot()->GetTensorInfo().GetDataType();
171 layer->GetOutputSlot(0).GetTensorInfo().GetDataType();
173 std::string reasonIfUnsupported;
182 for (
const auto& backend : availablePreferredBackends)
186 layer->SetBackendId(backend);
196 std::vector<ConvertFp16ToFp32Layer*> convertFp16ToFp32Layers;
199 convertFp16ToFp32Layers =
204 std::vector<ConvertFp32ToFp16Layer*> convertFp32ToFp16Layers;
207 convertFp32ToFp16Layers =
212 auto AssignFirstSupportedBackend = [&](
Layer* layer,
BackendId preferredBackend)
214 bool supportedBackendFound =
false;
215 std::string reasonIfUnsupported;
221 reasonIfUnsupported))
223 supportedBackendFound =
true;
227 for (
const auto& backend : availablePreferredBackends)
230 if (backend == preferredBackend)
238 reasonIfUnsupported))
240 supportedBackendFound =
true;
246 return supportedBackendFound;
251 if (!AssignFirstSupportedBackend(convertLayer, backend))
253 return ReturnWithError(convertLayer);
259 if (!AssignFirstSupportedBackend(convertLayer, backend))
261 return ReturnWithError(convertLayer);
269 std::stringstream warningMsg;
271 <<
" is not supported on requested backend " << layer->GetBackendId().Get()
274 <<
" (reason: " << reasonIfUnsupported
275 <<
"), falling back to the next backend.";
299 layer->SetBackendId(cpuBackendId);
304 return ReturnWithError(layer);
315 Optional<std::vector<std::string>&> errMessages)
333 auto backendFactory = backendRegistry.GetFactory(selectedBackend);
334 auto backendObjPtr = backendFactory();
335 BOOST_ASSERT(backendObjPtr);
337 backendObjPtr->RegisterTensorHandleFactories(handleFactoryRegistry);
339 backends[backendObjPtr->GetId()] = std::move(backendObjPtr);
348 Optional<std::vector<std::string>&> errMessages)
350 BOOST_ASSERT(optNetObjPtr);
360 auto backendObjPtr = backends.find(selectedBackend)->second.get();
361 BOOST_ASSERT(backendObjPtr);
367 [&backendObjPtr](
const Layer& layer)
373 if (subgraphs.empty())
380 for (
auto& subgraph : subgraphs)
383 OptimizationViews optimizationViews = backendObjPtr->OptimizeSubgraphView(*subgraph);
384 BOOST_ASSERT(optimizationViews.
Validate(*subgraph));
390 SubgraphView& replacementSubgraph = substitution.m_ReplacementSubgraph;
391 SubgraphView& substitutableSubgraph = substitution.m_SubstitutableSubgraph;
395 std::for_each(replacementSubgraph.
begin(), replacementSubgraph.
end(), [&selectedBackend](
Layer* l)
398 l->SetBackendId(selectedBackend);
404 std::stringstream warningMsg;
405 warningMsg <<
"Some sub-graph(s) failed to optimized on " << backendObjPtr->GetId() <<
" backend.";
410 if (!backendObjPtr->GetId().IsCpuRef())
413 settingsCopy.m_IgnoredBackends.insert(backendObjPtr->GetId());
420 std::stringstream subgraphMsg;
421 subgraphMsg <<
"Re-assigning backends to " << failedSubgraph.GetLayers().size()
422 <<
" layers inside sub-graph " << count++;
429 if (reassignmentResult.m_Error)
452 if (srcFactory && dstFactory &&
477 if (frmBackend == backends.end() ||
478 !frmBackend->second->SupportsTensorAllocatorAPI())
485 std::map<ITensorHandleFactory::FactoryId, int> factoryScores;
491 const Layer& connectedLayer = connection->GetOwningLayer();
493 auto toBackend = backends.find(connectedLayer.
GetBackendId());
494 BOOST_ASSERT_MSG(toBackend != backends.end(),
"Backend id not found for the connected layer");
496 if (!toBackend->second.get()->SupportsTensorAllocatorAPI())
502 auto dstPrefs = toBackend->second.get()->GetHandleFactoryPreferences();
503 for (
auto&& dst : dstPrefs)
516 auto it = factoryScores.find(dst);
517 if (it == factoryScores.end())
520 factoryScores[dst] = 0;
529 factoryScores[dst]++;
532 if (factoryScores[dst] > topScore)
534 topScore = factoryScores[dst];
549 boost::ignore_unused(backends, slot, registry);
562 if (frmBackend == backends.end() ||
563 !frmBackend->second->SupportsTensorAllocatorAPI())
569 bool requiresMapUnmap =
false;
572 const Layer& connectedLayer = connection->GetOwningLayer();
575 requiresMapUnmap =
true;
583 std::map<ITensorHandleFactory::FactoryId, int> factoryScores;
584 for (
auto&& pref : srcPrefs)
586 if (requiresMapUnmap)
596 auto it = factoryScores.find(pref);
597 if (it == factoryScores.end())
600 factoryScores[pref] = 0;
607 const Layer& connectedLayer = connection->GetOwningLayer();
609 auto toBackend = backends.find(connectedLayer.
GetBackendId());
610 BOOST_ASSERT_MSG(toBackend != backends.end(),
"Backend id not found for the connected layer");
612 auto dstPrefs = toBackend->second.get()->GetHandleFactoryPreferences();
613 for (
auto&& src : srcPrefs)
615 if (factoryScores.find(src) == factoryScores.end())
620 for (
auto&& dst : dstPrefs)
625 factoryScores[src]++;
633 int minScore = std::numeric_limits<int>::max();
634 for (
auto it : factoryScores)
636 minScore = std::min(minScore, it.second);
640 std::vector<ITensorHandleFactory::FactoryId> optimalFactories;
641 for (
auto it : factoryScores)
643 if (it.second == minScore)
645 optimalFactories.push_back(it.first);
650 for (
auto&& srcPref : srcPrefs)
652 for (
auto&& comp : optimalFactories)
667 const Layer& connectedLayer,
670 auto toBackend = backends.find(connectedLayer.
GetBackendId());
671 BOOST_ASSERT_MSG(toBackend != backends.end(),
"Backend id not found for the connected layer");
673 auto dstPrefs = toBackend->second.get()->GetHandleFactoryPreferences();
696 for (
auto&& pref : dstPrefs)
698 if (pref == srcFactoryId)
708 for (
auto&& pref : dstPrefs)
727 for (
auto&& pref : dstPrefs)
744 Optional<std::vector<std::string>&> errMessages)
748 optGraph.
ForEachLayer([&backends, ®istry, &result, &errMessages](
Layer* layer)
754 BOOST_ASSERT(backends.find(layer->
GetBackendId()) != backends.end());
779 unsigned int connectionIdx = 0;
782 const Layer& connectedLayer = connection->GetOwningLayer();
791 errMessages.value().emplace_back(
"Could not find valid strategy required for compatibility" 792 " between backends.");
808 const std::vector<BackendId>& backendPreferences,
811 Optional<std::vector<std::string>&> messages)
813 if (backendPreferences.empty())
818 const Network& network = *boost::polymorphic_downcast<const Network*>(&inNetwork);
819 std::unique_ptr<Graph> graph = std::make_unique<Graph>(network.
GetGraph());
823 OptimizedNetwork* optNetObjPtr = boost::polymorphic_downcast<OptimizedNetwork*>(optNet.get());
829 using namespace optimizations;
840 optGraph.InferTensorInfos();
853 std::stringstream failureMsg;
854 failureMsg <<
"None of the preferred backends " << backendPreferences
872 if (assignBackendsResult.
m_Error)
886 if (backendOptimizationResult.
m_Error)
902 tensorHandleFactoryRegistry,
911 optGraph.AddCompatibilityLayers(backends, tensorHandleFactoryRegistry);
921 auto backendPtr = factoryFun();
922 BOOST_ASSERT(backendPtr.get() !=
nullptr);
925 auto backendSpecificOptimizations = backendPtr->GetOptimizations();
928 if (!backendSpecificOptimizations.empty())
938 : m_Graph(
std::make_unique<
Graph>()),
955 return m_Graph->AddLayer<
InputLayer>(id, name);
988 layer->
m_Weight = std::make_unique<ScopedCpuTensorHandle>(weights);
990 if (fullyConnectedDescriptor.m_BiasEnabled)
992 layer->m_Bias = std::make_unique<ScopedCpuTensorHandle>(biases.
value());
1003 return AddFullyConnectedLayerImpl(fullyConnectedDescriptor, weights, biases, name);
1011 return AddFullyConnectedLayerImpl(fullyConnectedDescriptor, weights, biases, name);
1020 return AddFullyConnectedLayerImpl(fullyConnectedDescriptor, weights, optionalBiases, name);
1026 return m_Graph->AddLayer<
ConcatLayer>(concatDescriptor, name);
1039 const auto layer = m_Graph->AddLayer<
Convolution2dLayer>(convolution2dDescriptor, name);
1041 layer->
m_Weight = std::make_unique<ScopedCpuTensorHandle>(weights);
1043 if (convolution2dDescriptor.m_BiasEnabled)
1045 layer->m_Bias = std::make_unique<ScopedCpuTensorHandle>(biases.
value());
1056 return AddConvolution2dLayerImpl(convolution2dDescriptor, weights, biases, name);
1064 return AddConvolution2dLayerImpl(convolution2dDescriptor, weights, biases, name);
1073 return AddConvolution2dLayerImpl(convolution2dDescriptor, weights, optionalBiases, name);
1089 layer->
m_Weight = std::make_unique<ScopedCpuTensorHandle>(weights);
1091 if (convolution2dDescriptor.m_BiasEnabled)
1093 layer->m_Bias = std::make_unique<ScopedCpuTensorHandle>(biases.
value());
1111 return AddDepthwiseConvolution2dLayerImpl(convolution2dDescriptor, weights, biases, name);
1120 return AddDepthwiseConvolution2dLayerImpl(convolution2dDescriptor, weights, biases, name);
1130 return AddDepthwiseConvolution2dLayerImpl(convolution2dDescriptor, weights, optionalBiases, name);
1146 return m_Graph->AddLayer<
PermuteLayer>(permuteDescriptor, name);
1152 return m_Graph->AddLayer<
Pooling2dLayer>(pooling2dDescriptor, name);
1158 return m_Graph->AddLayer<
ActivationLayer>(activationDescriptor, name);
1164 return m_Graph->AddLayer<
ArgMinMaxLayer>(argMinMaxDescriptor, name);
1168 normalizationDescriptor,
1176 return m_Graph->AddLayer<
SliceLayer>(sliceDescriptor, name);
1182 return m_Graph->AddLayer<
SoftmaxLayer>(softmaxDescriptor, name);
1188 return m_Graph->AddLayer<
SplitterLayer>(splitterDescriptor, name);
1236 layer->
m_Mean = std::make_unique<ScopedCpuTensorHandle>(mean);
1237 layer->m_Variance = std::make_unique<ScopedCpuTensorHandle>(variance);
1238 layer->m_Beta = std::make_unique<ScopedCpuTensorHandle>(beta);
1239 layer->m_Gamma = std::make_unique<ScopedCpuTensorHandle>(gamma);
1253 return m_Graph->AddLayer<
ResizeLayer>(resizeDescriptor, name);
1257 resizeDescriptor,
const char* name)
1259 return m_Graph->AddLayer<
ResizeLayer>(resizeDescriptor, name);
1284 layer->
m_LayerOutput = std::make_unique<ScopedCpuTensorHandle>(input);
1292 return m_Graph->AddLayer<
ReshapeLayer>(reshapeDescriptor, name);
1316 const auto layer = m_Graph->AddLayer<
LstmLayer>(descriptor, name);
1321 layer->m_BasicParameters.m_InputToCellWeights =
1323 layer->m_BasicParameters.m_InputToOutputWeights =
1325 layer->m_BasicParameters.m_RecurrentToForgetWeights =
1327 layer->m_BasicParameters.m_RecurrentToCellWeights =
1329 layer->m_BasicParameters.m_RecurrentToOutputWeights =
1331 layer->m_BasicParameters.m_ForgetGateBias =
1333 layer->m_BasicParameters.m_CellBias =
1334 std::make_unique<ScopedCpuTensorHandle>(*(params.
m_CellBias));
1335 layer->m_BasicParameters.m_OutputGateBias =
1339 if(!descriptor.m_CifgEnabled)
1348 "AddLstmLayer: Recurrent To Input Weights cannot be NULL");
1354 layer->m_CifgParameters.m_InputToInputWeights =
1356 layer->m_CifgParameters.m_RecurrentToInputWeights =
1361 layer->m_CifgParameters.m_CellToInputWeights =
1364 layer->m_CifgParameters.m_InputGateBias =
1369 if(descriptor.m_ProjectionEnabled)
1375 layer->m_ProjectionParameters.m_ProjectionWeights =
1379 layer->m_ProjectionParameters.m_ProjectionBias =
1385 if(descriptor.m_PeepholeEnabled)
1395 layer->m_PeepholeParameters.m_CellToForgetWeights =
1397 layer->m_PeepholeParameters.m_CellToOutputWeights =
1402 if(descriptor.m_LayerNormEnabled)
1404 if(!descriptor.m_CifgEnabled)
1410 layer->m_LayerNormParameters.m_InputLayerNormWeights =
1426 layer->m_LayerNormParameters.m_ForgetLayerNormWeights =
1428 layer->m_LayerNormParameters.m_CellLayerNormWeights =
1430 layer->m_LayerNormParameters.m_OutputLayerNormWeights =
1448 return m_Graph->AddLayer<
MeanLayer>(meanDescriptor,name);
1453 return m_Graph->AddLayer<
PadLayer>(padDescriptor,name);
1519 layer->
m_Weight = std::make_unique<ScopedCpuTensorHandle>(weights);
1521 if (descriptor.m_BiasEnabled)
1523 layer->m_Bias = std::make_unique<ScopedCpuTensorHandle>(biases.
value());
1532 return m_Graph->AddLayer<
StackLayer>(stackDescriptor, name);
1550 layer->m_QuantizedLstmParameters.m_InputToForgetWeights =
1552 layer->m_QuantizedLstmParameters.m_InputToCellWeights =
1554 layer->m_QuantizedLstmParameters.m_InputToOutputWeights =
1558 layer->m_QuantizedLstmParameters.m_RecurrentToInputWeights =
1560 layer->m_QuantizedLstmParameters.m_RecurrentToForgetWeights =
1562 layer->m_QuantizedLstmParameters.m_RecurrentToCellWeights =
1564 layer->m_QuantizedLstmParameters.m_RecurrentToOutputWeights =
1568 layer->m_QuantizedLstmParameters.m_InputGateBias =
1570 layer->m_QuantizedLstmParameters.m_ForgetGateBias =
1572 layer->m_QuantizedLstmParameters.m_CellBias =
1573 std::make_unique<ScopedCpuTensorHandle>(params.
GetCellBias());
1574 layer->m_QuantizedLstmParameters.m_OutputGateBias =
1584 layer->Accept(visitor);
1589 : m_Graph(
std::move(graph)),
This layer represents a subtraction operation.
BackendIdSet m_SupportedBackends
IConnectableLayer * AddReshapeLayer(const ReshapeDescriptor &reshapeDescriptor, const char *name=nullptr) override
OptimizeForConnection< Layer, ReshapeLayer, SquashEqualSiblingsImpl< ReshapeLayer > > SquashEqualReshapeSiblings
EdgeStrategy CalculateEdgeStrategy(BackendsMap &backends, ITensorHandleFactory::FactoryId srcFactoryId, const Layer &layer, const Layer &connectedLayer, TensorHandleFactoryRegistry ®istry)
bool IsCpuRefUsed() const
This layer represents a pad operation.
std::unique_ptr< ScopedCpuTensorHandle > m_Weight
A unique pointer to store Weight values.
This layer dequantizes the input tensor.
std::unique_ptr< ScopedCpuTensorHandle > m_Anchors
A unique pointer to store Anchor values.
unsigned int GetNumOutputSlots() const override
This layer represents a DepthToSpace operation.
This layer represents a BatchToSpaceNd operation.
This layer represents a 2D transpose convolution operation.
FactoryFunction GetFactory(const BackendId &id) const
LayerType GetType() const
int32_t GetQuantizationOffset() const
A BatchToSpaceNdDescriptor for the BatchToSpaceNdLayer.
IConnectableLayer * AddSplitterLayer(const ViewsDescriptor &splitterDescriptor, const char *name=nullptr) override
A NormalizationDescriptor for the NormalizationLayer.
A tensor defined by a TensorInfo (shape and data type) and an immutable backing store.
IConnectableLayer * AddMaximumLayer(const char *name=nullptr) override
IConnectableLayer * AddInputLayer(LayerBindingId id, const char *name=nullptr) override
char const * GetLayerTypeAsCString(LayerType type)
BackendsMap CreateSupportedBackends(TensorHandleFactoryRegistry &handleFactoryRegistry, BackendSettings &backendSettings)
This layer represents a batch normalization operation.
const Subgraphs & GetFailedSubgraphs() const
IOptimizedNetworkPtr Optimize(const INetwork &network, const std::vector< BackendId > &backendPreferences, const IDeviceSpec &deviceSpec, const OptimizerOptions &options=OptimizerOptions(), Optional< std::vector< std::string > &> messages=EmptyOptional())
IConnectableLayer * AddL2NormalizationLayer(const L2NormalizationDescriptor &desc, const char *name=nullptr) override
virtual bool SupportsMapUnmap() const final
void SetEdgeStrategy(unsigned int connectionIndex, EdgeStrategy strategy)
BackendIdSet m_SelectedBackends
ConvertConstants< Float32ToFloat16, IsFloat16Layer > ConvertConstantsFloatToHalf
IConnectableLayer * AddMergeLayer(const char *name=nullptr) override
This layer represents a detection postprocess operator.
OptimizeForConnection< PermuteLayer, BatchToSpaceNdLayer, PermuteAndBatchToSpaceAsDepthToSpaceImpl > PermuteAndBatchToSpaceAsDepthToSpace
uint32_t m_TargetHeight
Target height value.
No strategy has been defined. Used internally to verify integrity of optimizations.
This layer represents a maximum operation.
void Accept(ILayerVisitor &visitor) const override
This layer represents a minimum operation.
This layer represents a depthwise convolution 2d operation.
This layer represents a convolution 2d operation.
IConnectableLayer * AddGatherLayer(const char *name=nullptr) override
std::unique_ptr< ScopedCpuTensorHandle > m_Weight
A unique pointer to store Weight values.
This layer represents a softmax operation.
This layer represents a stack operation.
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
This layer converts data type Float 32 to Float 16.
A PadDescriptor for the PadLayer.
An ActivationDescriptor for the ActivationLayer.
IConnectableLayer * AddGreaterLayer(const char *name=nullptr) override
A BatchNormalizationDescriptor for the BatchNormalizationLayer.
static void Destroy(INetwork *network)
ITensorHandleFactory::FactoryId CalculateSlotOption(BackendsMap &backends, OutputSlot &outputSlot, TensorHandleFactoryRegistry ®istry)
OptimizeForConnection< ConvertFp32ToFp16Layer, ConvertFp16ToFp32Layer, OptimizeInverseConversionsImpl > OptimizeInverseConversionsFp32
OptimizeForConnection< ReshapeLayer, ReshapeLayer, OptimizeConsecutiveReshapesImpl > OptimizeConsecutiveReshapes
This layer represents a log softmax operation.
Source backends tensor data can be exported to destination backend tensor without copy...
This layer represents a SpaceToDepth operation.
This layer represents a reshape operation.
static Subgraphs SelectSubgraphs(Graph &graph, const LayerSelectorFunction &selector)
static void Pass(Graph &graph, const Optimizations &optimizations)
uint32_t m_TargetWidth
Target width value.
This layer represents a ArgMinMax operation.
IConnectableLayer * AddAdditionLayer(const char *name=nullptr) override
const BackendId & GetBackendId() const
This layer represents a pooling 2d operation.
This layer represents a floor operation.
const std::string & GetNameStr() const
This layer represents a merge operation.
IConnectableLayer * AddEqualLayer(const char *name=nullptr) override
This layer represents a multiplication operation.
A L2NormalizationDescriptor for the L2NormalizationLayer.
static void Destroy(IOptimizedNetwork *network)
static const FactoryId LegacyFactoryId
bool m_BiasEnabled
Enable/disable bias.
A ViewsDescriptor for the SplitterLayer. Descriptor to configure the splitting process. Number of Views must be equal to the number of outputs, and their order must match - e.g. first view corresponds to the first output, second view to the second output, etc.
IConnectableLayer * AddElementwiseUnaryLayer(const ElementwiseUnaryDescriptor &elementwiseUnaryDescriptor, const char *name=nullptr) override
IConnectableLayer * AddDequantizeLayer(const char *name=nullptr) override
This layer represents a SpaceToBatchNd operation.
std::unique_ptr< ScopedCpuTensorHandle > m_Weight
A unique pointer to store Weight values.
OptimizeForType< Layer, ConvertFp32NetworkToFp16Impl > Fp32NetworkToFp16Converter
OptimizeForConnection< PadLayer, Convolution2dLayer, FoldPadIntoConvolution2dImpl > FoldPadIntoConvolution2d
IConnectableLayer * AddPooling2dLayer(const Pooling2dDescriptor &pooling2dDescriptor, const char *name=nullptr) override
IConnectableLayer * AddStandInLayer(const StandInDescriptor &descriptor, const char *name=nullptr) override
IConnectableLayer * AddLogSoftmaxLayer(const LogSoftmaxDescriptor &logSoftmaxDescriptor, const char *name=nullptr) override
IConnectableLayer * AddDivisionLayer(const char *name=nullptr) override
std::vector< ConvertFp32ToFp16Layer * > InsertConvertFp32ToFp16LayersAfter(Graph &graph, Layer &layer)
A SpaceToDepthDescriptor for the SpaceToDepthLayer.
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
#define ARMNN_LOG(severity)
This layer represents a fully connected operation.
OptimizationResult SelectTensorHandleStrategy(Graph &optGraph, BackendsMap &backends, TensorHandleFactoryRegistry ®istry, Optional< std::vector< std::string > &> errMessages)
A ReshapeDescriptor for the ReshapeLayer.
A TransposeConvolution2dDescriptor for the TransposeConvolution2dLayer.
IConnectableLayer * AddResizeLayer(const ResizeDescriptor &resizeDescriptor, const char *name=nullptr) override
std::vector< SubgraphViewPtr > Subgraphs
ITensorHandleFactory * GetFactory(ITensorHandleFactory::FactoryId id) const
bool CheckFlag(MemorySourceFlags flags, MemorySource source)
A ElementwiseUnaryDescriptor for the ElementwiseUnaryLayer.
IConnectableLayer * AddActivationLayer(const ActivationDescriptor &activationDescriptor, const char *name=nullptr) override
IConnectableLayer * AddLstmLayer(const LstmDescriptor &descriptor, const LstmInputParams ¶ms, const char *name=nullptr) override
OptimizeForConnection< Layer, PermuteLayer, MovePermuteUpImpl > MovePermuteUp
void SetBackendId(const BackendId &id)
IConnectableLayer * AddMultiplicationLayer(const char *name=nullptr) override
This layer represents an activation operation with the specified activation function.
void ReportWarning(const std::string &warningMessage, Optional< std::vector< std::string > &> warningMessages)
IConnectableLayer * AddMinimumLayer(const char *name=nullptr) override
IConnectableLayer * AddMergerLayer(const MergerDescriptor &mergerDescriptor, const char *name=nullptr) override
static const FactoryId DeferredFactoryId
ConvertConstants< Float16ToFloat32, IsFloat32Layer > ConvertConstantsHalfToFloat
#define ARMNN_NO_DEPRECATE_WARN_BEGIN
This layer represents a split operation.
Private implementation of INetwork.
std::unique_ptr< ScopedCpuTensorHandle > m_InputToInputWeights
A unique pointer to represent 2D weights tensor with dimensions [outputSize, inputSize] (QAsymm8)...
BackendRegistry & BackendRegistryInstance()
std::map< BackendId, std::unique_ptr< class IBackendInternal > > BackendsMap
virtual MemorySourceFlags GetExportFlags() const
OptimizeForConnection< Layer, PermuteLayer, SquashEqualSiblingsImpl< PermuteLayer > > SquashEqualPermuteSiblings
IConnectableLayer * AddSpaceToBatchNdLayer(const SpaceToBatchNdDescriptor &spaceToBatchNdDescriptor, const char *name=nullptr) override
std::unique_ptr< ScopedCpuTensorHandle > m_InputToForgetWeights
A unique pointer to represent 2D weights tensor with dimensions [input_size, num_units].
ITensorHandleFactory::FactoryId CalculateSlotOptionForOutput(BackendsMap &backends, OutputSlot &slot, TensorHandleFactoryRegistry ®istry)
LstmBasicParameters m_BasicParameters
IConnectableLayer * AddPreluLayer(const char *name=nullptr) override
const Substitutions & GetSubstitutions() const
IConnectableLayer * AddComparisonLayer(const ComparisonDescriptor &comparisonDescriptor, const char *name=nullptr) override
bool RequiresCopy(ITensorHandleFactory::FactoryId src, ITensorHandleFactory::FactoryId dst, TensorHandleFactoryRegistry ®istry)
void SetTensorInfo(const TensorInfo &tensorInfo) override
An LstmDescriptor for the LstmLayer.
OptimizedNetwork(std::unique_ptr< Graph > graph)
This layer represents a division operation.
IConnectableLayer * AddResizeBilinearLayer(const ResizeBilinearDescriptor &resizeDesc, const char *name=nullptr) override
IConnectableLayer * AddSliceLayer(const SliceDescriptor &sliceDescriptor, const char *name=nullptr) override
This layer represents a permutation operation.
IConnectableLayer * AddPermuteLayer(const PermuteDescriptor &permuteDescriptor, const char *name=nullptr) override
OptimizeForConnection< ConvertFp16ToFp32Layer, ConvertFp32ToFp16Layer, OptimizeInverseConversionsImpl > OptimizeInverseConversionsFp16
void SetQuantizationScale(float scale)
void ReportError(const std::string &errorMessage, Optional< std::vector< std::string > &> errorMessages)
IConnectableLayer * AddRsqrtLayer(const char *name=nullptr) override
static INetworkPtr Create()
An InstanceNormalizationDescriptor for InstanceNormalizationLayer.
IConnectableLayer * AddMeanLayer(const MeanDescriptor &meanDescriptor, const char *name=nullptr) override
const std::vector< InputSlot * > & GetConnections() const
Destination backend can work directly with tensors on source backend.
void ForEachLayer(Func func) const
Status PrintGraph() override
A FullyConnectedDescriptor for the FullyConnectedLayer.
A layer user-provided data can be bound to (e.g. inputs, outputs).
IConnectableLayer * AddSoftmaxLayer(const SoftmaxDescriptor &softmaxDescriptor, const char *name=nullptr) override
std::unique_ptr< ScopedCpuTensorHandle > m_LayerOutput
IConnectableLayer * AddQuantizedLstmLayer(const QuantizedLstmInputParams ¶ms, const char *name=nullptr) override
This layer represents a normalization operation.
ITensorHandleFactory::FactoryId CalculateSlotOptionForInput(BackendsMap &backends, OutputSlot &slot, TensorHandleFactoryRegistry ®istry)
IConnectableLayer * AddConvolution2dLayer(const Convolution2dDescriptor &convolution2dDescriptor, const ConstTensor &weights, const Optional< ConstTensor > &biases, const char *name=nullptr) override
This layer represents a Gather operator.
void SubstituteSubgraph(SubgraphView &subgraph, IConnectableLayer *substituteLayer)
IConnectableLayer * AddTransposeConvolution2dLayer(const TransposeConvolution2dDescriptor &descriptor, const ConstTensor &weights, const Optional< ConstTensor > &biases, const char *name=nullptr) override
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
A layer that the constant data can be bound to.
bool CheckScaleSetOnQuantizedType(Layer *layer, Optional< std::vector< std::string > &> errMessages)
CPU Execution: Reference C++ kernels.
bool m_BiasEnabled
Enable/disable bias.
bool Validate(const SubgraphView &originalSubgraph) const
const Graph & GetGraph() const
IConnectableLayer * AddStackLayer(const StackDescriptor &stackDescriptor, const char *name=nullptr) override
IConnectableLayer * AddAbsLayer(const char *name=nullptr) override
QuantizedLstmParameters m_QuantizedLstmParameters
Optimizer::Optimizations MakeOptimizations(Args &&... args)
This layer represents a LSTM operation.
A StackDescriptor for the StackLayer.
OptimizationResult AssignBackends(OptimizedNetwork *optNetObjPtr, BackendSettings &backendSettings, Graph::Iterator &firstLayer, Graph::Iterator &lastLayer, Optional< std::vector< std::string > &> errMessages)
A ResizeBilinearDescriptor for the ResizeBilinearLayer.
A SoftmaxDescriptor for the SoftmaxLayer.
IConnectableLayer * AddQuantizeLayer(const char *name=nullptr) override
uint32_t m_TargetWidth
Target width value.
LayerList::const_iterator Iterator
This layer represents a mean operation.
Status PrintGraph() override
OptimizationResult ApplyBackendOptimizations(OptimizedNetwork *optNetObjPtr, BackendSettings &backendSettings, BackendsMap &backends, Optional< std::vector< std::string > &> errMessages)
bool m_BiasEnabled
Enable/disable bias.
IConnectableLayer * AddPadLayer(const PadDescriptor &padDescriptor, const char *name=nullptr) override
IConnectableLayer * AddSwitchLayer(const char *name=nullptr) override
IConnectableLayer * AddDepthToSpaceLayer(const DepthToSpaceDescriptor &depthToSpaceDescriptor, const char *name=nullptr) override
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 })
This layer represents a elementwiseUnary operation.
static INetwork * CreateRaw()
This layer represents an addition operation.
IConnectableLayer * AddDepthwiseConvolution2dLayer(const DepthwiseConvolution2dDescriptor &convolution2dDescriptor, const ConstTensor &weights, const Optional< ConstTensor > &biases, const char *name=nullptr) override
Interface for a layer that is connectable to other layers via InputSlots and OutputSlots.
static bool IsLayerSupported(const BackendId &backendId, const IConnectableLayer &layer, Optional< DataType > dataType, std::string &outReasonIfUnsupported)
This layer represents a comparison operation.
std::unique_ptr< ScopedCpuTensorHandle > m_Mean
A unique pointer to store Mean values.
DataType GetDataType() const
virtual std::vector< ITensorHandleFactory::FactoryId > GetHandleFactoryPreferences() const
(Optional) Returns a vector of supported TensorHandleFactory ids in preference order.
std::unique_ptr< IOptimizedNetwork, void(*)(IOptimizedNetwork *network)> IOptimizedNetworkPtr
std::vector< ConvertFp16ToFp32Layer * > InsertConvertFp16ToFp32LayersBefore(Graph &graph, Layer &layer, bool expectCorrectInputType)
A Pooling2dDescriptor for the Pooling2dLayer.
Status SerializeToDot(std::ostream &stream) const override
A StandInDescriptor for the StandIn layer.
IConnectableLayer * AddSubtractionLayer(const char *name=nullptr) override
A SliceDescriptor for the SliceLayer.
This layer represents a strided slice operation.
IConnectableLayer * AddFullyConnectedLayer(const FullyConnectedDescriptor &fullyConnectedDescriptor, const ConstTensor &weights, const Optional< ConstTensor > &biases, const char *name=nullptr) override
bool m_BiasEnabled
Enable/disable bias.
BackendIdVector m_PreferredBackends
virtual MemorySourceFlags GetImportFlags() const
This layer calculates both true and false outputs for input.
void SetTensorHandleFactory(const ITensorHandleFactory::FactoryId &id)
A DepthwiseConvolution2dDescriptor for the DepthwiseConvolution2dLayer.
A PermuteDescriptor for the PermuteLayer.
void SetQuantizationOffset(int32_t offset)
A Convolution2dDescriptor for the Convolution2dLayer.
IConnectableLayer * AddNormalizationLayer(const NormalizationDescriptor &normalizationDescriptor, const char *name=nullptr) override
IConnectableLayer * AddOutputLayer(LayerBindingId id, const char *name=nullptr) override
IConnectableLayer * AddArgMinMaxLayer(const ArgMinMaxDescriptor &desc, const char *name=nullptr) override
uint32_t m_TargetHeight
Target height value.
This layer represents an unknown operation in the input graph.
A MeanDescriptor for the MeanLayer.
armnn::Runtime::CreationOptions::ExternalProfilingOptions options
A SpaceToBatchNdDescriptor for the SpaceToBatchNdLayer.
OptimizeForType< Layer, AddDebugImpl > InsertDebugLayer
This layer represents an instance normalization operation.
IConnectableLayer * AddStridedSliceLayer(const StridedSliceDescriptor &stridedSliceDescriptor, const char *name=nullptr) override
const TensorInfo & GetTensorInfo() const override
An ArgMinMaxDescriptor for ArgMinMaxLayer.
OptimizeForConnection< PermuteLayer, PermuteLayer, OptimizeInversePermutesImpl > OptimizeInversePermutes
IConnectableLayer * AddConstantLayer(const ConstTensor &input, const char *name=nullptr) override
OptimizeForType< PermuteLayer, PermuteAsReshapeImpl > PermuteAsReshape
bool has_value() const noexcept
Layer & GetOwningLayer() const
IConnectableLayer * AddInstanceNormalizationLayer(const InstanceNormalizationDescriptor &desc, const char *name=nullptr) override
IConnectableLayer * AddFloorLayer(const char *name=nullptr) override
int LayerBindingId
Type of identifiers for bindable layers (inputs, outputs).
constexpr const char * GetDataTypeName(DataType dataType)
const OutputSlot & GetOutputSlot(unsigned int index=0) const override
A ResizeDescriptor for the ResizeLayer.
BackendIdVector GetAvailablePreferredBackends() const
IConnectableLayer * AddBatchNormalizationLayer(const BatchNormalizationDescriptor &desc, const ConstTensor &mean, const ConstTensor &variance, const ConstTensor &beta, const ConstTensor &gamma, const char *name=nullptr) override
This layer represents a L2 normalization operation.
A ComparisonDescriptor for the ComparisonLayer.
Device specific knowledge to be passed to the optimizer.
This layer converts data type Float 16 to Float 32.
IConnectableLayer * AddSpaceToDepthLayer(const SpaceToDepthDescriptor &spaceToDepthDescriptor, const char *name=nullptr) override
float GetQuantizationScale() const
This layer dequantizes the input tensor.
An OriginsDescriptor for the ConcatLayer. Descriptor to configure the concatenation process...
IConnectableLayer * AddDetectionPostProcessLayer(const DetectionPostProcessDescriptor &descriptor, const ConstTensor &anchors, const char *name=nullptr) override
IConnectableLayer * AddBatchToSpaceNdLayer(const BatchToSpaceNdDescriptor &batchToSpaceNdDescriptor, const char *name=nullptr) override
This layer represents a QuantizedLstm operation.
#define ARMNN_NO_DEPRECATE_WARN_END
This layer represents a resize operation.
IConnectableLayer * AddConcatLayer(const ConcatDescriptor &concatDescriptor, const char *name=nullptr) override
A StridedSliceDescriptor for the StridedSliceLayer.
std::unique_ptr< ScopedCpuTensorHandle > m_Weight
A unique pointer to store weight values.