Skip to content

Commit feb51e5

Browse files
authored
Fix big endian handling in totypes (#209)
Previously the dtype was viewed, but an actual dtype conversion needs to happen. Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
1 parent f0fcffb commit feb51e5

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/onnx_ir/_core.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ def tobytes(self) -> bytes:
520520
else:
521521
assert self.dtype.itemsize == array.itemsize, "Bug: The itemsize should match"
522522
if not _IS_LITTLE_ENDIAN:
523-
array = array.view(array.dtype.newbyteorder("<"))
523+
array = array.astype(array.dtype.newbyteorder("<"))
524524
return array.tobytes()
525525

526526

@@ -1110,7 +1110,7 @@ def tobytes(self) -> bytes:
11101110
"""
11111111
array = self.numpy_packed()
11121112
if not _IS_LITTLE_ENDIAN:
1113-
array = array.view(array.dtype.newbyteorder("<"))
1113+
array = array.astype(array.dtype.newbyteorder("<"))
11141114
return array.tobytes()
11151115

11161116

0 commit comments

Comments
 (0)