blob: 8549289d69128980f551bad934b30ba2efa02207 [file] [log] [blame]
Sadik Armagan8f397a12022-06-17 15:38:22 +01001//
2// Copyright © 2022 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>
15using namespace armnn;
16
17namespace armnn_driver
18{
19
20class Converter
21{
22
23public:
24 using Model = ::android::nn::Model;
25 using Operand = ::android::nn::Operand;
26 using OperandLifeTime = ::android::nn::Operand::LifeTime;
27 using OperandType = ::android::nn::OperandType;
28 using Operation = ::android::nn::Operation;
29 using OperationType = ::android::nn::OperationType;
30 using ErrorStatus = ::android::nn::ErrorStatus;
31 static bool ConvertOperation(const Operation& operation, const Model& model, ConversionData& data);
32
33private:
34 static bool ConvertAdd(const Operation& operation, const Model& model, ConversionData& data);
35
36 static bool ConvertArgMinMax(const Operation& operation,
37 const Model& model,
38 ConversionData& data,
39 armnn::ArgMinMaxFunction argMinMaxFunction);
40
41 static bool ConvertAveragePool2d(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 ConvertDiv(const Operation& operation, const Model& model, ConversionData& data);
63
64 static bool ConvertElementwiseUnary(const Operation& operation,
65 const Model& model,
66 ConversionData& data,
67 armnn::UnaryOperation unaryOperation);
68
69 static bool ConvertElu(const Operation& operation, const Model& model, ConversionData& data);
70
71 static bool ConvertExpandDims(const Operation& operation, const Model& model, ConversionData& data);
72
73 static bool ConvertFill(const Operation& operation, const Model& model, ConversionData& data);
74
75 static bool ConvertFloor(const Operation& operation, const Model& model, ConversionData& data);
76
77 static bool ConvertFullyConnected(const Operation& operation, const Model& model, ConversionData& data);
78
79 static bool ConvertGather(const Operation& operation, const Model& model, ConversionData& data);
80
81 static bool ConvertGroupedConv2d(const Operation& operation, const Model& model, ConversionData& data);
82
83 static bool ConvertHardSwish(const Operation& operation, const Model& model, ConversionData& data);
84
85 static bool ConvertInstanceNormalization(const Operation& operation, const Model& model, ConversionData& data);
86
87 static bool ConvertL2Normalization(const Operation& operation, const Model& model, ConversionData& data);
88
89 static bool ConvertL2Pool2d(const Operation& operation, const Model& model, ConversionData& data);
90
91 static bool ConvertLocalResponseNormalization(const Operation& operation,
92 const Model& model,
93 ConversionData& data);
94
95 static bool ConvertLogicalBinary(const Operation& operation,
96 const Model& model,
97 ConversionData& data,
98 armnn::LogicalBinaryOperation logicalOperation);
99
100 static bool ConvertLogistic(const Operation& operation, const Model& model, ConversionData& data);
101
102 static bool ConvertLogSoftmax(const Operation& operation, const Model& model, ConversionData& data);
103
104 static bool ConvertLstm(const Operation& operation, const Model& model, ConversionData& data);
105
106 static bool ConvertMaxPool2d(const Operation& operation, const Model& model, ConversionData& data);
107
108 static bool ConvertMaximum(const Operation& operation, const Model& model, ConversionData& data);
109
110 static bool ConvertMean(const Operation& operation, const Model& model, ConversionData& data);
111
112 static bool ConvertMinimum(const Operation& operation, const Model& model, ConversionData& data);
113
114 static bool ConvertMul(const Operation& operation, const Model& model, ConversionData& data);
115
116 static bool ConvertPad(const Operation& operation, const Model& model, ConversionData& data);
117
118 static bool ConvertPadV2(const Operation& operation, const Model& model, ConversionData& data);
119
120 static bool ConvertPrelu(const Operation& operation, const Model& model, ConversionData& data);
121
122 static bool ConvertQuantize(const Operation& operation, const Model& model, ConversionData& data);
123
124 static bool ConvertQuantizedLstm(const Operation& operation, const Model& model, ConversionData& data);
125
126 static bool ConvertQuantized16BitLstm(const Operation& operation, const Model& model, ConversionData& data);
127
128 static bool ConvertRank(const Operation& operation, const Model& model, ConversionData& data);
129
130 static bool ConvertReLu(const Operation& operation, const Model& model, ConversionData& data);
131
132 static bool ConvertReLu1(const Operation& operation, const Model& model, ConversionData& data);
133
134 static bool ConvertReLu6(const Operation& operation, const Model& model, ConversionData& data);
135
136 static bool ConvertReshape(const Operation& operation, const Model& model, ConversionData& data);
137
138 static bool ConvertResize(const Operation& operation,
139 const Model& model,
140 ConversionData& data,
141 armnn::ResizeMethod resizeMethod);
142
143 static bool ConvertSoftmax(const Operation& operation, const Model& model, ConversionData& data);
144
145 static bool ConvertSpaceToBatchNd(const Operation& operation, const Model& model, ConversionData& data);
146
147 static bool ConvertSpaceToDepth(const Operation& operation, const Model& model, ConversionData& data);
148
149 static bool ConvertSqrt(const Operation& operation, const Model& model, ConversionData& data);
150
151 static bool ConvertSqueeze(const Operation& operation, const Model& model, ConversionData& data);
152
153 static bool ConvertStridedSlice(const Operation& operation, const Model& model, ConversionData& data);
154
155 static bool ConvertSub(const Operation& operation, const Model& model, ConversionData& data);
156
157 static bool ConvertTanH(const Operation& operation, const Model& model, ConversionData& data);
158
159 static bool ConvertTranspose(const Operation& operation, const Model& model, ConversionData& data);
160
161 static bool ConvertTransposeConv2d(const Operation& operation, const Model& model, ConversionData& data);
162};
163
164} // namespace armnn_driver