| 195 | |
| 196 | template <TensorType tensor_type, typename integer_dtype> |
| 197 | void 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 | |
| 221 | TEST(QuantizedSubOpModel, QuantizedTestsNoActivationUInt8) { |
| 222 | QuantizedTestsNoActivation<TensorType_UINT8, uint8_t>(); |
nothing calls this directly
no test coverage detected