Not at all sure how this would work, but the fp8 formats should really have a configurable scale factor when being interpreted as floats.
The scale bias has a default for the e4m3 and e5m2 floats, but there should be a way to specify a different one. I'm not a fan of having a special case, so perhaps something in the Dtype specification could be used?
So the MetaDtype contains a 'scale' field, which is set to 1 for everything except e4m3float (scale=8) and e5m2float (scale=16). Or perhaps set to None for most things as we don't want it to be used (I don't think it's actually useful elsewhere?)
Then a Dtype can be created as dt = Dtype('e4m3float', scale=10) for example. But not sure how this would be converted to a string. Perhaps e4m3float{10} or something similar? We can't have a number at the end as that conflicts with the length.
There's not really any good way to make a general property from this though. You can't say x.e4m3float{10} or anything similar, except using underscores, which is also messy. We could allow it the other way around, with dt(x) for example...
So given an 8 bit bitstring b, the user could write Dtype('e4m3float', scale=6)(b) to get the value with a new scale bias. In practice you'd end up predefining objects such as e4m3_6 = Dtype('e4m3float', scale=6)?
On further investigation I think this isn't needed. The default scales are really part of the format, so it's up to the user to scale the incoming and outgoing values themselves.
Not at all sure how this would work, but the fp8 formats should really have a configurable scale factor when being interpreted as floats.
The scale bias has a default for the e4m3 and e5m2 floats, but there should be a way to specify a different one. I'm not a fan of having a special case, so perhaps something in the Dtype specification could be used?
So the MetaDtype contains a 'scale' field, which is set to 1 for everything except e4m3float (scale=8) and e5m2float (scale=16). Or perhaps set to None for most things as we don't want it to be used (I don't think it's actually useful elsewhere?)
Then a Dtype can be created as
dt = Dtype('e4m3float', scale=10)
for example. But not sure how this would be converted to a string. Perhapse4m3float{10}
or something similar? We can't have a number at the end as that conflicts with the length.There's not really any good way to make a general property from this though. You can't say
x.e4m3float{10}
or anything similar, except using underscores, which is also messy. We could allow it the other way around, withdt(x)
for example...So given an 8 bit bitstring
b
, the user could writeDtype('e4m3float', scale=6)(b)
to get the value with a new scale bias. In practice you'd end up predefining objects such ase4m3_6 = Dtype('e4m3float', scale=6)
?