Skip to content

Commit f45710f

Browse files
Merge pull request #860 from IntelPython/fix/gh-852-const-version
Getter functions for usm_ndarray are marked const per gh-852
2 parents 809cdf4 + 3785914 commit f45710f

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

dpctl/apis/include/dpctl4pybind11.hpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -465,50 +465,50 @@ class usm_ndarray : public py::object
465465
throw py::error_already_set();
466466
}
467467

468-
char *get_data()
468+
char *get_data() const
469469
{
470470
PyObject *raw_o = this->ptr();
471471
PyUSMArrayObject *raw_ar = reinterpret_cast<PyUSMArrayObject *>(raw_o);
472472

473473
return UsmNDArray_GetData(raw_ar);
474474
}
475475

476-
template <typename T> T *get_data()
476+
template <typename T> T *get_data() const
477477
{
478478
return reinterpret_cast<T *>(get_data());
479479
}
480480

481-
int get_ndim()
481+
int get_ndim() const
482482
{
483483
PyObject *raw_o = this->ptr();
484484
PyUSMArrayObject *raw_ar = reinterpret_cast<PyUSMArrayObject *>(raw_o);
485485

486486
return UsmNDArray_GetNDim(raw_ar);
487487
}
488488

489-
const py::ssize_t *get_shape_raw()
489+
const py::ssize_t *get_shape_raw() const
490490
{
491491
PyObject *raw_o = this->ptr();
492492
PyUSMArrayObject *raw_ar = reinterpret_cast<PyUSMArrayObject *>(raw_o);
493493

494494
return UsmNDArray_GetShape(raw_ar);
495495
}
496496

497-
py::ssize_t get_shape(int i)
497+
py::ssize_t get_shape(int i) const
498498
{
499499
auto shape_ptr = get_shape_raw();
500500
return shape_ptr[i];
501501
}
502502

503-
const py::ssize_t *get_strides_raw()
503+
const py::ssize_t *get_strides_raw() const
504504
{
505505
PyObject *raw_o = this->ptr();
506506
PyUSMArrayObject *raw_ar = reinterpret_cast<PyUSMArrayObject *>(raw_o);
507507

508508
return UsmNDArray_GetStrides(raw_ar);
509509
}
510510

511-
py::ssize_t get_size()
511+
py::ssize_t get_size() const
512512
{
513513
PyObject *raw_o = this->ptr();
514514
PyUSMArrayObject *raw_ar = reinterpret_cast<PyUSMArrayObject *>(raw_o);
@@ -525,7 +525,7 @@ class usm_ndarray : public py::object
525525
return nelems;
526526
}
527527

528-
std::pair<py::ssize_t, py::ssize_t> get_minmax_offsets()
528+
std::pair<py::ssize_t, py::ssize_t> get_minmax_offsets() const
529529
{
530530
PyObject *raw_o = this->ptr();
531531
PyUSMArrayObject *raw_ar = reinterpret_cast<PyUSMArrayObject *>(raw_o);
@@ -559,7 +559,7 @@ class usm_ndarray : public py::object
559559
return std::make_pair(offset_min, offset_max);
560560
}
561561

562-
sycl::queue get_queue()
562+
sycl::queue get_queue() const
563563
{
564564
PyObject *raw_o = this->ptr();
565565
PyUSMArrayObject *raw_ar = reinterpret_cast<PyUSMArrayObject *>(raw_o);
@@ -568,23 +568,23 @@ class usm_ndarray : public py::object
568568
return *(reinterpret_cast<sycl::queue *>(QRef));
569569
}
570570

571-
int get_typenum()
571+
int get_typenum() const
572572
{
573573
PyObject *raw_o = this->ptr();
574574
PyUSMArrayObject *raw_ar = reinterpret_cast<PyUSMArrayObject *>(raw_o);
575575

576576
return UsmNDArray_GetTypenum(raw_ar);
577577
}
578578

579-
int get_flags()
579+
int get_flags() const
580580
{
581581
PyObject *raw_o = this->ptr();
582582
PyUSMArrayObject *raw_ar = reinterpret_cast<PyUSMArrayObject *>(raw_o);
583583

584584
return UsmNDArray_GetFlags(raw_ar);
585585
}
586586

587-
int get_elemsize()
587+
int get_elemsize() const
588588
{
589589
PyObject *raw_o = this->ptr();
590590
PyUSMArrayObject *raw_ar = reinterpret_cast<PyUSMArrayObject *>(raw_o);

0 commit comments

Comments
 (0)