xref: /aosp_15_r20/external/armnn/src/armnn/layers/DequantizeLayer.cpp (revision 89c4ff92f2867872bb9e2354d150bf0c8c502810)
1 //
2 // Copyright © 2017 Arm Ltd and Contributors. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 #include "DequantizeLayer.hpp"
6 
7 #include "LayerCloneBase.hpp"
8 
9 #include <armnn/backends/WorkloadData.hpp>
10 #include <armnn/backends/WorkloadFactory.hpp>
11 
12 namespace armnn
13 {
14 
DequantizeLayer(const char * name)15 DequantizeLayer::DequantizeLayer(const char* name)
16     : Layer(1, 1, LayerType::Dequantize, name)
17 {}
18 
CreateWorkload(const IWorkloadFactory & factory) const19 std::unique_ptr<IWorkload> DequantizeLayer::CreateWorkload(
20                                                            const IWorkloadFactory& factory) const
21 {
22     DequantizeQueueDescriptor descriptor;
23     SetAdditionalInfo(descriptor);
24 
25     return factory.CreateWorkload(LayerType::Dequantize, descriptor, PrepInfoAndDesc(descriptor));
26 }
27 
Clone(Graph & graph) const28 DequantizeLayer* DequantizeLayer::Clone(Graph& graph) const
29 {
30     return CloneBase<DequantizeLayer>(graph, GetName());
31 }
32 
ValidateTensorShapesFromInputs()33 void DequantizeLayer::ValidateTensorShapesFromInputs()
34 {
35     VerifyLayerConnections(1, CHECK_LOCATION());
36 
37     const TensorShape& outputShape = GetOutputSlot(0).GetTensorInfo().GetShape();
38 
39     VerifyShapeInferenceType(outputShape, m_ShapeInferenceMethod);
40 
41     std::vector<TensorShape> inferredShapes = InferOutputShapes({
42         GetInputSlot(0).GetConnection()->GetTensorInfo().GetShape() });
43 
44     ARMNN_ASSERT(inferredShapes.size() == 1);
45 
46     ValidateAndCopyShape(outputShape, inferredShapes[0], m_ShapeInferenceMethod, "DequantizeLayer");
47 }
48 
ExecuteStrategy(IStrategy & strategy) const49 void DequantizeLayer::ExecuteStrategy(IStrategy& strategy) const
50 {
51     strategy.ExecuteStrategy(this, GetParameters(), {}, GetName());
52 }
53 
54 } // namespace armnn
55