MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / QuantizedTestsNoActivation

Function QuantizedTestsNoActivation

tensorflow/lite/kernels/sub_test.cc:197–219  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

195
196template <TensorType tensor_type, typename integer_dtype>
197void QuantizedTestsNoActivation() {
198 float kQuantizedTolerance = GetTolerance(-1.0, 1.0);
199 std::vector<std::vector<float>> inputs1 = {
200 {0.1, 0.2, 0.3, 0.4}, {-0.2, 0.2, 0.4, 0.7}, {-0.01, 0.2, 0.7, 0.3}};
201 std::vector<std::vector<float>> inputs2 = {
202 {0.6, 0.4, 0.3, 0.1}, {0.6, 0.4, 0.5, -0.2}, {0.6, 0.4, -0.18, 0.5}};
203 std::vector<std::vector<float>> results = {{-0.5, -0.2, 0.0, 0.3},
204 {-0.8, -0.2, -0.1, 0.9},
205 {-0.61, -0.2, 0.88, -0.2}};
206 for (int i = 0; i < inputs1.size(); ++i) {
207 QuantizedSubOpModel m({tensor_type, {1, 2, 2, 1}, -1.0, 1.0},
208 {tensor_type, {1, 2, 2, 1}, -1.0, 1.0},
209 {tensor_type, {}, -1.0, 1.0},
210 ActivationFunctionType_NONE);
211 m.QuantizeAndPopulate<integer_dtype>(m.input1(), inputs1[i]);
212 m.QuantizeAndPopulate<integer_dtype>(m.input2(), inputs2[i]);
213 m.Invoke();
214 EXPECT_THAT(
215 m.GetDequantizedOutput<integer_dtype>(),
216 ElementsAreArray(ArrayFloatNear(results[i], kQuantizedTolerance)))
217 << "With test number " << i;
218 }
219}
220
221TEST(QuantizedSubOpModel, QuantizedTestsNoActivationUInt8) {
222 QuantizedTestsNoActivation<TensorType_UINT8, uint8_t>();

Callers

nothing calls this directly

Calls 6

GetToleranceFunction · 0.70
ArrayFloatNearFunction · 0.70
sizeMethod · 0.45
input1Method · 0.45
input2Method · 0.45
InvokeMethod · 0.45

Tested by

no test coverage detected