mirror of
https://github.com/ml-explore/mlx.git
synced 2025-12-16 01:49:05 +08:00
Reduce implicit copies in make_array (#874)
1. Move shapes into outputs instead of copying them. 2. Pass primitive by const ref as it is always copied into outputs, which removes a copy when calling make_array.
This commit is contained in:
@@ -645,7 +645,7 @@ void compile_fuse(
|
||||
}
|
||||
}
|
||||
auto compiled_outputs = array::make_arrays(
|
||||
shapes,
|
||||
std::move(shapes),
|
||||
types,
|
||||
std::make_shared<Compiled>(
|
||||
old_outputs.back().primitive().stream(),
|
||||
@@ -738,8 +738,8 @@ std::vector<array> compile_replace(
|
||||
shapes.push_back(o.shape());
|
||||
}
|
||||
}
|
||||
auto real_out =
|
||||
array::make_arrays(shapes, types, a.primitive_ptr(), real_inputs);
|
||||
auto real_out = array::make_arrays(
|
||||
std::move(shapes), types, a.primitive_ptr(), real_inputs);
|
||||
for (int i = 0; i < trace_out.size(); ++i) {
|
||||
trace_to_real.insert({trace_out[i].id(), std::move(real_out[i])});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user