Skip to content

Commit

Permalink
Merge pull request #860 from IntelPython/fix/gh-852-const-version
Browse files Browse the repository at this point in the history
Getter functions for usm_ndarray are marked const per gh-852
  • Loading branch information
oleksandr-pavlyk committed Jul 24, 2022
2 parents 809cdf4 + 3785914 commit f45710f
Showing 1 changed file with 12 additions and 12 deletions.
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

0 comments on commit f45710f

Please sign in to comment.