diff --git a/python/src/load.cpp b/python/src/load.cpp index 2590b1821..f6609faea 100644 --- a/python/src/load.cpp +++ b/python/src/load.cpp @@ -244,6 +244,8 @@ DictOrArray mlx_load_helper( std::string fname; if (py::isinstance(file)) { fname = py::cast(file); + } else if (is_istream_object(file)) { + fname = file.attr("name").cast(); } else { throw std::invalid_argument( "[load] Input must be a file-like object, or string");