diff --git a/cuvec/include/cuvec_pybind11.cuh b/cuvec/include/cuvec_pybind11.cuh index 08e5886..b466ebd 100644 --- a/cuvec/include/cuvec_pybind11.cuh +++ b/cuvec/include/cuvec_pybind11.cuh @@ -29,8 +29,9 @@ PYBIND11_MAKE_OPAQUE(NDCuVec); pybind11::class_>(m, PYBIND11_TOSTRING(NDCuVec_##typechar)) \ .def(pybind11::init<>()) \ .def(pybind11::init>()) \ - .def("reshape", &NDCuVec::reshape) \ - .def("shape", [](const NDCuVec &v) { return v.shape; }) \ - .def("address", [](NDCuVec &v) { return (size_t)v.vec.data(); }) + .def_property( \ + "shape", [](const NDCuVec *v) { return &(v->shape); }, &NDCuVec::reshape) \ + .def_property_readonly("address", \ + [](const NDCuVec *v) { return (size_t)v->vec.data(); }) #endif // _CUVEC_PYBIND11_H_ diff --git a/cuvec/pybind11.py b/cuvec/pybind11.py index 578e206..6abef8a 100644 --- a/cuvec/pybind11.py +++ b/cuvec/pybind11.py @@ -44,16 +44,16 @@ def __init__(self, typechar: str, shape: Shape, cuvec=None): @property def shape(self) -> tuple: - return tuple(self.cuvec.shape()) + return tuple(self.cuvec.shape) @shape.setter def shape(self, shape: Shape): shape = cu.Shape(shape if isinstance(shape, Sequence) else (shape,)) - self.cuvec.reshape(shape) + self.cuvec.shape = shape @property def address(self) -> int: - return self.cuvec.address() + return self.cuvec.address Pybind11Vector.vec_types = {np.dtype(c): partial(Pybind11Vector, c) for c in typecodes}