Skip to content

Commit f32b0cd

Browse files
Use the underlying memory pointer to determine where memory resides in ToDlPack (#1093)
* Use the underlying memory pointer to determine where memory resides For tensor slices, ToDlPack was previously incorrectly assigning the device_type because Data() pointed to the offset. When using MATX_MANAGED_MEMORY, cuPointerGetAttributes cannot tell the difference between CPU and GPU memory * Fixup - add const method to GetStorage() * Revert "Fixup - add const method to GetStorage()" This reverts commit c4314f6. * Add const to GetStorage call
1 parent 4b43915 commit f32b0cd

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

include/matx/core/tensor.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1470,8 +1470,9 @@ MATX_LOOP_UNROLL
14701470
t->device.device_id = 0;
14711471

14721472
// Determine where this memory resides
1473-
auto kind = GetPointerKind(this->Data());
1474-
[[maybe_unused]] auto mem_res = cuPointerGetAttributes(sizeof(attr)/sizeof(attr[0]), attr, data, reinterpret_cast<CUdeviceptr>(this->Data()));
1473+
void *data_ptr = const_cast<tensor_t*>(this)->GetStorage().data();
1474+
auto kind = GetPointerKind(data_ptr);
1475+
[[maybe_unused]] auto mem_res = cuPointerGetAttributes(sizeof(attr)/sizeof(attr[0]), attr, data, reinterpret_cast<CUdeviceptr>(data_ptr));
14751476
MATX_ASSERT_STR_EXP(mem_res, CUDA_SUCCESS, matxCudaError, "Error returned from cuPointerGetAttributes");
14761477
if (kind == MATX_INVALID_MEMORY) {
14771478
if (mem_type == CU_MEMORYTYPE_DEVICE) {

0 commit comments

Comments
 (0)