zxybazh commented on code in PR #13050:
URL: https://github.com/apache/tvm/pull/13050#discussion_r995343161


##########
src/relay/backend/task_extraction.cc:
##########
@@ -42,26 +46,35 @@ Array<meta_schedule::ExtractedTask> ExtractTask(IRModule 
mod, Target target,
   mod = transform::Sequential(pass_seqs)(std::move(mod));
 
   std::vector<ExtractedTask> tasks;
-  std::unordered_map<tec::CCacheKey, ExtractedTask> cache;
+
+  auto mod_eq = meta_schedule::ModuleEquality::Create(mod_eq_name);
+
+  std::unordered_map<IRModule, ExtractedTask, ModuleHash, ModuleEqual> cache(
+      /*bucket_count*/ 0, ModuleHash(*mod_eq), ModuleEqual(*mod_eq));
+
   PostOrderVisit(mod->Lookup("main"), [&target, &tasks, &cache, 
&tir_converter](const Expr& exp) {
     if (exp->IsInstance<FunctionNode>()) {
       Function relay_func = Downcast<Function>(exp);
       if (!relay_func->HasNonzeroAttr(attr::kPrimitive)) {
         return;
       }
-      tec::CCacheKey cache_key(relay_func, target);
-      auto it = cache.find(cache_key);
-      if (it != cache.end()) {
-        it->second->weight += 1;
-        return;
-      }
+
       auto [inputs_outputs, constants, fused_name] =
           tec::LowerTECompute(relay_func, target, /*return_inputs=*/true);
+
       if (Optional<tir::PrimFunc> f = tir_converter(inputs_outputs, 
constants)) {
+        IRModule tir_mod = PrimFuncToIRModule(f.value());
+
+        auto it = cache.find(tir_mod);

Review Comment:
   Let's leave a comment for this note: `Note that the cache is now key-ed on 
the tir mod, rather than the relay mod (which tec::CCacheKey uses).`



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