blob: 9d9716acdf3ed538ef319cf625e56ee82583608b [file] [log] [blame]
Michael Butlerb98aa6d2020-02-22 22:37:59 -08001/*
2 * Copyright (C) 2020 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include <android/hardware/neuralnetworks/1.2/types.h>
18#include <nnapi/OperandTypes.h>
19#include <nnapi/OperationTypes.h>
20#include <nnapi/Types.h>
21#include <type_traits>
22
23namespace {
24
25#define COMPARE_ENUMS_TYPES(type) \
26 static_assert(std::is_same_v< \
27 std::underlying_type_t<::android::hardware::neuralnetworks::V1_2::type>, \
28 std::underlying_type_t<::android::nn::type>>, \
29 "::android::hardware::neuralnetworks::V1_2::" #type \
30 " does not have the same underlying type as ::android::nn::" #type)
31
32COMPARE_ENUMS_TYPES(OperandType);
33COMPARE_ENUMS_TYPES(OperationType);
34COMPARE_ENUMS_TYPES(DeviceType);
35COMPARE_ENUMS_TYPES(MeasureTiming);
36
37#undef COMPARE_ENUMS_TYPES
38
39#define COMPARE_ENUMS_FULL(symbol, type) \
40 static_assert( \
41 static_cast<std::underlying_type_t<::android::hardware::neuralnetworks::V1_2::type>>( \
42 ::android::hardware::neuralnetworks::V1_2::type::symbol) == \
43 static_cast<std::underlying_type_t<::android::nn::type>>( \
44 ::android::nn::type::symbol), \
45 "::android::hardware::neuralnetworks::V1_2::" #type "::" #symbol \
46 " does not match ::android::nn::" #type "::" #symbol)
47
48#define COMPARE_ENUMS(symbol) COMPARE_ENUMS_FULL(symbol, OperandType)
49
50COMPARE_ENUMS(FLOAT32);
51COMPARE_ENUMS(INT32);
52COMPARE_ENUMS(UINT32);
53COMPARE_ENUMS(TENSOR_FLOAT32);
54COMPARE_ENUMS(TENSOR_INT32);
55COMPARE_ENUMS(TENSOR_QUANT8_ASYMM);
56COMPARE_ENUMS(BOOL);
57COMPARE_ENUMS(TENSOR_QUANT16_SYMM);
58COMPARE_ENUMS(TENSOR_FLOAT16);
59COMPARE_ENUMS(TENSOR_BOOL8);
60COMPARE_ENUMS(FLOAT16);
61COMPARE_ENUMS(TENSOR_QUANT8_SYMM_PER_CHANNEL);
62COMPARE_ENUMS(TENSOR_QUANT16_ASYMM);
63COMPARE_ENUMS(TENSOR_QUANT8_SYMM);
64COMPARE_ENUMS(OEM);
65COMPARE_ENUMS(TENSOR_OEM_BYTE);
66
67#undef COMPARE_ENUMS
68
69#define COMPARE_ENUMS(symbol) COMPARE_ENUMS_FULL(symbol, OperationType)
70
71COMPARE_ENUMS(ADD);
72COMPARE_ENUMS(AVERAGE_POOL_2D);
73COMPARE_ENUMS(CONCATENATION);
74COMPARE_ENUMS(CONV_2D);
75COMPARE_ENUMS(DEPTHWISE_CONV_2D);
76COMPARE_ENUMS(DEPTH_TO_SPACE);
77COMPARE_ENUMS(DEQUANTIZE);
78COMPARE_ENUMS(EMBEDDING_LOOKUP);
79COMPARE_ENUMS(FLOOR);
80COMPARE_ENUMS(FULLY_CONNECTED);
81COMPARE_ENUMS(HASHTABLE_LOOKUP);
82COMPARE_ENUMS(L2_NORMALIZATION);
83COMPARE_ENUMS(L2_POOL_2D);
84COMPARE_ENUMS(LOCAL_RESPONSE_NORMALIZATION);
85COMPARE_ENUMS(LOGISTIC);
86COMPARE_ENUMS(LSH_PROJECTION);
87COMPARE_ENUMS(LSTM);
88COMPARE_ENUMS(MAX_POOL_2D);
89COMPARE_ENUMS(MUL);
90COMPARE_ENUMS(RELU);
91COMPARE_ENUMS(RELU1);
92COMPARE_ENUMS(RELU6);
93COMPARE_ENUMS(RESHAPE);
94COMPARE_ENUMS(RESIZE_BILINEAR);
95COMPARE_ENUMS(RNN);
96COMPARE_ENUMS(SOFTMAX);
97COMPARE_ENUMS(SPACE_TO_DEPTH);
98COMPARE_ENUMS(SVDF);
99COMPARE_ENUMS(TANH);
100COMPARE_ENUMS(BATCH_TO_SPACE_ND);
101COMPARE_ENUMS(DIV);
102COMPARE_ENUMS(MEAN);
103COMPARE_ENUMS(PAD);
104COMPARE_ENUMS(SPACE_TO_BATCH_ND);
105COMPARE_ENUMS(SQUEEZE);
106COMPARE_ENUMS(STRIDED_SLICE);
107COMPARE_ENUMS(SUB);
108COMPARE_ENUMS(TRANSPOSE);
109COMPARE_ENUMS(ABS);
110COMPARE_ENUMS(ARGMAX);
111COMPARE_ENUMS(ARGMIN);
112COMPARE_ENUMS(AXIS_ALIGNED_BBOX_TRANSFORM);
113COMPARE_ENUMS(BIDIRECTIONAL_SEQUENCE_LSTM);
114COMPARE_ENUMS(BIDIRECTIONAL_SEQUENCE_RNN);
115COMPARE_ENUMS(BOX_WITH_NMS_LIMIT);
116COMPARE_ENUMS(CAST);
117COMPARE_ENUMS(CHANNEL_SHUFFLE);
118COMPARE_ENUMS(DETECTION_POSTPROCESSING);
119COMPARE_ENUMS(EQUAL);
120COMPARE_ENUMS(EXP);
121COMPARE_ENUMS(EXPAND_DIMS);
122COMPARE_ENUMS(GATHER);
123COMPARE_ENUMS(GENERATE_PROPOSALS);
124COMPARE_ENUMS(GREATER);
125COMPARE_ENUMS(GREATER_EQUAL);
126COMPARE_ENUMS(GROUPED_CONV_2D);
127COMPARE_ENUMS(HEATMAP_MAX_KEYPOINT);
128COMPARE_ENUMS(INSTANCE_NORMALIZATION);
129COMPARE_ENUMS(LESS);
130COMPARE_ENUMS(LESS_EQUAL);
131COMPARE_ENUMS(LOG);
132COMPARE_ENUMS(LOGICAL_AND);
133COMPARE_ENUMS(LOGICAL_NOT);
134COMPARE_ENUMS(LOGICAL_OR);
135COMPARE_ENUMS(LOG_SOFTMAX);
136COMPARE_ENUMS(MAXIMUM);
137COMPARE_ENUMS(MINIMUM);
138COMPARE_ENUMS(NEG);
139COMPARE_ENUMS(NOT_EQUAL);
140COMPARE_ENUMS(PAD_V2);
141COMPARE_ENUMS(POW);
142COMPARE_ENUMS(PRELU);
143COMPARE_ENUMS(QUANTIZE);
144COMPARE_ENUMS(QUANTIZED_16BIT_LSTM);
145COMPARE_ENUMS(RANDOM_MULTINOMIAL);
146COMPARE_ENUMS(REDUCE_ALL);
147COMPARE_ENUMS(REDUCE_ANY);
148COMPARE_ENUMS(REDUCE_MAX);
149COMPARE_ENUMS(REDUCE_MIN);
150COMPARE_ENUMS(REDUCE_PROD);
151COMPARE_ENUMS(REDUCE_SUM);
152COMPARE_ENUMS(ROI_ALIGN);
153COMPARE_ENUMS(ROI_POOLING);
154COMPARE_ENUMS(RSQRT);
155COMPARE_ENUMS(SELECT);
156COMPARE_ENUMS(SIN);
157COMPARE_ENUMS(SLICE);
158COMPARE_ENUMS(SPLIT);
159COMPARE_ENUMS(SQRT);
160COMPARE_ENUMS(TILE);
161COMPARE_ENUMS(TOPK_V2);
162COMPARE_ENUMS(TRANSPOSE_CONV_2D);
163COMPARE_ENUMS(UNIDIRECTIONAL_SEQUENCE_LSTM);
164COMPARE_ENUMS(UNIDIRECTIONAL_SEQUENCE_RNN);
165COMPARE_ENUMS(RESIZE_NEAREST_NEIGHBOR);
166COMPARE_ENUMS(OEM_OPERATION);
167
168#undef COMPARE_ENUMS
169
170#define COMPARE_ENUMS(symbol) COMPARE_ENUMS_FULL(symbol, DeviceType)
171
172COMPARE_ENUMS(OTHER);
173COMPARE_ENUMS(CPU);
174COMPARE_ENUMS(GPU);
175COMPARE_ENUMS(ACCELERATOR);
176
177#undef COMPARE_ENUMS
178
179#define COMPARE_ENUMS(symbol) COMPARE_ENUMS_FULL(symbol, MeasureTiming)
180
181COMPARE_ENUMS(NO);
182COMPARE_ENUMS(YES);
183
184#undef COMPARE_ENUMS
185
186#undef COMPARE_ENUMS_FULL
187
188} // anonymous namespace