All problems
Mixed Precision Memory Saving
Problem
Compute the bytes saved by storing parameters in half precision instead of full precision: num_params * (full_bytes - half_bytes).
The signature is mixed_precision_saving(num_params, full_bytes=4, half_bytes=2). Return an integer number of bytes.
Hint
Each parameter drops from 4 bytes to 2 bytes in fp16/bf16.
Test cases
case 1
in: [1000000]
expected: 2000000
case 2
in: [1]
expected: 2
case 3
in: [7000000000,4,2]
expected: 14000000000
case 4
in: [1000,2,1]
expected: 1000
Starter codePython
def mixed_precision_saving(num_params, full_bytes=4, half_bytes=2):
# Your code here
pass4 test cases · run your code against them in the editor