Skip to content

Commit 0c188f2

Browse files
committed
修复 infinicore.Tensor.data_ptr 的调用问题
1 parent acb75f3 commit 0c188f2

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

python/infinicore/tensor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def ndim(self):
3232
return self._underlying.ndim
3333

3434
def data_ptr(self):
35-
return self._underlying.data_ptr
35+
return self._underlying.data_ptr()
3636

3737
def size(self, dim=None):
3838
if dim is None:

src/infinicore/pybind11/tensor.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ inline void bind(py::module &m) {
1717
.def_property_readonly("dtype", [](const Tensor &tensor) { return tensor->dtype(); })
1818
.def_property_readonly("device", [](const Tensor &tensor) { return tensor->device(); })
1919

20-
.def("data_ptr", [](const Tensor &tensor) { return tensor->data(); })
20+
.def("data_ptr", [](const Tensor &tensor) { return reinterpret_cast<std::uintptr_t>(tensor->data()); })
2121
.def("size", [](const Tensor &tensor, std::size_t dim) { return tensor->size(dim); })
2222
.def("stride", [](const Tensor &tensor, std::size_t dim) { return tensor->stride(dim); })
2323
.def("numel", [](const Tensor &tensor) { return tensor->numel(); })

0 commit comments

Comments
 (0)