You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by GitBox <gi...@apache.org> on 2022/07/13 14:58:16 UTC

[GitHub] [tvm-rfcs] tqchen commented on a diff in pull request #84: [RFC] Name mangling in IRModules

tqchen commented on code in PR #84:
URL: https://github.com/apache/tvm-rfcs/pull/84#discussion_r920184786


##########
rfcs/0077_name_mangling_ir_modules.md:
##########
@@ -29,20 +30,31 @@ This RFC aims to unify the creation of unique `GlobalVars` and refactor the curr
 [guide-level-explanation]: #guide-level-explanation
 
 The changes are internal to TVM. 
-The code writer is expected to avoid as much as possible calling the constructor of `GlobalVar` and instead use a `NameSupply` to generate one. 
-The `NameSupply` is constructed by passing a `String prefix` (usually a module name) that is to be prepended to the `GlobalVars` generated: `auto name_supply = NameSupply::NameSupplyWithPrefix(mod_name);`
-
-A `NameSupply` can be attached to an `IRModule`. The `IRModule` acts a carrier for the `NameSupply` through compiler passes. 
-The attached `NameSupply` can then be retrieved from the `IRModule` when, for example, a pass generates new `GlobalVars`.
+The code writer is expected to avoid as much as possible calling the constructor of `GlobalVar` and instead use a `GlobalVarSupply` to generate one:
+- The `GlobalVarSupply` is constructed by passing a `NameSupply` that is used to generate unique strings for the `name_hint` member of `GlobalVars`.
+Alternatively, builder methods such as `GlobalVarSupply::EmptySupply` can be used to construct an empty `GlobalVarSuppyl` with an empty `NameSupply`.
+- The `NameSupply` can be constructed by passing a `String prefix` (usually a module name) that can then be prepended  to the `String`s generated: `auto name_supply = NameSupply::NameSupplyWithPrefix(mod_name);`
+
+A `GlobalVarSupply` can be derived from an existing `IRModule` or an array of `IRModules` by calling `tvm::BuildGlobalVarSupply(modules)`. 
+When a pass generates new `GlobalVars`, a `GlobalVarSupply` can be created from the current `IRModule`. Then, `GlobalVarSupply::FreshGlobal`
+can be used to guarantee uniqueness of new `GlobalVars`.
+```
+GlobalVarSupply var_supply = tvm::BuildGlobalVarSupply(mod);

Review Comment:
   perhaps we can do constructor directly?



-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org