Skip to content
DeepForgeby svx
All problems
EasyDeep Learningdl-356

Dequant Fusion Cost

Problem

Compute memory traffic with and without dequantization fusion. Unfused traffic is quant_bytes + 2*dequant_bytes (write then re-read); fused traffic is quant_bytes. Return [unfused_bytes, fused_bytes, saved_bytes].

The signature is dequant_fusion_cost(quant_bytes, dequant_bytes).

Hint

Fusing dequant into the consumer avoids materializing the fp16 tensor in memory.

Test cases

case 1
in: [100,400]
expected: [900,100,800]
case 2
in: [0,100]
expected: [200,0,200]
case 3
in: [50,0]
expected: [50,50,0]
case 4
in: [100,100]
expected: [300,100,200]
Starter codePython
def dequant_fusion_cost(quant_bytes, dequant_bytes):
    # Your code here
    pass

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