masahi commented on code in PR #10937:
URL: https://github.com/apache/tvm/pull/10937#discussion_r846944453


##########
src/meta_schedule/task_scheduler/task_scheduler.cc:
##########
@@ -127,7 +128,20 @@ void TaskSchedulerNode::Tune() {
     ICHECK(!task->is_terminated);
     ICHECK(!task->runner_futures.defined());
     SearchStrategy strategy = task->search_strategy.value();
-    if ((task->measure_candidates = 
strategy->GenerateMeasureCandidates()).defined()) {
+    Optional<Array<MeasureCandidate>> candidates = 
strategy->GenerateMeasureCandidates();
+    if (candidates.defined()) {
+      // Filter out invalid candidates.
+      // An invalid candidate can arise due to a schedule application failure 
(e.g. tensorize).
+      Array<MeasureCandidate> valid_candidates;
+      for (MeasureCandidate candidate : candidates.value()) {
+        if (candidate.defined()) {
+          valid_candidates.push_back(candidate);
+        }
+      }
+
+      if (valid_candidates.size() == 0) continue;

Review Comment:
   Yeah, I realized that after I put try/catch in `ThreadedApply`, all 
candidates are valid if ` support::parallel_for_dynamic` ever returns.
   
   The issue I have now is that, that infinite loop can now really repeat 
forever, if some postprocs never succeed on all design spaces. I'm now trying 
conv2d VNNI auto-tensorize, and due to an implementation issue in 
auto-tensorize, `sch->Tensorize` in postproc always fail. But since the 
tensorize error is now caught by `ThreadedApply` and we repeat, it leads to an 
infinite loop.
   
   So I'm now wondering if doing try/catch in `ThreadedApply` is the right 
solution here. Rather, we might want to wrap try/catch around 
`sch->Tensorize(...)` in a postproc rewrite, meaning we return non-tensorized 
schedule in case of auto-tensorization failure. I think this is what @vinx13 
suggested last week.
   
   So, if we agree that we should wrap try/catch around `sch->Tensorize(...)`, 
I don't need the change in this PR anymore. Do we have other good reason to put 
try/catch around `ThreadedApply`? Otherwise I'll close this.



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to