| 167 | } |
| 168 | |
| 169 | Tensor from_dlpack(const DLManagedTensor *src) { |
| 170 | Device device = get_hmp_device(src->dl_tensor.device); |
| 171 | ScalarType stype = to_scalar_type(src->dl_tensor.dtype); |
| 172 | DataPtr dp{src->dl_tensor.data, device}; |
| 173 | SizeArray shape{src->dl_tensor.shape, |
| 174 | src->dl_tensor.shape + src->dl_tensor.ndim}; |
| 175 | if (!src->dl_tensor.strides) { |
| 176 | return from_buffer({src->dl_tensor.data, device}, stype, shape); |
| 177 | } |
| 178 | SizeArray strides{src->dl_tensor.strides, |
| 179 | src->dl_tensor.strides + src->dl_tensor.ndim}; |
| 180 | return from_buffer({src->dl_tensor.data, device}, stype, shape, strides); |
| 181 | } |
| 182 | } // namespace hmp |
no test coverage detected