Forward ``__dlpack__`` to a wrapped object with forced keyword arguments. Consumers such as ``np.from_dlpack`` do not expose every ``__dlpack__`` keyword, so this makes them reachable from a consumer's point of view.
| 52 | |
| 53 | |
| 54 | class DLPackForwarder: |
| 55 | """Forward ``__dlpack__`` to a wrapped object with forced keyword arguments. |
| 56 | |
| 57 | Consumers such as ``np.from_dlpack`` do not expose every ``__dlpack__`` |
| 58 | keyword, so this makes them reachable from a consumer's point of view. |
| 59 | """ |
| 60 | |
| 61 | def __init__(self, obj, **forced): |
| 62 | self._obj = obj |
| 63 | self._forced = forced |
| 64 | |
| 65 | def __dlpack__(self, **kwargs): |
| 66 | return self._obj.__dlpack__(**{**kwargs, **self._forced}) |
| 67 | |
| 68 | def __dlpack_device__(self): |
| 69 | return self._obj.__dlpack_device__() |
| 70 | |
| 71 | |
| 72 | def check_bytes_allocated(f): |
no outgoing calls