1 /* Copyright 2018 The TensorFlow Authors. All Rights Reserved. 2 3 Licensed under the Apache License, Version 2.0 (the "License"); 4 you may not use this file except in compliance with the License. 5 You may obtain a copy of the License at 6 7 http://www.apache.org/licenses/LICENSE-2.0 8 9 Unless required by applicable law or agreed to in writing, software 10 distributed under the License is distributed on an "AS IS" BASIS, 11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 See the License for the specific language governing permissions and 13 limitations under the License. 14 ==============================================================================*/ 15 #ifndef TENSORFLOW_LITE_TOOLS_OPTIMIZE_TEST_UTIL_H_ 16 #define TENSORFLOW_LITE_TOOLS_OPTIMIZE_TEST_UTIL_H_ 17 18 #include "tensorflow/lite/core/api/error_reporter.h" 19 20 namespace tflite { 21 namespace optimize { 22 namespace internal { 23 // Test model with a single convolution. 24 // Floating point weights of the model are all integers and lie in 25 // range[-127, 127]. The weights have been put in such a way that each 26 // channel has at least one weight as -127 and one weight as 127. 27 // The activations are all in range: [-128, 127] 28 // This means all bias computations should result in 1.0 scale. 29 extern const char* kConvModelWithMinus128Plus127Weights; 30 31 // Test model with single convolution where all weights are integers between 32 // [0, 10] weights are randomly distributed. It is not guaranteed that min max 33 // for weights are going to appear in each channel. 34 // Activations have min = 0, max = 10. 35 extern const char* kConvModelWith0Plus10Weights; 36 37 // Test model where no bias is in the conv. 38 extern const char* kConvModelWithNoBias; 39 40 // A floating point model with a single softmax. The input tensor has min 41 // and max in range [-5, 5], not necessarily -5 or +5. 42 extern const char* kSingleSoftmaxModelMinMinus5MaxPlus5; 43 44 // A floating point model with a single average pool. The input tensor has min 45 // and max in range [-5, 5], not necessarily -5 or +5. 46 extern const char* kSingleAvgPoolModelMinMinus5MaxPlus5; 47 48 // Test model with a weights variable that is shared between a convolution layer 49 // and an add operation. 50 extern const char* kModelWithSharedWeights; 51 52 // Test model with Add followed by a reshape. Model has 2 inputs for add. 53 extern const char* kMultiInputAddWithReshape; 54 55 // Test gather operation with quantized input. 56 extern const char* kQuantizedWithGather; 57 58 // Test model with a tf.constant input to tf.add. Model has 2 inputs one 59 // constant and other placeholder. 60 extern const char* kConstInputAddModel; 61 62 // A float test model with concat that has [0, 5] and [0, 10] for inputs and [0, 63 // 10] as output. 64 extern const char* kFloatConcatMax5Max10Max10; 65 66 // Test model with broadcast_to op. 67 extern const char* kModelWithBroadcastToOp; 68 69 // Test model with a custom op. 70 extern const char* kModelWithCustomOp; 71 72 // Test model with a argmax op. 73 extern const char* kModelWithArgMaxOp; 74 75 // Test model with a fully connected op. 76 extern const char* kModelWithFCOp; 77 78 // Test model with a gather_nd op. 79 extern const char* kModelWithGatherNDOp; 80 81 // Test model with a Where op. 82 extern const char* kModelWithWhereOp; 83 84 // Test model with mixed quantizable and un-quantizable ops. 85 // reshape->custom->custom->squeeze. 86 extern const char* kModelMixed; 87 88 // Test model with mixed quantizable and 89 // and un-quantizable ops for 90 // activations in 16-bit. 91 extern const char* kModelMixed16x8; 92 93 // Test model with split op. 94 extern const char* kModelSplit; 95 96 // Test model with pack op. 97 extern const char* kModelPack; 98 99 // Test model with LSTM op that has layer norm, has projection, without 100 // peephole, without cifg. 101 extern const char* kLstmCalibrated; 102 extern const char* kLstmQuantized; 103 104 // Test model with LSTM op that has peephole, without layer norm, without 105 // projection, without cifg. 106 extern const char* kLstmCalibrated2; 107 extern const char* kLstmQuantized2; 108 109 extern const char* kUnidirectionalSequenceLstmCalibrated; 110 extern const char* kUnidirectionalSequenceLstmQuantized; 111 112 // Test model with a minimum op. 113 extern const char* kModelWithMinimumOp; 114 115 // Test model with a maximum op. 116 extern const char* kModelWithMaximumOp; 117 118 // Test model with a transpose op. 119 extern const char* kModelWithTranspose; 120 121 // Test model with SVDF op. 122 extern const char* kSvdfCalibrated; 123 extern const char* kSvdfQuantized; 124 125 // Test model with an unpack op. 126 extern const char* kModelWithUnpack; 127 128 // Test QAT model with fc op. 129 extern const char* kQatModelWithFc; 130 131 // Test calibrated model with resource variables. 132 extern const char* kModelWithResourceVarsCalibrated; 133 134 // An error reporter that fails on testing. 135 class FailOnErrorReporter : public ErrorReporter { 136 public: 137 int Report(const char* format, va_list args) override; 138 }; 139 } // namespace internal 140 } // namespace optimize 141 } // namespace tflite 142 143 #endif // TENSORFLOW_LITE_TOOLS_OPTIMIZE_TEST_UTIL_H_ 144