mirror of
https://github.com/ml-explore/mlx.git
synced 2025-12-16 01:49:05 +08:00
contiguous op / prim (#1612)
This commit is contained in:
@@ -107,22 +107,13 @@ void save(std::shared_ptr<io::Writer> out_stream, array a) {
|
||||
////////////////////////////////////////////////////////
|
||||
// Check array
|
||||
|
||||
a = contiguous(a, true);
|
||||
a.eval();
|
||||
|
||||
if (a.nbytes() == 0) {
|
||||
throw std::invalid_argument("[save] cannot serialize an empty array");
|
||||
}
|
||||
|
||||
if (!(a.flags().row_contiguous || a.flags().col_contiguous)) {
|
||||
a = reshape(flatten(a), a.shape());
|
||||
a.eval();
|
||||
}
|
||||
// Check once more in-case the above ops change
|
||||
if (!(a.flags().row_contiguous || a.flags().col_contiguous)) {
|
||||
throw std::invalid_argument(
|
||||
"[save] can only serialize row or col contiguous arrays");
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////
|
||||
// Check file
|
||||
if (!out_stream->good() || !out_stream->is_open()) {
|
||||
|
||||
Reference in New Issue
Block a user