File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -739,9 +739,13 @@ py::object HalDevice::CreateDLPackCapsule(HalBufferView& buffer_view,
739739 " Cannot export device buffer" );
740740 static_assert (sizeof (dl_tensor.data ) >=
741741 sizeof (external_buffer.handle .device_allocation .ptr ));
742+ // Set the data pointer to the offset, and the byte_offset to 0.
743+ // This SHOULD not be required, but some backends (torch GPU for example),
744+ // ignore the byte_offset entirely.
742745 dl_tensor.data =
743- reinterpret_cast <void *>(external_buffer.handle .device_allocation .ptr );
744- dl_tensor.byte_offset = offset;
746+ reinterpret_cast <uint8_t *>(external_buffer.handle .device_allocation .ptr ) +
747+ offset;
748+ dl_tensor.byte_offset = 0 ;
745749
746750 // Create and return capsule.
747751 PyObject* capsule = PyCapsule_New (static_cast <DLManagedTensor*>(tensor.get ()),
You can’t perform that action at this time.
0 commit comments