| 776 | } |
| 777 | |
| 778 | std::pair<size_t, bool> get_ndim_safe(py::handle tensor) { |
| 779 | if (auto p = TensorWrapper::try_cast(tensor.ptr())) { |
| 780 | return {p->m_tensor->shape()->ndim, true}; |
| 781 | } |
| 782 | |
| 783 | try { |
| 784 | return {getattr(tensor, "ndim").cast<size_t>(), true}; |
| 785 | } catch (py::error_already_set& err) { |
| 786 | return {0, false}; |
| 787 | } |
| 788 | } |
| 789 | |
| 790 | py::tuple _unpack_indexes(py::handle inp_hdl, py::tuple tuple_val) { |
| 791 | py::object inp = py::reinterpret_borrow<py::object>(inp_hdl); |
no test coverage detected