mirror of
https://github.com/ml-explore/mlx.git
synced 2025-06-29 21:11:16 +08:00
Make eval just wait if all arrays are scheduled (#1368)
This commit is contained in:
parent
cdb59faea6
commit
e64349bbdd
@ -186,10 +186,35 @@ array eval_impl(std::vector<array> outputs, bool async) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void async_eval(std::vector<array> outputs) {
|
void async_eval(std::vector<array> outputs) {
|
||||||
|
if (outputs.empty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (std::none_of(outputs.begin(), outputs.end(), [](array& x) {
|
||||||
|
return x.status() == array::Status::unscheduled;
|
||||||
|
})) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
eval_impl(std::move(outputs), true);
|
eval_impl(std::move(outputs), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void eval(std::vector<array> outputs) {
|
void eval(std::vector<array> outputs) {
|
||||||
|
if (outputs.empty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (std::none_of(outputs.begin(), outputs.end(), [](array& x) {
|
||||||
|
return x.status() == array::Status::unscheduled;
|
||||||
|
})) {
|
||||||
|
for (auto& x : outputs) {
|
||||||
|
if (!x.is_available()) {
|
||||||
|
x.event().wait();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
eval_impl(std::move(outputs), false).event().wait();
|
eval_impl(std::move(outputs), false).event().wait();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user