jcf94 commented on a change in pull request #6348:
URL: https://github.com/apache/incubator-tvm/pull/6348#discussion_r479847372
##########
File path: src/auto_scheduler/compute_dag.cc
##########
@@ -812,16 +813,24 @@ State ComputeDAG::InferBound(const State& state) const {
Array<State> ComputeDAG::InferBound(const Array<State>& states) const {
Array<State> out_states;
- // TODO(jcf94, merrymercy): Use parallel_for to run this in parallel
- for (const auto& state : states) {
+ out_states.reserve(states.size());
+ std::mutex m;
+
+ support::parallel_for(0, states.size(), [this, &states, &out_states, &m](int
i) {
State out_state;
try {
- out_state = this->InferBound(state);
+ out_state = this->InferBound(states[i]);
} catch (dmlc::Error& e) {
- LOG(WARNING) << "InferBound fails on the state:\n" << state << "\n" <<
e.what() << std::endl;
+ LOG(WARNING) << "InferBound fails on the state:\n"
+ << states[i] << "\n"
+ << "with: " << e.what() << std::endl;
}
- out_states.push_back(std::move(out_state));
- }
+ if (out_state.defined()) {
+ std::unique_lock<std::mutex> l(m);
Review comment:
Our original implementation in Ansor repo just worked in this way, while
if there's any inferbound failure the `out_state` will contains some empy
`State()`.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]