Skip to content
DeepForgeby svx
All problems
MediumDeep Learningdl-353

Outlier Channel Mixed Storage

Problem

Account for outlier channels in mixed-precision storage. Channels whose max absolute value exceeds threshold are stored at high_bits, the rest at low_bits, each channel holding elements_per_channel values. Return [num_high_channels, total_bits].

The signature is outlier_channel_storage(channel_max_abs, threshold, low_bits=4, high_bits=8, elements_per_channel=1).

Hint

Keeping a few outlier channels wide is cheaper than widening the whole tensor.

Test cases

case 1
in: [[1,5,0.5,20],4,4,8,1]
expected: [2,24]
case 2
in: [[1,2],10,4,16,100]
expected: [0,800]
case 3
in: [[5],1,4,8,10]
expected: [1,80]
case 4
in: [[0,0],-1,8,16,1]
expected: [2,32]
Starter codePython
def outlier_channel_storage(channel_max_abs, threshold, low_bits=4, high_bits=8, elements_per_channel=1):
    # Your code here
    pass

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