ArmNN
 24.02
PreCompiledLayer.cpp
Go to the documentation of this file.
1 //
2 // Copyright © 2017 Arm Ltd and Contributors. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
6 #include "PreCompiledLayer.hpp"
7 
8 #include "LayerCloneBase.hpp"
9 
11 
12 #include <armnn/TypesUtils.hpp>
13 
14 namespace armnn
15 {
16 
18  : LayerWithParameters(param.m_NumInputSlots, param.m_NumOutputSlots, LayerType::PreCompiled, param, name)
19 {}
20 
22 {}
23 
25 {
26  PreCompiledLayer* clone = CloneBase<PreCompiledLayer>(graph, m_Param, GetName());
27  clone->m_PreCompiledObject = const_cast<PreCompiledLayer*>(this)->m_PreCompiledObject;
28  return clone;
29 }
30 
31 std::unique_ptr<IWorkload> PreCompiledLayer::CreateWorkload(const armnn::IWorkloadFactory& factory) const
32 {
33  PreCompiledQueueDescriptor descriptor;
34  descriptor.m_PreCompiledObject = m_PreCompiledObject.get();
35  SetAdditionalInfo(descriptor);
36 
37  return factory.CreateWorkload(LayerType::PreCompiled, descriptor, PrepInfoAndDesc(descriptor));
38 }
39 
41 {
42 
43  // NOTE: since the PreCompiledLayer is an internal layer created from a valid SubgraphView,
44  // we do not need to validate its input shapes
45 }
46 
48 {
49  m_PreCompiledObject = std::move(preCompiledObject);
50 }
51 
53 {
54  strategy.ExecuteStrategy(this, GetParameters(), {}, GetName());
55 }
56 
57 } // namespace armnn
armnn::PreCompiledLayer::CreateWorkload
virtual std::unique_ptr< IWorkload > CreateWorkload(const IWorkloadFactory &factory) const override
Definition: PreCompiledLayer.cpp:31
armnn::PreCompiledQueueDescriptor::m_PreCompiledObject
void * m_PreCompiledObject
Definition: WorkloadData.hpp:519
TypesUtils.hpp
armnn::PreCompiledLayer::Clone
PreCompiledLayer * Clone(Graph &graph) const override
Creates a dynamically-allocated copy of this layer.
Definition: PreCompiledLayer.cpp:24
armnn::PreCompiledObjectPtr
std::unique_ptr< void, PreCompiledObjectDeleter > PreCompiledObjectPtr
Definition: PreCompiledLayer.hpp:20
armnn::PreCompiledQueueDescriptor
Definition: WorkloadData.hpp:512
armnn::IStrategy
Definition: IStrategy.hpp:16
armnn::LayerWithParameters< PreCompiledDescriptor >::GetParameters
const PreCompiledDescriptor & GetParameters() const override
Definition: LayerWithParameters.hpp:19
armnn::LayerWithParameters
Definition: LayerWithParameters.hpp:14
armnn::Layer::GetName
const char * GetName() const override
Returns the name of the layer.
Definition: Layer.hpp:332
armnn::LayerWithParameters< PreCompiledDescriptor >::m_Param
PreCompiledDescriptor m_Param
The parameters for the layer (not including tensor-valued weights etc.).
Definition: LayerWithParameters.hpp:52
armnn::PreCompiledLayer::~PreCompiledLayer
~PreCompiledLayer()
Definition: PreCompiledLayer.cpp:21
armnn::LayerWithParameters< PreCompiledDescriptor >::PrepInfoAndDesc
WorkloadInfo PrepInfoAndDesc(QueueDescriptor &descriptor) const
Helper function to reduce duplication in *Layer::CreateWorkload.
Definition: LayerWithParameters.hpp:44
Workload.hpp
PreCompiledLayer.hpp
armnn::IWorkloadFactory
Definition: WorkloadFactory.hpp:22
armnn::PreCompiledLayer::PreCompiledLayer
PreCompiledLayer(const PreCompiledDescriptor &param, const char *name)
Definition: PreCompiledLayer.cpp:17
armnn::Layer::SetAdditionalInfo
void SetAdditionalInfo(QueueDescriptor &descriptor) const
Definition: Layer.cpp:287
armnn::PreCompiledLayer
Definition: PreCompiledLayer.hpp:22
armnn::LayerType::PreCompiled
@ PreCompiled
armnn
Copyright (c) 2021 ARM Limited and Contributors.
Definition: 01_00_quick_start.dox:6
armnn::PreCompiledLayer::SetPreCompiledObject
void SetPreCompiledObject(PreCompiledObjectPtr preCompiledObject)
Definition: PreCompiledLayer.cpp:47
armnn::PreCompiledLayer::ValidateTensorShapesFromInputs
void ValidateTensorShapesFromInputs() override
Definition: PreCompiledLayer.cpp:40
armnn::PreCompiledDescriptor
A PreCompiledDescriptor for the PreCompiledLayer.
Definition: Descriptors.hpp:1367
armnn::PreCompiledLayer::ExecuteStrategy
void ExecuteStrategy(IStrategy &strategy) const override
Apply a visitor to this layer.
Definition: PreCompiledLayer.cpp:52
armnn::LayerType
LayerType
When adding a new layer, adapt also the LastLayer enum value in the enum class LayerType below.
Definition: Types.hpp:491
armnn::Graph
Definition: Graph.hpp:30
armnn::IWorkloadFactory::CreateWorkload
virtual std::unique_ptr< IWorkload > CreateWorkload(LayerType type, const QueueDescriptor &descriptor, const WorkloadInfo &info) const =0
Backends should implement their own CreateWorkload function with a switch statement.
armnn::IStrategy::ExecuteStrategy
virtual void ExecuteStrategy(const IConnectableLayer *layer, const armnn::BaseDescriptor &descriptor, const std::vector< armnn::ConstTensor > &constants, const char *name, const armnn::LayerBindingId id=0)=0
LayerCloneBase.hpp