Skip to content
DeepForgeby svx
All problems
MediumComputer Visioncv-285

Int8 Conv Output Scale

Problem

Compute the affine quantization parameters for int8 tensors.

scale = (fp_max - fp_min) / 255 and zero_point = round(-fp_min / scale). Return [round(scale, 6), zero_point].

Test cases

case 1
in: [-1,1]
expected: [0.007843,128]
case 2
in: [0,6]
expected: [0.023529,0]
case 3
in: [-3,3]
expected: [0.023529,128]
case 4
in: [0,255]
expected: [1,0]
Starter codePython
def int8_scale(fp_min, fp_max):
    # Your code here
    pass

4 test cases · run your code against them in the editor