We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e98a7d8 commit 61da03fCopy full SHA for 61da03f
dpctl/tensor/_dlpack.pyx
@@ -305,5 +305,18 @@ cpdef usm_ndarray from_dlpack_capsule(object py_caps) except +:
305
306
cpdef from_dlpack(array):
307
"""Constructs `usm_ndarray` from a Python object that implements
308
- `__dlpack__` protocol."""
309
- pass
+ `__dlpack__` protocol.
+ """
310
+ if not hasattr(array, "__dlpack__"):
311
+ raise TypeError(
312
+ "The argument of type {type(array)} does not implement "
313
+ "`__dlpack__` method."
314
+ )
315
+ dlpack_attr = getattr(array, "__dlpack__")
316
+ if not callable(dlpack_attr):
317
318
319
320
321
+ dlpack_capsule = dlpack_attr()
322
+ return from_dlpack_capsule(dlpack_capsule)
0 commit comments