Skip to content

Commit 202562c

Browse files
committedAug 30, 2024·
array
"
1 parent 6a70ac5 commit 202562c

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed
 

‎onnx_array_api/array_api/_onnx_common.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@
33
import numpy as np
44
from onnx import TensorProto
55

6-
with warnings.catch_warnings():
7-
warnings.simplefilter("ignore")
8-
from numpy.array_api._array_object import Array
6+
try:
7+
with warnings.catch_warnings():
8+
warnings.simplefilter("ignore")
9+
from numpy.array_api._array_object import Array
10+
except ImportError:
11+
Array = None
912
from ..npx.npx_types import (
1013
DType,
1114
ElemType,
@@ -107,7 +110,7 @@ def asarray(
107110
v = TEagerTensor(np.array(a))
108111
elif isinstance(a, np.ndarray):
109112
v = TEagerTensor(a)
110-
elif isinstance(a, Array):
113+
elif Array and isinstance(a, Array):
111114
v = TEagerTensor(np.asarray(a))
112115
else:
113116
raise RuntimeError(f"Unexpected type {type(a)} for the first input.")

0 commit comments

Comments
 (0)
Please sign in to comment.