MCPcopy Create free account
hub / github.com/apache/arrow / test_array_to_tensor_dlpack

Function test_array_to_tensor_dlpack

python/pyarrow/tests/test_dlpack.py:163–170  ·  view source on GitHub ↗
(arr, expected)

Source from the content-addressed store, hash-verified

161@check_bytes_allocated
162@pytest.mark.parametrize(('arr', 'expected'), multidim_arrays())
163def test_array_to_tensor_dlpack(arr, expected):
164 tensor = arr.to_tensor()
165 # A Tensor sharing an Array buffer is immutable, so it can only be exported
166 # through the versioned DLPack protocol.
167 assert not tensor.is_mutable
168 result = np.from_dlpack(DLPackForwarder(tensor, max_version=(1, 0)))
169 np.testing.assert_array_equal(result, expected, strict=True)
170 assert tensor.__dlpack_device__() == (1, 0)
171
172
173@requires_numpy_version("2.1.0")

Callers

nothing calls this directly

Calls 2

DLPackForwarderClass · 0.85
__dlpack_device__Method · 0.45

Tested by

no test coverage detected