mbs-octoml commented on a change in pull request #8597:
URL: https://github.com/apache/tvm/pull/8597#discussion_r683006012
##########
File path: include/tvm/ir/module.h
##########
@@ -307,20 +307,31 @@ class IRModule : public ObjectRef {
}
/*!
- * \brief Construct a module from a standalone expression.
+ * \brief Constructs a module from a standalone expression \p expr.
*
- * Allows one to optionally pass a global function map and
- * map of type definitions as well.
+ * If \p expr is a function it will be bound directly. Otherwise a function
over the free
+ * variables of \p expr (possibly none) with \p expr as body is created and
bound.
+ *
+ * The function is bound to, in preference order:
+ * - The "global_symbol" attribute of \p expr, if it is a function with
that attribute.
+ * - \p name_hint, if non-empty.
+ * - "main"
+ *
+ * Additional global functions and type definitions may be included in the
result module.
*
* \param expr The expression to set as the main function to the module.
- * \param global_funcs The global function map.
- * \param type_definitions Map of global type definitions
+ * \param global_funcs The global function map. Default empty.
+ * \param type_definitions Map of global type definitions. Default empty.
+ * \param import_set Set of external modules already imported. Default empty.
+ * \param name_hint Name hint for global var to bind to \p expr. Default
empty.
*
- * \returns A module with expr set as the main function.
+ * \returns A module with \p expr set as the main function.
*/
TVM_DLL static IRModule FromExpr(const RelayExpr& expr,
const Map<GlobalVar, BaseFunc>&
global_funcs = {},
- const Map<GlobalTypeVar, TypeData>&
type_definitions = {});
+ const Map<GlobalTypeVar, TypeData>&
type_definitions = {},
+ std::unordered_set<String> import_set = {},
+ const std::string& name_hint =
std::string());
Review comment:
Done. Kept FromExpr for the simple case (just an expr, always implicitly
bound to 'main'). General case now FromExprInContext. Added yet another
GetUniqueName into IRModule (though left private & not ffiable for now). We
should bring the N copies of this under control.
--
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]