MCPcopy Create free account
hub / github.com/BabitMF/bmf / from_dlpack

Function from_dlpack

bmf/hmp/src/dataexport/data_export.cpp:169–181  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

167}
168
169Tensor 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

Callers 1

tensor_from_dlpackFunction · 0.85

Calls 3

get_hmp_deviceFunction · 0.85
to_scalar_typeFunction · 0.85
from_bufferFunction · 0.85

Tested by

no test coverage detected