1 /*
2  * Copyright (C) 2019 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 "Model.pb.h"
18 #include "TestHarness.h"
19 
20 namespace android::nn::fuzz {
21 namespace {
22 
23 using namespace test_helper;
24 using namespace android_nn_fuzz;
25 
26 static_assert(static_cast<TestOperandType>(FLOAT32) == TestOperandType::FLOAT32);
27 static_assert(static_cast<TestOperandType>(INT32) == TestOperandType::INT32);
28 static_assert(static_cast<TestOperandType>(UINT32) == TestOperandType::UINT32);
29 static_assert(static_cast<TestOperandType>(TENSOR_FLOAT32) == TestOperandType::TENSOR_FLOAT32);
30 static_assert(static_cast<TestOperandType>(TENSOR_INT32) == TestOperandType::TENSOR_INT32);
31 static_assert(static_cast<TestOperandType>(TENSOR_QUANT8_ASYMM) ==
32               TestOperandType::TENSOR_QUANT8_ASYMM);
33 static_assert(static_cast<TestOperandType>(BOOL) == TestOperandType::BOOL);
34 static_assert(static_cast<TestOperandType>(TENSOR_QUANT16_SYMM) ==
35               TestOperandType::TENSOR_QUANT16_SYMM);
36 static_assert(static_cast<TestOperandType>(TENSOR_FLOAT16) == TestOperandType::TENSOR_FLOAT16);
37 static_assert(static_cast<TestOperandType>(TENSOR_BOOL8) == TestOperandType::TENSOR_BOOL8);
38 static_assert(static_cast<TestOperandType>(FLOAT16) == TestOperandType::FLOAT16);
39 static_assert(static_cast<TestOperandType>(TENSOR_QUANT8_SYMM_PER_CHANNEL) ==
40               TestOperandType::TENSOR_QUANT8_SYMM_PER_CHANNEL);
41 static_assert(static_cast<TestOperandType>(TENSOR_QUANT16_ASYMM) ==
42               TestOperandType::TENSOR_QUANT16_ASYMM);
43 static_assert(static_cast<TestOperandType>(TENSOR_QUANT8_SYMM) ==
44               TestOperandType::TENSOR_QUANT8_SYMM);
45 static_assert(static_cast<TestOperandType>(TENSOR_QUANT8_ASYMM_SIGNED) ==
46               TestOperandType::TENSOR_QUANT8_ASYMM_SIGNED);
47 
48 static_assert(static_cast<TestOperationType>(ADD) == TestOperationType::ADD);
49 static_assert(static_cast<TestOperationType>(AVERAGE_POOL_2D) ==
50               TestOperationType::AVERAGE_POOL_2D);
51 static_assert(static_cast<TestOperationType>(CONCATENATION) == TestOperationType::CONCATENATION);
52 static_assert(static_cast<TestOperationType>(CONV_2D) == TestOperationType::CONV_2D);
53 static_assert(static_cast<TestOperationType>(DEPTHWISE_CONV_2D) ==
54               TestOperationType::DEPTHWISE_CONV_2D);
55 static_assert(static_cast<TestOperationType>(DEPTH_TO_SPACE) == TestOperationType::DEPTH_TO_SPACE);
56 static_assert(static_cast<TestOperationType>(DEQUANTIZE) == TestOperationType::DEQUANTIZE);
57 static_assert(static_cast<TestOperationType>(EMBEDDING_LOOKUP) ==
58               TestOperationType::EMBEDDING_LOOKUP);
59 static_assert(static_cast<TestOperationType>(FLOOR) == TestOperationType::FLOOR);
60 static_assert(static_cast<TestOperationType>(FULLY_CONNECTED) ==
61               TestOperationType::FULLY_CONNECTED);
62 static_assert(static_cast<TestOperationType>(HASHTABLE_LOOKUP) ==
63               TestOperationType::HASHTABLE_LOOKUP);
64 static_assert(static_cast<TestOperationType>(L2_NORMALIZATION) ==
65               TestOperationType::L2_NORMALIZATION);
66 static_assert(static_cast<TestOperationType>(L2_POOL_2D) == TestOperationType::L2_POOL_2D);
67 static_assert(static_cast<TestOperationType>(LOCAL_RESPONSE_NORMALIZATION) ==
68               TestOperationType::LOCAL_RESPONSE_NORMALIZATION);
69 static_assert(static_cast<TestOperationType>(LOGISTIC) == TestOperationType::LOGISTIC);
70 static_assert(static_cast<TestOperationType>(LSH_PROJECTION) == TestOperationType::LSH_PROJECTION);
71 static_assert(static_cast<TestOperationType>(LSTM) == TestOperationType::LSTM);
72 static_assert(static_cast<TestOperationType>(MAX_POOL_2D) == TestOperationType::MAX_POOL_2D);
73 static_assert(static_cast<TestOperationType>(MUL) == TestOperationType::MUL);
74 static_assert(static_cast<TestOperationType>(RELU) == TestOperationType::RELU);
75 static_assert(static_cast<TestOperationType>(RELU1) == TestOperationType::RELU1);
76 static_assert(static_cast<TestOperationType>(RELU6) == TestOperationType::RELU6);
77 static_assert(static_cast<TestOperationType>(RESHAPE) == TestOperationType::RESHAPE);
78 static_assert(static_cast<TestOperationType>(RESIZE_BILINEAR) ==
79               TestOperationType::RESIZE_BILINEAR);
80 static_assert(static_cast<TestOperationType>(RNN) == TestOperationType::RNN);
81 static_assert(static_cast<TestOperationType>(SOFTMAX) == TestOperationType::SOFTMAX);
82 static_assert(static_cast<TestOperationType>(SPACE_TO_DEPTH) == TestOperationType::SPACE_TO_DEPTH);
83 static_assert(static_cast<TestOperationType>(SVDF) == TestOperationType::SVDF);
84 static_assert(static_cast<TestOperationType>(TANH) == TestOperationType::TANH);
85 static_assert(static_cast<TestOperationType>(BATCH_TO_SPACE_ND) ==
86               TestOperationType::BATCH_TO_SPACE_ND);
87 static_assert(static_cast<TestOperationType>(DIV) == TestOperationType::DIV);
88 static_assert(static_cast<TestOperationType>(MEAN) == TestOperationType::MEAN);
89 static_assert(static_cast<TestOperationType>(PAD) == TestOperationType::PAD);
90 static_assert(static_cast<TestOperationType>(SPACE_TO_BATCH_ND) ==
91               TestOperationType::SPACE_TO_BATCH_ND);
92 static_assert(static_cast<TestOperationType>(SQUEEZE) == TestOperationType::SQUEEZE);
93 static_assert(static_cast<TestOperationType>(STRIDED_SLICE) == TestOperationType::STRIDED_SLICE);
94 static_assert(static_cast<TestOperationType>(SUB) == TestOperationType::SUB);
95 static_assert(static_cast<TestOperationType>(TRANSPOSE) == TestOperationType::TRANSPOSE);
96 static_assert(static_cast<TestOperationType>(ABS) == TestOperationType::ABS);
97 static_assert(static_cast<TestOperationType>(ARGMAX) == TestOperationType::ARGMAX);
98 static_assert(static_cast<TestOperationType>(ARGMIN) == TestOperationType::ARGMIN);
99 static_assert(static_cast<TestOperationType>(AXIS_ALIGNED_BBOX_TRANSFORM) ==
100               TestOperationType::AXIS_ALIGNED_BBOX_TRANSFORM);
101 static_assert(static_cast<TestOperationType>(BIDIRECTIONAL_SEQUENCE_LSTM) ==
102               TestOperationType::BIDIRECTIONAL_SEQUENCE_LSTM);
103 static_assert(static_cast<TestOperationType>(BIDIRECTIONAL_SEQUENCE_RNN) ==
104               TestOperationType::BIDIRECTIONAL_SEQUENCE_RNN);
105 static_assert(static_cast<TestOperationType>(BOX_WITH_NMS_LIMIT) ==
106               TestOperationType::BOX_WITH_NMS_LIMIT);
107 static_assert(static_cast<TestOperationType>(CAST) == TestOperationType::CAST);
108 static_assert(static_cast<TestOperationType>(CHANNEL_SHUFFLE) ==
109               TestOperationType::CHANNEL_SHUFFLE);
110 static_assert(static_cast<TestOperationType>(DETECTION_POSTPROCESSING) ==
111               TestOperationType::DETECTION_POSTPROCESSING);
112 static_assert(static_cast<TestOperationType>(EQUAL) == TestOperationType::EQUAL);
113 static_assert(static_cast<TestOperationType>(EXP) == TestOperationType::EXP);
114 static_assert(static_cast<TestOperationType>(EXPAND_DIMS) == TestOperationType::EXPAND_DIMS);
115 static_assert(static_cast<TestOperationType>(GATHER) == TestOperationType::GATHER);
116 static_assert(static_cast<TestOperationType>(GENERATE_PROPOSALS) ==
117               TestOperationType::GENERATE_PROPOSALS);
118 static_assert(static_cast<TestOperationType>(GREATER) == TestOperationType::GREATER);
119 static_assert(static_cast<TestOperationType>(GREATER_EQUAL) == TestOperationType::GREATER_EQUAL);
120 static_assert(static_cast<TestOperationType>(GROUPED_CONV_2D) ==
121               TestOperationType::GROUPED_CONV_2D);
122 static_assert(static_cast<TestOperationType>(HEATMAP_MAX_KEYPOINT) ==
123               TestOperationType::HEATMAP_MAX_KEYPOINT);
124 static_assert(static_cast<TestOperationType>(INSTANCE_NORMALIZATION) ==
125               TestOperationType::INSTANCE_NORMALIZATION);
126 static_assert(static_cast<TestOperationType>(LESS) == TestOperationType::LESS);
127 static_assert(static_cast<TestOperationType>(LESS_EQUAL) == TestOperationType::LESS_EQUAL);
128 static_assert(static_cast<TestOperationType>(LOG) == TestOperationType::LOG);
129 static_assert(static_cast<TestOperationType>(LOGICAL_AND) == TestOperationType::LOGICAL_AND);
130 static_assert(static_cast<TestOperationType>(LOGICAL_NOT) == TestOperationType::LOGICAL_NOT);
131 static_assert(static_cast<TestOperationType>(LOGICAL_OR) == TestOperationType::LOGICAL_OR);
132 static_assert(static_cast<TestOperationType>(LOG_SOFTMAX) == TestOperationType::LOG_SOFTMAX);
133 static_assert(static_cast<TestOperationType>(MAXIMUM) == TestOperationType::MAXIMUM);
134 static_assert(static_cast<TestOperationType>(MINIMUM) == TestOperationType::MINIMUM);
135 static_assert(static_cast<TestOperationType>(NEG) == TestOperationType::NEG);
136 static_assert(static_cast<TestOperationType>(NOT_EQUAL) == TestOperationType::NOT_EQUAL);
137 static_assert(static_cast<TestOperationType>(PAD_V2) == TestOperationType::PAD_V2);
138 static_assert(static_cast<TestOperationType>(POW) == TestOperationType::POW);
139 static_assert(static_cast<TestOperationType>(PRELU) == TestOperationType::PRELU);
140 static_assert(static_cast<TestOperationType>(QUANTIZE) == TestOperationType::QUANTIZE);
141 static_assert(static_cast<TestOperationType>(QUANTIZED_16BIT_LSTM) ==
142               TestOperationType::QUANTIZED_16BIT_LSTM);
143 static_assert(static_cast<TestOperationType>(RANDOM_MULTINOMIAL) ==
144               TestOperationType::RANDOM_MULTINOMIAL);
145 static_assert(static_cast<TestOperationType>(REDUCE_ALL) == TestOperationType::REDUCE_ALL);
146 static_assert(static_cast<TestOperationType>(REDUCE_ANY) == TestOperationType::REDUCE_ANY);
147 static_assert(static_cast<TestOperationType>(REDUCE_MAX) == TestOperationType::REDUCE_MAX);
148 static_assert(static_cast<TestOperationType>(REDUCE_MIN) == TestOperationType::REDUCE_MIN);
149 static_assert(static_cast<TestOperationType>(REDUCE_PROD) == TestOperationType::REDUCE_PROD);
150 static_assert(static_cast<TestOperationType>(REDUCE_SUM) == TestOperationType::REDUCE_SUM);
151 static_assert(static_cast<TestOperationType>(ROI_ALIGN) == TestOperationType::ROI_ALIGN);
152 static_assert(static_cast<TestOperationType>(ROI_POOLING) == TestOperationType::ROI_POOLING);
153 static_assert(static_cast<TestOperationType>(RSQRT) == TestOperationType::RSQRT);
154 static_assert(static_cast<TestOperationType>(SELECT) == TestOperationType::SELECT);
155 static_assert(static_cast<TestOperationType>(SIN) == TestOperationType::SIN);
156 static_assert(static_cast<TestOperationType>(SLICE) == TestOperationType::SLICE);
157 static_assert(static_cast<TestOperationType>(SPLIT) == TestOperationType::SPLIT);
158 static_assert(static_cast<TestOperationType>(SQRT) == TestOperationType::SQRT);
159 static_assert(static_cast<TestOperationType>(TILE) == TestOperationType::TILE);
160 static_assert(static_cast<TestOperationType>(TOPK_V2) == TestOperationType::TOPK_V2);
161 static_assert(static_cast<TestOperationType>(TRANSPOSE_CONV_2D) ==
162               TestOperationType::TRANSPOSE_CONV_2D);
163 static_assert(static_cast<TestOperationType>(UNIDIRECTIONAL_SEQUENCE_LSTM) ==
164               TestOperationType::UNIDIRECTIONAL_SEQUENCE_LSTM);
165 static_assert(static_cast<TestOperationType>(UNIDIRECTIONAL_SEQUENCE_RNN) ==
166               TestOperationType::UNIDIRECTIONAL_SEQUENCE_RNN);
167 static_assert(static_cast<TestOperationType>(RESIZE_NEAREST_NEIGHBOR) ==
168               TestOperationType::RESIZE_NEAREST_NEIGHBOR);
169 
170 static_assert(static_cast<TestOperandLifeTime>(TEMPORARY_VARIABLE) ==
171               TestOperandLifeTime::TEMPORARY_VARIABLE);
172 static_assert(static_cast<TestOperandLifeTime>(SUBGRAPH_INPUT) ==
173               TestOperandLifeTime::SUBGRAPH_INPUT);
174 static_assert(static_cast<TestOperandLifeTime>(SUBGRAPH_OUTPUT) ==
175               TestOperandLifeTime::SUBGRAPH_OUTPUT);
176 static_assert(static_cast<TestOperandLifeTime>(CONSTANT_COPY) ==
177               TestOperandLifeTime::CONSTANT_COPY);
178 static_assert(static_cast<TestOperandLifeTime>(CONSTANT_REFERENCE) ==
179               TestOperandLifeTime::CONSTANT_REFERENCE);
180 static_assert(static_cast<TestOperandLifeTime>(NO_VALUE) == TestOperandLifeTime::NO_VALUE);
181 
182 }  // anonymous namespace
183 }  // namespace android::nn::fuzz
184