| 45 | } |
| 46 | |
| 47 | void quantize(Tensor &qt, const Tensor &t, float min, float max) |
| 48 | { |
| 49 | DataType dt = DataType::QASYMM8_SIGNED; |
| 50 | |
| 51 | // Determine the scale |
| 52 | const float scale = (max - min) / 256.0f; |
| 53 | |
| 54 | // Determine the zero-point; using affine equation val = (qval-zerop) * scale |
| 55 | const float zero_point = -128.0f - min / scale; |
| 56 | |
| 57 | QuantizationInfo qinfo(scale, (int32_t)round(zero_point), true); |
| 58 | |
| 59 | // We now have the quantisation info and can configure the quantised tensor |
| 60 | qt.allocator()->init(TensorInfo(t.info()->tensor_shape(), 1, dt, qinfo)); |
| 61 | qt.allocator()->allocate(); |
| 62 | NEQuantizationLayer quantization; |
| 63 | quantization.configure(&t, &qt); |
| 64 | quantization.run(); |
| 65 | } |
| 66 | |
| 67 | void invert_qinfo_offset(Tensor &t) |
| 68 | { |
no test coverage detected