junrushao1994 commented on code in PR #11692:
URL: https://github.com/apache/tvm/pull/11692#discussion_r897068109


##########
src/meta_schedule/extracted_task.cc:
##########
@@ -32,6 +38,42 @@ ExtractedTask::ExtractedTask(String task_name, IRModule mod, 
Target target,
   data_ = n;
 }
 
+Optional<tir::PrimFunc> DefaultTaskFilter(const Array<te::Tensor>& args) {
+  using namespace ::tvm::te;
+  std::vector<Tensor> stack;
+  std::unordered_set<const TensorNode*> visited;
+  for (const Tensor& v : args) {
+    for (const PrimExpr& e : v->shape) {
+      // Dynamic shape is not supported for now
+      if (!e->IsInstance<IntImmNode>()) {
+        return NullOpt;
+      }
+    }
+    if (!visited.count(v.get())) {
+      visited.insert(v.get());
+      stack.push_back(v);
+    }
+  }
+  while (!stack.empty()) {
+    Tensor tensor = stack.back();
+    stack.pop_back();
+    if (tensor->op->IsInstance<PlaceholderOpNode>()) {
+      // do nothing
+    } else if (tensor->op->IsInstance<ComputeOpNode>()) {

Review Comment:
   This is certain an interesting design tradeoff. MetaSchedule/AutoScheduler 
default rules are not supposed to handle all the ExternOp and HybridOp in every 
model, because they are already scheduled (e.g. the NMS operator), or do not 
need to be scheduled (e.g. external library). Therefore, we are filtering out 
all those operations by default to make sure MetaSchedule doesn't break on 
customer models.
   
   Given we support customized filtering methods, do you think it's a good idea 
if we expose another method that doesn't rule out extern-op for customized 
usecases?



##########
src/meta_schedule/extracted_task.cc:
##########
@@ -32,6 +38,42 @@ ExtractedTask::ExtractedTask(String task_name, IRModule mod, 
Target target,
   data_ = n;
 }
 
+Optional<tir::PrimFunc> DefaultTaskFilter(const Array<te::Tensor>& args) {
+  using namespace ::tvm::te;
+  std::vector<Tensor> stack;
+  std::unordered_set<const TensorNode*> visited;
+  for (const Tensor& v : args) {
+    for (const PrimExpr& e : v->shape) {
+      // Dynamic shape is not supported for now
+      if (!e->IsInstance<IntImmNode>()) {
+        return NullOpt;
+      }
+    }
+    if (!visited.count(v.get())) {
+      visited.insert(v.get());
+      stack.push_back(v);
+    }
+  }
+  while (!stack.empty()) {
+    Tensor tensor = stack.back();
+    stack.pop_back();
+    if (tensor->op->IsInstance<PlaceholderOpNode>()) {
+      // do nothing
+    } else if (tensor->op->IsInstance<ComputeOpNode>()) {

Review Comment:
   This is certain an interesting design tradeoff. MetaSchedule/AutoScheduler 
default rules are not supposed to handle all the ExternOp and HybridOp in every 
model, because they are already scheduled (e.g. the NMS operator), or do not 
need to be scheduled (e.g. external library). Therefore, we are filtering out 
all those operations by default to make sure MetaSchedule doesn't break on 
customer models.
   
   Alternatively, given we support customized filtering methods, do you think 
it's a good idea if we expose another method that doesn't rule out extern-op 
for customized usecases?



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