(arr, expected)
| 161 | @check_bytes_allocated |
| 162 | @pytest.mark.parametrize(('arr', 'expected'), multidim_arrays()) |
| 163 | def 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") |
nothing calls this directly
no test coverage detected