Skip to content
DeepForgeby svx
All problems
EasyDeep Learningdl-058

Int8 Quantization Scale

Problem

Compute a symmetric int8 quantization scale: max_abs / qmax, where qmax defaults to 127.

The signature is int8_scale(max_abs, qmax=127).

Hint

One scale maps the largest magnitude to the largest int8 code.

Test cases

case 1
in: [1]
expected: 0.0078740157
case 2
in: [2.55]
expected: 0.0200787402
case 3
in: [0]
expected: 0
case 4
in: [127,127]
expected: 1
Starter codePython
def int8_scale(max_abs, qmax=127):
    # Your code here
    pass

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