-
Notifications
You must be signed in to change notification settings - Fork 156
Add fp8/fp6/fp4 types #158
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
1ab3fb1
add fp8/fp6/fp4 types
leofang 46122b1
incorporate review comments to ensure we allow packed layouts for now
leofang ed3015f
Merge branch 'main' into exotic
leofang a0a1597
add notes on endianness of packed data; add is_padded bit mask
leofang File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -157,6 +157,26 @@ typedef enum { | |
| kDLComplex = 5U, | ||
| /*! \brief boolean */ | ||
| kDLBool = 6U, | ||
| /*! \brief FP8 data types */ | ||
| kDLFloat8_e3m4 = 7U, | ||
| kDLFloat8_e4m3 = 8U, | ||
| kDLFloat8_e4m3b11fnuz = 9U, | ||
| kDLFloat8_e4m3fn = 10U, | ||
|
Comment on lines
+162
to
+164
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. One quick question: what's the spec difference between
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. https://github.com/jax-ml/ml_dtypes (linking there may make sense) |
||
| kDLFloat8_e4m3fnuz = 11U, | ||
| kDLFloat8_e5m2 = 12U, | ||
| kDLFloat8_e5m2fnuz = 13U, | ||
| kDLFloat8_e8m0fnu = 14U, | ||
leofang marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| /*! \brief FP6 data types | ||
| * Setting bits != 6 is currently unspecified, and the producer must ensure it is set | ||
| * while the consumer must stop importing if the value is unexpected. | ||
| */ | ||
| kDLFloat6_e2m3fn = 15U, | ||
| kDLFloat6_e3m2fn = 16U, | ||
leofang marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| /*! \brief FP4 data types | ||
| * Setting bits != 4 is currently unspecified, and the producer must ensure it is set | ||
| * while the consumer must stop importing if the value is unexpected. | ||
| */ | ||
| kDLFloat4_e2m1fn = 17U, | ||
leofang marked this conversation as resolved.
Show resolved
Hide resolved
leofang marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } DLDataTypeCode; | ||
|
|
||
| /*! | ||
|
|
@@ -170,6 +190,12 @@ typedef enum { | |
| * - int8: type_code = 0, bits = 8, lanes = 1 | ||
| * - std::complex<float>: type_code = 5, bits = 64, lanes = 1 | ||
| * - bool: type_code = 6, bits = 8, lanes = 1 (as per common array library convention, the underlying storage size of bool is 8 bits) | ||
| * - float8_e4m3: type_code = 8, bits = 8, lanes = 1 (packed in memory) | ||
| * - float6_e3m2fn: type_code = 16, bits = 6, lanes = 1 (packed in memory) | ||
| * - float4_e2m1fn: type_code = 17, bits = 4, lanes = 1 (packed in memory) | ||
| * | ||
| * When a sub-byte type is packed, DLPack requires the data to be in little bit-endian, i.e., | ||
| * for a packed data set D ((D >> (i * bits)) && bit_mask) stores the i-th element. | ||
| */ | ||
| typedef struct { | ||
| /*! | ||
|
|
@@ -280,6 +306,14 @@ typedef struct DLManagedTensor { | |
| */ | ||
| #define DLPACK_FLAG_BITMASK_IS_COPIED (1UL << 1UL) | ||
|
|
||
| /* | ||
| * \brief bit mask to indicate that whether a sub-byte type is packed or padded. | ||
| * | ||
| * The default for sub-byte types (ex: fp4/fp6) is assumed packed. This flag can | ||
| * be set by the producer to signal that a tensor of sub-byte type is padded. | ||
| */ | ||
| #define DLPACK_FLAG_BITMASK_IS_SUBBYTE_TYPE_PADDED (1UL << 2UL) | ||
|
|
||
| /*! | ||
| * \brief A versioned and managed C Tensor object, manage memory of DLTensor. | ||
| * | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.