xref: /aosp_15_r20/external/armnn/src/armnn/layers/PreCompiledLayer.cpp (revision 89c4ff92f2867872bb9e2354d150bf0c8c502810)
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 
10 #include <armnn/backends/Workload.hpp>
11 
12 #include <armnn/TypesUtils.hpp>
13 
14 namespace armnn
15 {
16 
PreCompiledLayer(const PreCompiledDescriptor & param,const char * name)17 PreCompiledLayer::PreCompiledLayer(const PreCompiledDescriptor& param, const char* name)
18     : LayerWithParameters(param.m_NumInputSlots, param.m_NumOutputSlots, LayerType::PreCompiled, param, name)
19 {}
20 
~PreCompiledLayer()21 PreCompiledLayer::~PreCompiledLayer()
22 {}
23 
Clone(Graph & graph) const24 PreCompiledLayer* PreCompiledLayer::Clone(Graph& graph) const
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 
CreateWorkload(const armnn::IWorkloadFactory & factory) const31 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 
ValidateTensorShapesFromInputs()40 void PreCompiledLayer::ValidateTensorShapesFromInputs()
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 
SetPreCompiledObject(PreCompiledObjectPtr preCompiledObject)47 void PreCompiledLayer::SetPreCompiledObject(PreCompiledObjectPtr preCompiledObject)
48 {
49     m_PreCompiledObject = std::move(preCompiledObject);
50 }
51 
ExecuteStrategy(IStrategy & strategy) const52 void PreCompiledLayer::ExecuteStrategy(IStrategy& strategy) const
53 {
54     strategy.ExecuteStrategy(this, GetParameters(), {}, GetName());
55 }
56 
57 } // namespace armnn
58