| 402 | }; |
| 403 | |
| 404 | void mlx_save_helper(nb::object file, mx::array a) { |
| 405 | if (is_str_or_path(file)) { |
| 406 | auto file_str = nb::cast<std::string>(nb::str(file)); |
| 407 | mx::save(file_str, a); |
| 408 | return; |
| 409 | } else if (is_ostream_object(file)) { |
| 410 | auto writer = std::make_shared<PyFileWriter>(file); |
| 411 | { |
| 412 | nb::gil_scoped_release gil; |
| 413 | mx::save(writer, a); |
| 414 | } |
| 415 | |
| 416 | return; |
| 417 | } |
| 418 | |
| 419 | throw std::invalid_argument( |
| 420 | "[save] Input must be a file-like object, or string"); |
| 421 | } |
| 422 | |
| 423 | void mlx_savez_helper( |
| 424 | nb::object file_, |
nothing calls this directly
no test coverage detected