Skip to content

Commit 3f06e0e

Browse files
committed
Handle int64
1 parent f202e85 commit 3f06e0e

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

onnxscript/ir/_convenience/_constructors.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,16 @@ def tensor(
9595
# Plain Python object
9696
if dtype is not None:
9797
numpy_dtype = dtype.numpy()
98+
elif isinstance(value, int) and not isinstance(value, bool):
99+
# Specify int64 for ints because on Windows this may be int32
100+
numpy_dtype = np.dtype(np.int64)
98101
elif isinstance(value, float):
99102
# If the value is a single float, we use np.float32 as the default dtype
100103
numpy_dtype = np.dtype(np.float32)
104+
elif isinstance(value, Sequence) and all(
105+
(isinstance(elem, int) and not isinstance(value, bool)) for elem in value
106+
):
107+
numpy_dtype = np.dtype(np.int64)
101108
elif isinstance(value, Sequence) and all(isinstance(elem, float) for elem in value):
102109
# If the value is a sequence of floats, we use np.float32 as the default dtype
103110
numpy_dtype = np.dtype(np.float32)

0 commit comments

Comments
 (0)