ArmNN
 24.02
Converter.hpp
Go to the documentation of this file.
1 //
2 // Copyright © 2022-2023 Arm Ltd and Contributors. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
6 #pragma once
7 
8 #include "ConversionUtils.hpp"
9 
10 #include <nnapi/OperandTypes.h>
11 #include <nnapi/Result.h>
12 #include <nnapi/Types.h>
13 
14 #include <armnn/Types.hpp>
15 using namespace armnn;
16 
17 namespace armnn_driver
18 {
19 
20 class Converter
21 {
22 
23 public:
26  using OperandLifeTime = ::android::nn::Operand::LifeTime;
31  static bool ConvertOperation(const Operation& operation, const Model& model, ConversionData& data);
32 
33 private:
34  static bool ConvertArgMinMax(const Operation& operation,
35  const Model& model,
36  ConversionData& data,
37  armnn::ArgMinMaxFunction argMinMaxFunction);
38 
39  static bool ConvertAveragePool2d(const Operation& operation, const Model& model, ConversionData& data);
40 
41  static bool ConvertBatchMatMul(const Operation& operation, const Model& model, ConversionData& data);
42 
43  static bool ConvertBatchToSpaceNd(const Operation& operation, const Model& model, ConversionData& data);
44 
45  static bool ConvertCast(const Operation& operation, const Model& model, ConversionData& data);
46 
47  static bool ConvertComparison(const Operation& operation,
48  const Model& model,
49  ConversionData& data,
50  armnn::ComparisonOperation comparisonOperation);
51 
52  static bool ConvertConcatenation(const Operation& operation, const Model& model, ConversionData& data);
53 
54  static bool ConvertConv2d(const Operation& operation, const Model& model, ConversionData& data);
55 
56  static bool ConvertDepthToSpace(const Operation& operation, const Model& model, ConversionData& data);
57 
58  static bool ConvertDepthwiseConv2d(const Operation& operation, const Model& model, ConversionData& data);
59 
60  static bool ConvertDequantize(const Operation& operation, const Model& model, ConversionData& data);
61 
62  static bool ConvertElementwiseUnary(const Operation& operation,
63  const Model& model,
64  ConversionData& data,
65  armnn::UnaryOperation unaryOperation);
66 
67  static bool ConvertElementwiseBinary(const Operation& operation,
68  const Model& model,
69  ConversionData& data,
70  armnn::BinaryOperation binaryOperation);
71 
72  static bool ConvertElu(const Operation& operation, const Model& model, ConversionData& data);
73 
74  static bool ConvertExpandDims(const Operation& operation, const Model& model, ConversionData& data);
75 
76  static bool ConvertFill(const Operation& operation, const Model& model, ConversionData& data);
77 
78  static bool ConvertFloor(const Operation& operation, const Model& model, ConversionData& data);
79 
80  static bool ConvertFullyConnected(const Operation& operation, const Model& model, ConversionData& data);
81 
82  static bool ConvertGather(const Operation& operation, const Model& model, ConversionData& data);
83 
84  static bool ConvertGroupedConv2d(const Operation& operation, const Model& model, ConversionData& data);
85 
86  static bool ConvertHardSwish(const Operation& operation, const Model& model, ConversionData& data);
87 
88  static bool ConvertInstanceNormalization(const Operation& operation, const Model& model, ConversionData& data);
89 
90  static bool ConvertL2Normalization(const Operation& operation, const Model& model, ConversionData& data);
91 
92  static bool ConvertL2Pool2d(const Operation& operation, const Model& model, ConversionData& data);
93 
94  static bool ConvertLocalResponseNormalization(const Operation& operation,
95  const Model& model,
96  ConversionData& data);
97 
98  static bool ConvertLogicalBinary(const Operation& operation,
99  const Model& model,
100  ConversionData& data,
101  armnn::LogicalBinaryOperation logicalOperation);
102 
103  static bool ConvertLogistic(const Operation& operation, const Model& model, ConversionData& data);
104 
105  static bool ConvertLogSoftmax(const Operation& operation, const Model& model, ConversionData& data);
106 
107  static bool ConvertLstm(const Operation& operation, const Model& model, ConversionData& data);
108 
109  static bool ConvertMaxPool2d(const Operation& operation, const Model& model, ConversionData& data);
110 
111  static bool ConvertMean(const Operation& operation, const Model& model, ConversionData& data);
112 
113  static bool ConvertPad(const Operation& operation, const Model& model, ConversionData& data);
114 
115  static bool ConvertPadV2(const Operation& operation, const Model& model, ConversionData& data);
116 
117  static bool ConvertPrelu(const Operation& operation, const Model& model, ConversionData& data);
118 
119  static bool ConvertQuantize(const Operation& operation, const Model& model, ConversionData& data);
120 
121  static bool ConvertQuantizedLstm(const Operation& operation, const Model& model, ConversionData& data);
122 
123  static bool ConvertQuantized16BitLstm(const Operation& operation, const Model& model, ConversionData& data);
124 
125  static bool ConvertRank(const Operation& operation, const Model& model, ConversionData& data);
126 
127  static bool ConvertReLu(const Operation& operation, const Model& model, ConversionData& data);
128 
129  static bool ConvertReLu1(const Operation& operation, const Model& model, ConversionData& data);
130 
131  static bool ConvertReLu6(const Operation& operation, const Model& model, ConversionData& data);
132 
133  static bool ConvertReshape(const Operation& operation, const Model& model, ConversionData& data);
134 
135  static bool ConvertResize(const Operation& operation,
136  const Model& model,
137  ConversionData& data,
138  armnn::ResizeMethod resizeMethod);
139 
140  static bool ConvertReverseV2(const Operation& operation, const Model& model, ConversionData& data);
141 
142  static bool ConvertSoftmax(const Operation& operation, const Model& model, ConversionData& data);
143 
144  static bool ConvertSpaceToBatchNd(const Operation& operation, const Model& model, ConversionData& data);
145 
146  static bool ConvertSpaceToDepth(const Operation& operation, const Model& model, ConversionData& data);
147 
148  static bool ConvertSqrt(const Operation& operation, const Model& model, ConversionData& data);
149 
150  static bool ConvertSqueeze(const Operation& operation, const Model& model, ConversionData& data);
151 
152  static bool ConvertStridedSlice(const Operation& operation, const Model& model, ConversionData& data);
153 
154  static bool ConvertTanH(const Operation& operation, const Model& model, ConversionData& data);
155 
156  static bool ConvertTile(const Operation& operation, const Model& model, ConversionData& data);
157 
158  static bool ConvertTranspose(const Operation& operation, const Model& model, ConversionData& data);
159 
160  static bool ConvertTransposeConv2d(const Operation& operation, const Model& model, ConversionData& data);
161 };
162 
163 } // namespace armnn_driver
armnn_driver::Converter
Definition: Converter.hpp:20
armnn::ResizeMethod
ResizeMethod
Definition: Types.hpp:166
armnn_driver::Operand
::android::nn::Operand Operand
Definition: ConversionUtils.hpp:46
armnn_driver::Converter::OperationType
::android::nn::OperationType OperationType
Definition: Converter.hpp:29
armnn_driver::ConversionData
Definition: ConversionUtils.hpp:53
armnn_driver::Converter::Model
::android::nn::Model Model
Definition: Converter.hpp:24
armnn_driver::Operation
::android::nn::Operation Operation
Definition: ConversionUtils.hpp:49
armnn::ArgMinMaxFunction
ArgMinMaxFunction
Definition: Types.hpp:103
ConversionUtils.hpp
armnn::LogicalBinaryOperation
LogicalBinaryOperation
Definition: Types.hpp:119
armnn_driver::OperandType
::android::nn::OperandType OperandType
Definition: ConversionUtils.hpp:48
armnn_driver::Converter::OperandLifeTime
::android::nn::Operand::LifeTime OperandLifeTime
Definition: Converter.hpp:26
armnn_driver::ErrorStatus
::android::nn::ErrorStatus ErrorStatus
Definition: ConversionUtils.hpp:51
armnn_driver
Helper classes.
Definition: ArmnnDevice.cpp:37
armnn_driver::Model
::android::nn::Model Model
Helper classes.
Definition: ConversionUtils.hpp:45
armnn_driver::Converter::Operand
::android::nn::Operand Operand
Definition: Converter.hpp:25
armnn::UnaryOperation
UnaryOperation
Definition: Types.hpp:125
armnn_driver::Converter::ErrorStatus
::android::nn::ErrorStatus ErrorStatus
Definition: Converter.hpp:30
armnn_driver::OperationType
::android::nn::OperationType OperationType
Definition: ConversionUtils.hpp:50
armnn::ComparisonOperation
ComparisonOperation
Definition: Types.hpp:109
armnn::BinaryOperation
BinaryOperation
Definition: Types.hpp:138
armnn_driver::Converter::OperandType
::android::nn::OperandType OperandType
Definition: Converter.hpp:27
armnn
Copyright (c) 2021 ARM Limited and Contributors.
Definition: 01_00_quick_start.dox:6
Types.hpp
armnn_driver::Converter::Operation
::android::nn::Operation Operation
Definition: Converter.hpp:28