Conversation
A name such as f32e8m0 was parsed as float32 because 0 was treated as a missing width. The same substitution turned f16e0m10 into float16. Signed-off-by: Sasha Mitchell <sash.t.mitchell@gmail.com>
|
| try: | ||
| t.type_id = _type2id[t] | ||
| except KeyError: | ||
| raise ValueError(f"Unsupported type name: {name}") from None |
There was a problem hiding this comment.
Rejected dtype accepted on retry Parsing
f32e8m0 or f16e0m10 raises ValueError on the first call, but constructing the temporary DType has already cached it. A second dtype(name) call returns that unregistered type with type_id=None instead of rejecting it. Cache a parsed type only after its registered-type lookup succeeds, and test repeated calls.
| try: | ||
| t.type_id = _type2id[t] | ||
| except KeyError: | ||
| raise ValueError(f"Unsupported type name: {name}") from None |
There was a problem hiding this comment.
Validation error lacks context The new
ValueError says only Unsupported type name: {name}. The repository’s error-message directive requires user-facing errors to identify the input, show expected versus actual values, and end as a complete sentence. This message gives no supported float widths or examples and lacks a final period; add that guidance so users can correct the name.
Rule Used: Error messages must name the affected parameter/operator, show expected vs. actual values, and end as a complete sentence. Not "is 5" but "got 5 channels, expected 1 or 3.". Use make_string(...) for C++ concatenation; f-strings in Python. (source)
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Category:
Bug fix (non-breaking change which fixes an issue)
Description:
DType.parse("f32e8m0")came back as float32.DType.parse("f16e0m10")came back as float16.The float constructor used
width or default. A written 0 is falsy, so it was replaced with the IEEE default (23 significand bits, or 5 exponent bits). Those names are not registered DALI types. The parser now raises ValueError, the same as any other unknown name. Omitted widths still take the IEEE default, sof32andf16are unchanged.Additional information:
Affected modules and functionalities:
nvidia.dali.experimental.dynamic.DType.parseanddtype().Key points relevant for the review:
Only a missing width (
None) takes the default. A written 0 stays 0, then fails the registered-type lookup.Tests:
dali/test/python/experimental_mode/test_type.py:test_explicit_zero_float_field_is_not_replaced_with_the_defaultOn main the test fails because
f32e8m0is accepted as float32. With this change it passes.Checklist
Documentation
DALI team only
Requirements
REQ IDs: N/A
JIRA TASK: N/A