1 /* 2 * Copyright (C) 2021 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 <aidl/android/hardware/neuralnetworks/IPreparedModel.h> 18 #include <aidl/android/hardware/neuralnetworks/OperandType.h> 19 #include <aidl/android/hardware/neuralnetworks/OperationType.h> 20 21 #include <ControlFlow.h> 22 #include <TestHarness.h> 23 24 namespace aidl::android::hardware::neuralnetworks { 25 26 namespace nn = ::android::nn; 27 28 static_assert(static_cast<uint64_t>(IPreparedModel::DEFAULT_LOOP_TIMEOUT_DURATION_NS) == 29 nn::operation_while::kTimeoutNsDefault); 30 static_assert(static_cast<uint64_t>(IPreparedModel::MAXIMUM_LOOP_TIMEOUT_DURATION_NS) == 31 nn::operation_while::kTimeoutNsMaximum); 32 33 // Make sure that the HIDL enums are compatible with the values defined in 34 // frameworks/ml/nn/tools/test_generator/test_harness/include/TestHarness.h. 35 using namespace test_helper; 36 #define CHECK_TEST_ENUM(EnumType, enumValue) \ 37 static_assert(static_cast<EnumType>(Test##EnumType::enumValue) == EnumType::enumValue) 38 39 CHECK_TEST_ENUM(OperandType, FLOAT32); 40 CHECK_TEST_ENUM(OperandType, INT32); 41 CHECK_TEST_ENUM(OperandType, UINT32); 42 CHECK_TEST_ENUM(OperandType, TENSOR_FLOAT32); 43 CHECK_TEST_ENUM(OperandType, TENSOR_INT32); 44 CHECK_TEST_ENUM(OperandType, TENSOR_QUANT8_ASYMM); 45 CHECK_TEST_ENUM(OperandType, BOOL); 46 CHECK_TEST_ENUM(OperandType, TENSOR_QUANT16_SYMM); 47 CHECK_TEST_ENUM(OperandType, TENSOR_FLOAT16); 48 CHECK_TEST_ENUM(OperandType, TENSOR_BOOL8); 49 CHECK_TEST_ENUM(OperandType, FLOAT16); 50 CHECK_TEST_ENUM(OperandType, TENSOR_QUANT8_SYMM_PER_CHANNEL); 51 CHECK_TEST_ENUM(OperandType, TENSOR_QUANT16_ASYMM); 52 CHECK_TEST_ENUM(OperandType, TENSOR_QUANT8_SYMM); 53 CHECK_TEST_ENUM(OperandType, TENSOR_QUANT8_ASYMM_SIGNED); 54 55 CHECK_TEST_ENUM(OperationType, ADD); 56 CHECK_TEST_ENUM(OperationType, AVERAGE_POOL_2D); 57 CHECK_TEST_ENUM(OperationType, CONCATENATION); 58 CHECK_TEST_ENUM(OperationType, CONV_2D); 59 CHECK_TEST_ENUM(OperationType, DEPTHWISE_CONV_2D); 60 CHECK_TEST_ENUM(OperationType, DEPTH_TO_SPACE); 61 CHECK_TEST_ENUM(OperationType, DEQUANTIZE); 62 CHECK_TEST_ENUM(OperationType, EMBEDDING_LOOKUP); 63 CHECK_TEST_ENUM(OperationType, FLOOR); 64 CHECK_TEST_ENUM(OperationType, FULLY_CONNECTED); 65 CHECK_TEST_ENUM(OperationType, HASHTABLE_LOOKUP); 66 CHECK_TEST_ENUM(OperationType, L2_NORMALIZATION); 67 CHECK_TEST_ENUM(OperationType, L2_POOL_2D); 68 CHECK_TEST_ENUM(OperationType, LOCAL_RESPONSE_NORMALIZATION); 69 CHECK_TEST_ENUM(OperationType, LOGISTIC); 70 CHECK_TEST_ENUM(OperationType, LSH_PROJECTION); 71 CHECK_TEST_ENUM(OperationType, LSTM); 72 CHECK_TEST_ENUM(OperationType, MAX_POOL_2D); 73 CHECK_TEST_ENUM(OperationType, MUL); 74 CHECK_TEST_ENUM(OperationType, RELU); 75 CHECK_TEST_ENUM(OperationType, RELU1); 76 CHECK_TEST_ENUM(OperationType, RELU6); 77 CHECK_TEST_ENUM(OperationType, RESHAPE); 78 CHECK_TEST_ENUM(OperationType, RESIZE_BILINEAR); 79 CHECK_TEST_ENUM(OperationType, RNN); 80 CHECK_TEST_ENUM(OperationType, SOFTMAX); 81 CHECK_TEST_ENUM(OperationType, SPACE_TO_DEPTH); 82 CHECK_TEST_ENUM(OperationType, SVDF); 83 CHECK_TEST_ENUM(OperationType, TANH); 84 CHECK_TEST_ENUM(OperationType, BATCH_TO_SPACE_ND); 85 CHECK_TEST_ENUM(OperationType, DIV); 86 CHECK_TEST_ENUM(OperationType, MEAN); 87 CHECK_TEST_ENUM(OperationType, PAD); 88 CHECK_TEST_ENUM(OperationType, SPACE_TO_BATCH_ND); 89 CHECK_TEST_ENUM(OperationType, SQUEEZE); 90 CHECK_TEST_ENUM(OperationType, STRIDED_SLICE); 91 CHECK_TEST_ENUM(OperationType, SUB); 92 CHECK_TEST_ENUM(OperationType, TRANSPOSE); 93 CHECK_TEST_ENUM(OperationType, ABS); 94 CHECK_TEST_ENUM(OperationType, ARGMAX); 95 CHECK_TEST_ENUM(OperationType, ARGMIN); 96 CHECK_TEST_ENUM(OperationType, AXIS_ALIGNED_BBOX_TRANSFORM); 97 CHECK_TEST_ENUM(OperationType, BIDIRECTIONAL_SEQUENCE_LSTM); 98 CHECK_TEST_ENUM(OperationType, BIDIRECTIONAL_SEQUENCE_RNN); 99 CHECK_TEST_ENUM(OperationType, BOX_WITH_NMS_LIMIT); 100 CHECK_TEST_ENUM(OperationType, CAST); 101 CHECK_TEST_ENUM(OperationType, CHANNEL_SHUFFLE); 102 CHECK_TEST_ENUM(OperationType, DETECTION_POSTPROCESSING); 103 CHECK_TEST_ENUM(OperationType, EQUAL); 104 CHECK_TEST_ENUM(OperationType, EXP); 105 CHECK_TEST_ENUM(OperationType, EXPAND_DIMS); 106 CHECK_TEST_ENUM(OperationType, GATHER); 107 CHECK_TEST_ENUM(OperationType, GENERATE_PROPOSALS); 108 CHECK_TEST_ENUM(OperationType, GREATER); 109 CHECK_TEST_ENUM(OperationType, GREATER_EQUAL); 110 CHECK_TEST_ENUM(OperationType, GROUPED_CONV_2D); 111 CHECK_TEST_ENUM(OperationType, HEATMAP_MAX_KEYPOINT); 112 CHECK_TEST_ENUM(OperationType, INSTANCE_NORMALIZATION); 113 CHECK_TEST_ENUM(OperationType, LESS); 114 CHECK_TEST_ENUM(OperationType, LESS_EQUAL); 115 CHECK_TEST_ENUM(OperationType, LOG); 116 CHECK_TEST_ENUM(OperationType, LOGICAL_AND); 117 CHECK_TEST_ENUM(OperationType, LOGICAL_NOT); 118 CHECK_TEST_ENUM(OperationType, LOGICAL_OR); 119 CHECK_TEST_ENUM(OperationType, LOG_SOFTMAX); 120 CHECK_TEST_ENUM(OperationType, MAXIMUM); 121 CHECK_TEST_ENUM(OperationType, MINIMUM); 122 CHECK_TEST_ENUM(OperationType, NEG); 123 CHECK_TEST_ENUM(OperationType, NOT_EQUAL); 124 CHECK_TEST_ENUM(OperationType, PAD_V2); 125 CHECK_TEST_ENUM(OperationType, POW); 126 CHECK_TEST_ENUM(OperationType, PRELU); 127 CHECK_TEST_ENUM(OperationType, QUANTIZE); 128 CHECK_TEST_ENUM(OperationType, QUANTIZED_16BIT_LSTM); 129 CHECK_TEST_ENUM(OperationType, RANDOM_MULTINOMIAL); 130 CHECK_TEST_ENUM(OperationType, REDUCE_ALL); 131 CHECK_TEST_ENUM(OperationType, REDUCE_ANY); 132 CHECK_TEST_ENUM(OperationType, REDUCE_MAX); 133 CHECK_TEST_ENUM(OperationType, REDUCE_MIN); 134 CHECK_TEST_ENUM(OperationType, REDUCE_PROD); 135 CHECK_TEST_ENUM(OperationType, REDUCE_SUM); 136 CHECK_TEST_ENUM(OperationType, ROI_ALIGN); 137 CHECK_TEST_ENUM(OperationType, ROI_POOLING); 138 CHECK_TEST_ENUM(OperationType, RSQRT); 139 CHECK_TEST_ENUM(OperationType, SELECT); 140 CHECK_TEST_ENUM(OperationType, SIN); 141 CHECK_TEST_ENUM(OperationType, SLICE); 142 CHECK_TEST_ENUM(OperationType, SPLIT); 143 CHECK_TEST_ENUM(OperationType, SQRT); 144 CHECK_TEST_ENUM(OperationType, TILE); 145 CHECK_TEST_ENUM(OperationType, TOPK_V2); 146 CHECK_TEST_ENUM(OperationType, TRANSPOSE_CONV_2D); 147 CHECK_TEST_ENUM(OperationType, UNIDIRECTIONAL_SEQUENCE_LSTM); 148 CHECK_TEST_ENUM(OperationType, UNIDIRECTIONAL_SEQUENCE_RNN); 149 CHECK_TEST_ENUM(OperationType, RESIZE_NEAREST_NEIGHBOR); 150 151 #undef CHECK_TEST_ENUM 152 153 } // namespace aidl::android::hardware::neuralnetworks 154