All problems
Fake-Quant Forward Value
Problem
Compute the fake-quantization forward value: q = clamp(round(x/scale) + zero_point, qmin, qmax), then dequantize with (q - zero_point) * scale. Apply element-wise to the list x and return the list of dequantized values.
The signature is fake_quant_forward(x, scale, zero_point, qmin, qmax).
Hint
Fake quantization simulates the rounding error while keeping the tensor in floating point.
Test cases
case 1
in: [[1.2,-1.2],1,0,-128,127]
expected: [1,-1]
case 2
in: [[1000],1,0,-128,127]
expected: [127]
case 3
in: [[2.5],0.5,0,0,15]
expected: [2.5]
case 4
in: [[0,5],1,8,0,15]
expected: [0,5]
Starter codePython
def fake_quant_forward(x, scale, zero_point, qmin, qmax):
# Your code here
pass4 test cases · run your code against them in the editor