| 343 | |
| 344 | template <typename T> |
| 345 | void get_shape(T list, mx::Shape& shape) { |
| 346 | shape.push_back(check_shape_dim(nb::len(list))); |
| 347 | if (shape.back() > 0) { |
| 348 | auto l = list.begin(); |
| 349 | if (nb::isinstance<nb::list>(*l)) { |
| 350 | return get_shape(nb::cast<nb::list>(*l), shape); |
| 351 | } else if (nb::isinstance<nb::tuple>(*l)) { |
| 352 | return get_shape(nb::cast<nb::tuple>(*l), shape); |
| 353 | } else if (nb::isinstance<mx::array>(*l)) { |
| 354 | auto arr = nb::cast<mx::array>(*l); |
| 355 | for (int i = 0; i < arr.ndim(); i++) { |
| 356 | shape.push_back(arr.shape(i)); |
| 357 | } |
| 358 | return; |
| 359 | } |
| 360 | } |
| 361 | } |
| 362 | |
| 363 | template <typename T> |
| 364 | mx::array array_from_list_impl( |
no test coverage detected