forked from apache/tvm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Relay] Use LowerTEPass in VM (apache#9483)
We replace use of the TECompiler::{Lower,LowerShapeFunc} methods from the VM's compiler.cc with LowerTEPass. This clears the way for performing post-lowering IRModule->IRModule transformations which combine Relay and TIR analysis. In particular, it will allow us to use the PlanDevices pass to propagate memory scope constraints across PrimFuncs. We run LowerTEPass fairly early in the pipeline, which required quite a few passes to become 'post-lowering friendly'. In particular, ManifestAlloc is now run after rather than before lowering, and so must now work in a mixed Function/PrimFunc world. The "vm.shape_func" operator has been removed since a) lowering has already generated the necessary dynamic shape function, and b) the call to that function can be represented by an 'ordinary' vm.invoke_tvm_op call. We worked our way through the following glitches: - Dynamic shape functions are now given their true type (rather than the type of the primitive function they are paired with). - Lowering was choosing definitional GlobalVars which were not pointer-equal to the referential GlobalVars left behind in the rewritten Calls. We fixed that in te_compiler.cc, though better would be to push GlobalVars deeper into the lowering machinery. - device_copy was rewritten to a call to @__copy without any definition. Though we tried adding it as a global this (obviously in retrospect...) won't typecheck if there are multiple device_copies in the program. Instead leave device_copy unchanged during lowering and update each executor codegen to look for them specially. - Calls to already-compiled BYOC functions were indistinguishable from calls to (non-primitive) Relay functions. We move them into the call_lowered calling convention, and leave behind a Function tagged with "ExternalSymbol". Better would be a first-class representatn for externals in the IRModule but one step at a time. - Functions with dynamic shapes tagged for BYOC compilation were not tracking their connection to their dynamic shape function. We now use exactly the same attributes as for non-BYOC primitives. - VerilatorRuntime can legitimately be deleted before initialized. - IRModule attributes must be preserved. In particular, since LowerTEPass can be invoked more than once we need to be careful to preserve any existing external modules and other attributes gatherd from an earlier LowerTEPass. - GetUniqueName accounts for existing definitions in the module, but is not used for external functions since their intended names are communicated to the codegen toolchain via the already fixed "global_symbol" attribute.
- Loading branch information
1 parent
64fb0b9
commit b6fce0e
Showing
50 changed files
with
1,150 additions
and
1,193 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.