vinx13 commented on code in PR #12059:
URL: https://github.com/apache/tvm/pull/12059#discussion_r919293782


##########
src/meta_schedule/postproc/rewrite_tensorize.cc:
##########
@@ -35,26 +35,24 @@ void CollectTensorizationJobs(
   tir::PostOrderVisit(func->body, [=, &jobs](const ObjectRef& obj) {
     if (const auto* block = obj.as<tir::BlockNode>()) {
       tir::StmtSRef block_sref = sch->GetSRef(block);
+      std::string block_name = block_sref->StmtAs<tir::BlockNode>()->name_hint;
       if (Optional<String> intrin_name =
               tir::GetAnn<String>(block_sref, 
tir::attr::meta_schedule_auto_tensorize)) {
-        std::string block_name = 
block_sref->StmtAs<tir::BlockNode>()->name_hint;
-        if (block_name.find("init") == std::string::npos) {
-          jobs->emplace_back(block_name, func_name, [sch, 
intrin_name](tir::BlockRV block) {
-            try {
-              sch->Tensorize(block, intrin_name.value());
-            } catch (const std::exception& e) {
-              LOG(WARNING) << "Tensorize failed with error " << e.what();
-            }
-          });
-        } else if (vectorize_init_loop) {
-          jobs->emplace_back(block_name, func_name, [sch](tir::BlockRV block) {
-            Array<BlockRV> child_blocks = sch->GetChildBlocks(block);
-            ICHECK(child_blocks.size() == 1);
-            Array<LoopRV> init_loops = sch->GetLoops(child_blocks[0]);
-            ICHECK(init_loops.size() == 1);
-            sch->Vectorize(init_loops[0]);
-          });
-        }
+        jobs->emplace_back(block_name, func_name, [sch, 
intrin_name](tir::BlockRV block) {
+          try {
+            sch->Tensorize(block, intrin_name.value());
+          } catch (const std::exception& e) {
+            LOG(WARNING) << "Tensorize failed with error " << e.what();
+          }
+        });
+      } else if (block_name.find("init") && vectorize_init_loop) {

Review Comment:
   In `rewrite_reduction_block`, `tir::attr::meta_schedule_auto_tensorize` will 
be removed from the init block by default, unless the original reduction block 
is annotated with `tir::attr::meta_schedule_auto_tensorize_init`. 
`tir::attr::meta_schedule_auto_tensorize_init` will be renamed to 
`tir::attr::meta_schedule_auto_tensorize` so that in `rewrite_tensorize` we can 
check a single annotation. However I hit another issue that 
`block_name.find("init")` is not safe. I changed the logic here a bit let me 
know if that makes sense to you



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