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:
Cheng
2024-03-22 22:29:16 +09:00
committed by GitHub
parent 44390bd3d0
commit f0ae00da12
5 changed files with 18 additions and 14 deletions

View File

@@ -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])});
}