We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 6a70ac5 commit 202562cCopy full SHA for 202562c
onnx_array_api/array_api/_onnx_common.py
@@ -3,9 +3,12 @@
3
import numpy as np
4
from onnx import TensorProto
5
6
-with warnings.catch_warnings():
7
- warnings.simplefilter("ignore")
8
- from numpy.array_api._array_object import Array
+try:
+ with warnings.catch_warnings():
+ warnings.simplefilter("ignore")
9
+ from numpy.array_api._array_object import Array
10
+except ImportError:
11
+ Array = None
12
from ..npx.npx_types import (
13
DType,
14
ElemType,
@@ -107,7 +110,7 @@ def asarray(
107
110
v = TEagerTensor(np.array(a))
108
111
elif isinstance(a, np.ndarray):
109
112
v = TEagerTensor(a)
- elif isinstance(a, Array):
113
+ elif Array and isinstance(a, Array):
114
v = TEagerTensor(np.asarray(a))
115
else:
116
raise RuntimeError(f"Unexpected type {type(a)} for the first input.")
0 commit comments