Skip to content
DeepForgeby svx
All problems
MediumDeep Learningdl-322

FP8 E5M2 Value Decode

Problem

Decode an 8-bit FP8 E5M2 value. The layout is 1 sign bit, 5 exponent bits with bias 15, and 2 mantissa bits; subnormals use 2^-14 with no implicit leading 1. Return the decoded float for the integer bit pattern bits.

The signature is fp8_e5m2_decode(bits).

Hint

E5M2 trades mantissa bits for exponent range compared with E4M3.

Test cases

case 1
in: [0]
expected: 0
case 2
in: [56]
expected: 0.5
case 3
in: [80]
expected: 32
case 4
in: [1]
expected: 0.0000152587890625
case 5
in: [192]
expected: -2
Starter codePython
def fp8_e5m2_decode(bits):
    # Your code here
    pass

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