29 delete static_cast<const T*
>(blob);
47 auto memoryManager = std::make_shared<TosaRefMemoryManager>();
51 auto factory = std::make_unique<TosaRefTensorHandleFactory>(memoryManager);
73 return std::make_unique<TosaRefMemoryManager>();
87 auto handler = std::make_unique<TosaSerializationHandler>();
89 std::vector<std::string> graphInputs;
90 std::vector<std::string> graphOutputs;
91 std::vector<TosaSerializationOperator*> operators;
92 std::vector<TosaSerializationTensor*> tensors;
96 std::unordered_set<std::string> graphInputsSet;
97 std::unordered_set<std::string> uniqueTensorNamesSet;
99 auto it = subgraph.
begin();
100 while (it != subgraph.
end())
115 for (
const std::string& blockInputName : mappings->GetInputs())
117 if ((blockInputName.find(
"input") != std::string::npos) && !graphInputsSet.count(blockInputName))
119 graphInputs.push_back(blockInputName);
120 graphInputsSet.insert(blockInputName);
126 for (
const std::string& blockOutputName : mappings->GetOutputs())
128 if (blockOutputName.find(
"output") != std::string::npos)
130 graphOutputs.push_back(blockOutputName);
134 sequencer.
Add(&base, mappings);
137 for (
auto & pair : sequencer.
Finish())
139 auto blockOperators = pair.block->GetOperators();
140 operators.insert(operators.end(), blockOperators.begin(), blockOperators.end());
142 auto blockTensors = pair.block->GetTensors();
146 for (
const auto& tensor : blockTensors)
148 const std::string& name = tensor->GetName();
151 if (!uniqueTensorNamesSet.count(name))
153 uniqueTensorNamesSet.insert(name);
154 tensors.push_back(tensor);
160 auto* block =
new TosaSerializationBasicBlock(
"main",
"main", operators, tensors, graphInputs, graphOutputs);
162 std::vector<TosaSerializationBasicBlock*> blocks;
163 blocks.emplace_back(block);
166 auto* region =
new TosaSerializationRegion(
"main", blocks);
167 handler->GetRegions().emplace_back(region);
174 std::move(*compiledBlob),
176 "TOSA_Pre_Compiled_Layer");
185 return optimizationViews;
196 auto memoryManager = std::make_shared<TosaRefMemoryManager>();
200 auto factory = std::make_unique<TosaRefTensorHandleFactory>(memoryManager);
210 return std::make_unique<DefaultAllocator>();
217 {
"NonConstWeights",
true},
218 {
"ConstantTensorsAsInputs",
true}
TosaSerializationBasicBlock * GetTosaMappingFromLayer(const Layer *layer)
std::shared_ptr< ILayerSupport > ILayerSupportSharedPtr
std::unique_ptr< IMemoryManager > IMemoryManagerUniquePtr
std::unique_ptr< arm::pipe::IBackendProfiling > IBackendProfilingPtr
std::shared_ptr< IMemoryManager > IMemoryManagerSharedPtr
std::unique_ptr< IWorkloadFactory > IWorkloadFactoryPtr
std::unique_ptr< IBackendContext > IBackendContextPtr
std::shared_ptr< arm::pipe::IBackendProfilingContext > IBackendProfilingContextPtr
This is the bridge between backend and backend profiling we'll keep it in the backend namespace.
Interface for a layer that is connectable to other layers via InputSlots and OutputSlots.
virtual const IOutputSlot & GetOutputSlot(unsigned int index) const =0
Get the const output slot handle by slot index.
IConnectableLayer * AddPrecompiledLayer(const PreCompiledDescriptor &preCompiledDescriptor, CompiledBlobPtr compiledBlobPtr, const Optional< BackendId > &backend, const char *name=nullptr)
Adds a Precompiled layer to the network.
virtual void SetTensorInfo(const TensorInfo &tensorInfo)=0
virtual const TensorInfo & GetTensorInfo() const =0
LayerType GetType() const override
Returns the armnn::LayerType of this layer.
std::list< Pair > & Finish()
void Add(LayerT *layer, BlockT *block)
void AddSubstitution(SubstitutionPair &&substitution)
The SubgraphView class represents a subgraph of a Graph.
IConnectableLayerIterator begin()
unsigned int GetNumOutputSlots() const
unsigned int GetNumInputSlots() const
const IOutputSlot * GetIOutputSlot(unsigned int index) const
IConnectableLayerIterator end()
void RegisterFactory(std::unique_ptr< ITensorHandleFactory > allocator)
Register a TensorHandleFactory and transfer ownership.
void RegisterMemoryManager(std::shared_ptr< IMemoryManager > memoryManger)
Register a memory manager with shared ownership.
void RegisterCopyAndImportFactoryPair(ITensorHandleFactory::FactoryId copyFactoryId, ITensorHandleFactory::FactoryId importFactoryId)
Register a pair of TensorHandleFactory Id for Memory Copy and TensorHandleFactory Id for Memory Impor...
static const BackendId & GetIdStatic()
const BackendId & GetId() const override
OptimizationViews OptimizeSubgraphView(const SubgraphView &subgraph, const ModelOptions &modelOptions) const override
void RegisterTensorHandleFactories(class TensorHandleFactoryRegistry ®istry) override
(Optional) Register TensorHandleFactories Either this method or CreateMemoryManager() and IWorkloadFa...
std::vector< ITensorHandleFactory::FactoryId > GetHandleFactoryPreferences() const override
(Optional) Returns a vector of supported TensorHandleFactory ids in preference order.
IBackendInternal::IBackendContextPtr CreateBackendContext(const IRuntime::CreationOptions &) const override
Create the runtime context of the backend.
IBackendInternal::IWorkloadFactoryPtr CreateWorkloadFactory(const IBackendInternal::IMemoryManagerSharedPtr &memoryManager=nullptr) const override
IBackendInternal::ILayerSupportSharedPtr GetLayerSupport() const override
IBackendInternal::IMemoryManagerUniquePtr CreateMemoryManager() const override
BackendCapabilities GetCapabilities() const override
Returns a BackendCapability if the backend lists the capability The BackendCapability must then be in...
IBackendInternal::IBackendProfilingContextPtr CreateBackendProfilingContext(const IRuntime::CreationOptions &creationOptions, IBackendProfilingPtr &backendProfiling) override
Create context specifically used for profiling interaction from backends.
std::unique_ptr< ICustomAllocator > GetDefaultAllocator() const override
Returns the default memory allocator for the backend.
static const FactoryId & GetIdStatic()
Copyright (c) 2021 ARM Limited and Contributors.
auto PolymorphicPointerDowncast(const SourceType &value)
Polymorphic downcast for shared pointers and build in pointers.
std::vector< BackendOptions > ModelOptions
void DeleteAsType(const void *const blob)
DestType PolymorphicDowncast(SourceType *value)
Polymorphic downcast for build in pointers only.
BackendOptions BackendCapabilities
constexpr const char * TosaRefBackendId()
A PreCompiledDescriptor for the PreCompiledLayer.