Make sure that cupy/numpy Array objects can be composed using asarray on the Array API spec
@@ -77,6 +77,10 @@ def asarray(
# Give a better error message in this case. NumPy would convert this
# to an object array. TODO: This won't handle large integers in lists.
raise OverflowError("Integer out of bounds for array dtypes")
+ if isinstance(obj, (list, tuple)):
+ # Make sure that sequences containing numpy or cupy array API objects
+ # can be concatenated successfully. See #6367
+ obj = [x._array if hasattr(x, '_array') else x for x in obj]
prev_device = runtime.getDevice()
try:
runtime.setDevice(device.id)
