MCPcopy Create free account
hub / github.com/ARM-software/ComputeLibrary / quantize

Function quantize

examples/neon_gemm_s8_f32.cpp:47–65  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

45}
46
47void 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
67void invert_qinfo_offset(Tensor &t)
68{

Callers 5

mainFunction · 0.70
quantizeMethod · 0.50
quantize_qasymm8Function · 0.50
quantize_qasymm8_signedFunction · 0.50
quantize_and_fill_tensorFunction · 0.50

Calls 8

roundFunction · 0.50
TensorInfoClass · 0.50
initMethod · 0.45
allocatorMethod · 0.45
infoMethod · 0.45
allocateMethod · 0.45
configureMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected