| 178 | } |
| 179 | |
| 180 | nb::tuple PyTensor::shape() const { |
| 181 | const auto& dims = tensor_.shape().dims(); |
| 182 | nb::list shape_list; |
| 183 | for (size_t d : dims) { |
| 184 | shape_list.append(static_cast<int64_t>(d)); |
| 185 | } |
| 186 | return nb::tuple(shape_list); |
| 187 | } |
| 188 | |
| 189 | size_t PyTensor::ndim() const { |
| 190 | return tensor_.shape().rank(); |