Skip to content

Getter functions for usm_ndarray are marked const per gh-852 #860

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 24, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions dpctl/apis/include/dpctl4pybind11.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -465,50 +465,50 @@ class usm_ndarray : public py::object
throw py::error_already_set();
}

char *get_data()
char *get_data() const
{
PyObject *raw_o = this->ptr();
PyUSMArrayObject *raw_ar = reinterpret_cast<PyUSMArrayObject *>(raw_o);

return UsmNDArray_GetData(raw_ar);
}

template <typename T> T *get_data()
template <typename T> T *get_data() const
{
return reinterpret_cast<T *>(get_data());
}

int get_ndim()
int get_ndim() const
{
PyObject *raw_o = this->ptr();
PyUSMArrayObject *raw_ar = reinterpret_cast<PyUSMArrayObject *>(raw_o);

return UsmNDArray_GetNDim(raw_ar);
}

const py::ssize_t *get_shape_raw()
const py::ssize_t *get_shape_raw() const
{
PyObject *raw_o = this->ptr();
PyUSMArrayObject *raw_ar = reinterpret_cast<PyUSMArrayObject *>(raw_o);

return UsmNDArray_GetShape(raw_ar);
}

py::ssize_t get_shape(int i)
py::ssize_t get_shape(int i) const
{
auto shape_ptr = get_shape_raw();
return shape_ptr[i];
}

const py::ssize_t *get_strides_raw()
const py::ssize_t *get_strides_raw() const
{
PyObject *raw_o = this->ptr();
PyUSMArrayObject *raw_ar = reinterpret_cast<PyUSMArrayObject *>(raw_o);

return UsmNDArray_GetStrides(raw_ar);
}

py::ssize_t get_size()
py::ssize_t get_size() const
{
PyObject *raw_o = this->ptr();
PyUSMArrayObject *raw_ar = reinterpret_cast<PyUSMArrayObject *>(raw_o);
Expand All @@ -525,7 +525,7 @@ class usm_ndarray : public py::object
return nelems;
}

std::pair<py::ssize_t, py::ssize_t> get_minmax_offsets()
std::pair<py::ssize_t, py::ssize_t> get_minmax_offsets() const
{
PyObject *raw_o = this->ptr();
PyUSMArrayObject *raw_ar = reinterpret_cast<PyUSMArrayObject *>(raw_o);
Expand Down Expand Up @@ -559,7 +559,7 @@ class usm_ndarray : public py::object
return std::make_pair(offset_min, offset_max);
}

sycl::queue get_queue()
sycl::queue get_queue() const
{
PyObject *raw_o = this->ptr();
PyUSMArrayObject *raw_ar = reinterpret_cast<PyUSMArrayObject *>(raw_o);
Expand All @@ -568,23 +568,23 @@ class usm_ndarray : public py::object
return *(reinterpret_cast<sycl::queue *>(QRef));
}

int get_typenum()
int get_typenum() const
{
PyObject *raw_o = this->ptr();
PyUSMArrayObject *raw_ar = reinterpret_cast<PyUSMArrayObject *>(raw_o);

return UsmNDArray_GetTypenum(raw_ar);
}

int get_flags()
int get_flags() const
{
PyObject *raw_o = this->ptr();
PyUSMArrayObject *raw_ar = reinterpret_cast<PyUSMArrayObject *>(raw_o);

return UsmNDArray_GetFlags(raw_ar);
}

int get_elemsize()
int get_elemsize() const
{
PyObject *raw_o = this->ptr();
PyUSMArrayObject *raw_ar = reinterpret_cast<PyUSMArrayObject *>(raw_o);
Expand Down