MCPcopy Create free account
hub / github.com/ml-explore/mlx / mlx_save_helper

Function mlx_save_helper

python/src/load.cpp:404–421  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

402};
403
404void 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
423void mlx_savez_helper(
424 nb::object file_,

Callers

nothing calls this directly

Calls 3

is_str_or_pathFunction · 0.85
saveFunction · 0.85
is_ostream_objectFunction · 0.85

Tested by

no test coverage detected