-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Fixes s390x byteswapping issues #6183
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1563,6 +1563,16 @@ | |
""" | ||
return mapping.TENSOR_TYPE_MAP[tensor_dtype].storage_dtype | ||
|
||
def tensor_dtype_to_storage_np_dtype(tensor_dtype: int) -> int: | ||
"""Convert a TensorProto's data_type to corresponding data_type for raw storage. | ||
|
||
Check warning Code scanning / lintrunner RUFF/W293 Warning
Blank line contains whitespace.
See https://docs.astral.sh/ruff/rules/blank-line-with-whitespace Check warning Code scanning / lintrunner EDITORCONFIG-CHECKER/editorconfig Warning
Trailing whitespace
|
||
Args: | ||
tensor_dtype: TensorProto's data_type | ||
|
||
Check warning Code scanning / lintrunner RUFF/W293 Warning
Blank line contains whitespace.
See https://docs.astral.sh/ruff/rules/blank-line-with-whitespace Check warning Code scanning / lintrunner EDITORCONFIG-CHECKER/editorconfig Warning
Trailing whitespace
|
||
Returns: | ||
numpy's data_type for the raw storage | ||
""" | ||
return mapping.TENSOR_TYPE_MAP[tensor_dtype].storage_np_dtype | ||
Check failure Code scanning / lintrunner MYPY/return-value Error
Incompatible return value type (got "dtype[Any]", expected "int")
To disable, use # type: ignore[return-value]
|
||
|
||
def tensor_dtype_to_string(tensor_dtype: int) -> str: | ||
"""Get the name of given TensorProto's data_type. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need this to be public?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question. I guess it could be argued that if a user were creating a raw tensor then having that information could help in determining whether or not the storage has the correct number of elements.