All problems
Per-Channel Quant Scale
Problem
Compute per-channel symmetric int8 quantization scales: for each row (channel) of the weight matrix, return max(abs(row)) / qmax.
The signature is per_channel_quant_scale(weights, qmax=127).
Hint
Per-channel scales give each output channel its own dynamic range.
Test cases
case 1
in: [[[1,-2],[4,4]]]
expected: [0.0157480315,0.031496063]
case 2
in: [[[0,0]]]
expected: [0]
case 3
in: [[[3,4],[-1,0.5]]]
expected: [0.031496063,0.0078740157]
case 4
in: [[[1,0],[0,8]],100]
expected: [0.01,0.08]
Starter codePython
def per_channel_quant_scale(weights, qmax=127):
# Your code here
pass4 test cases · run your code against them in the editor