csullivan commented on code in PR #13349:
URL: https://github.com/apache/tvm/pull/13349#discussion_r1035522221


##########
include/tvm/driver/driver_api.h:
##########
@@ -78,20 +78,22 @@ TVM_DLL transform::Sequential 
HostModulePassManager(IRModule mixed_mod, Target t
  * \brief Lower an IRModule (optimize with it with the pass list defined in 
CreatePassList)
  * \param mod The IRmodule to lower
  * \param simple_mode Disables the loop partition pass. Defaults to false.
+ * \param target The device target to provide additional characteristics. 
Defaults to not defined.
  * \return The result module.
  */
-TVM_DLL IRModule LowerModule(IRModule mod, bool simple_mode = false);
+TVM_DLL IRModule LowerModule(IRModule mod, bool simple_mode = false, Target 
target = {});

Review Comment:
   For now we should avoid making an API change to the compiler that would 
introduce `target` to lowering without some community discussion on the topic.
   
   That said I also prefer deriving this target specific information from the 
target. In this case if we make the following change to move LowerVTCMAlloc 
into the MixedModulePassManager, we can add `tir::transform::VerifyVTCMLimit` 
just prior to it in the `mixed_pass_list`. As these passes are run at build 
time (after lowering), the target is available for use. 
   
   ```diff
   diff --git a/src/driver/driver_api.cc b/src/driver/driver_api.cc
   index e5e3998b1..babac2bf6 100644
   --- a/src/driver/driver_api.cc
   +++ b/src/driver/driver_api.cc
   @@ -225,10 +225,8 @@ Array<tvm::transform::Pass> CreatePassList(bool 
disable_loop_partition) {
      if (!disable_storage_rewrite) {
        pass_list.push_back(tir::transform::StorageRewrite());
      }
   -  // LowerVtcmAlloc must occur after any transformations that modify memory 
allocation locations
   -  pass_list.push_back(tir::transform::LowerVtcmAlloc());
   -  bool use_async_copy = pass_ctx->GetConfig<Bool>("tir.use_async_copy", 
Bool(false)).value();
   
   +  bool use_async_copy = pass_ctx->GetConfig<Bool>("tir.use_async_copy", 
Bool(false)).value();
      if (use_async_copy) {
        pass_list.push_back(tir::transform::LowerAsyncDMA());
      }
   @@ -539,6 +537,9 @@ transform::Sequential MixedModulePassManager(IRModule 
mixed_mod, Target target)
   
      Array<Pass> mixed_pass_list;
   +  
mixed_pass_list.push_back(tir::transform::VerifyVTCMLimit(GetVTCMCapacity(target,
 pass_ctx)));
   +  // LowerVtcmAlloc must occur after any transformations that modify memory 
allocation locations
   +  mixed_pass_list.push_back(tir::transform::LowerVtcmAlloc());
   +
      mixed_pass_list.push_back(tir::transform::BindTarget(target));
   
      mixed_pass_list.push_back(tir::transform::VerifyMemory());
   ```
   



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