Skip to content

Conversation

@Lunderberg
Copy link
Contributor

Prior to this commit, relax.transform.RunCodegen required a list of entry functions for a module, defaulting to "main" if not specified. The list of entry functions is duplicate information that could be inferred from the module, and should not be required from the user. This commit updates RunCodegen to treat all externally-exposed functions as entry points, in the same manner as
DeadCodeElimination.

For backwards compatibility, the entry_functions argument is still accepted, and is used to augment the list of externally-exposed functions.

* `IRModule.clone`: Clone the module.  While in C++, a module can be
  copied using `IRModule::CopyOnWrite()`, copying a module in Python
  required passing all members into the `IRModule` initializer.  The
  `IRModule.clone` method provides an easier way to copy an `IRModule`
  from python.

* `IRModule.__delitem__`: Remove a function from the module.  This
  exposes the C++ method `IRModuleNode::Remove` for use in the python
  API.  This uses the python `del` keyword, similar to a native python
  list.  Similar to the existing `IRModule.__getitem__`, this can be
  called with either a `GlobalVar` or a python string.

* `IRModule.__contains__`: Check if a function is in the module.  This
  allows the pythone keyword `in` to check if a module contains a
  specific function.  Similar to the existing `IRModule.__getitem__`,
  this can be called either with a `GlobalVar` (`if gvar in mod`) or
  with a python string (`if "function_name" in mod`).
@Lunderberg Lunderberg changed the base branch from unity to main January 22, 2024 20:29
@Lunderberg Lunderberg force-pushed the unity_check_func_attr_in_relax_codegen branch 2 times, most recently from 2bf368d to 9a1d724 Compare January 23, 2024 16:24
Prior to this commit, `relax.transform.RunCodegen` required a list of
entry functions for a module, defaulting to `"main"` if not specified.
The list of entry functions is duplicate information that could be
inferred from the module, and should not be required from the user.
This commit updates `RunCodegen` to treat all externally-exposed
functions as entry points, in the same manner as
`DeadCodeElimination`.

For backwards compatibility, the `entry_functions` argument is still
accepted, and is used to augment the list of externally-exposed
functions.
@Lunderberg Lunderberg force-pushed the unity_check_func_attr_in_relax_codegen branch from 9a1d724 to 762e229 Compare January 25, 2024 15:32
@vinx13 vinx13 merged commit 147ed5e into apache:main Jan 30, 2024
@Lunderberg Lunderberg deleted the unity_check_func_attr_in_relax_codegen branch January 30, 2024 16:40
elvin-n pushed a commit to Deelvin/tvm that referenced this pull request Mar 19, 2024
…ache#16422)

* [IR] Add utility methods to IRModule

* `IRModule.clone`: Clone the module.  While in C++, a module can be
  copied using `IRModule::CopyOnWrite()`, copying a module in Python
  required passing all members into the `IRModule` initializer.  The
  `IRModule.clone` method provides an easier way to copy an `IRModule`
  from python.

* `IRModule.__delitem__`: Remove a function from the module.  This
  exposes the C++ method `IRModuleNode::Remove` for use in the python
  API.  This uses the python `del` keyword, similar to a native python
  list.  Similar to the existing `IRModule.__getitem__`, this can be
  called with either a `GlobalVar` or a python string.

* `IRModule.__contains__`: Check if a function is in the module.  This
  allows the pythone keyword `in` to check if a module contains a
  specific function.  Similar to the existing `IRModule.__getitem__`,
  this can be called either with a `GlobalVar` (`if gvar in mod`) or
  with a python string (`if "function_name" in mod`).

* [Unity][CodeGen] RunCodegen based on externally-exposed functions

Prior to this commit, `relax.transform.RunCodegen` required a list of
entry functions for a module, defaulting to `"main"` if not specified.
The list of entry functions is duplicate information that could be
inferred from the module, and should not be required from the user.
This commit updates `RunCodegen` to treat all externally-exposed
functions as entry points, in the same manner as
`DeadCodeElimination`.

For backwards compatibility, the `entry_functions` argument is still
accepted, and is used to augment the list of externally-exposed
functions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants