altanh commented on a change in pull request #8597:
URL: https://github.com/apache/tvm/pull/8597#discussion_r683868643
##########
File path: include/tvm/ir/module.h
##########
@@ -307,20 +316,38 @@ class IRModule : public ObjectRef {
}
/*!
- * \brief Construct a module from a standalone expression.
+ * \brief Constructs a module from a standalone expression \p expr.
+ *
+ * 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.
*
- * Allows one to optionally pass a global function map and
- * map of type definitions as well.
+ * The function is bound to, in preference order:
+ * - The "global_symbol" attribute of \p expr, if it is a function with
that attribute.
+ * - 'main'
+ * - A unique name derived from 'main' if 'main' is already bound in \p
global_funcs.
+ *
+ * Additional global functions and type definitions may be included in the
result module.
+ *
+ * See also \p FromExpr.
*
* \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 The global type definition map. Default empty.
+ * \param import_set Set of external modules already imported. Default empty.
*
- * \returns A module with expr set as the main function.
+ * \returns A module with \p expr set as the main function, and the global
var to which
+ * \p expr was bound (typcially 'main').
+ */
+ TVM_DLL static std::pair<IRModule, GlobalVar> FromExprInContext(
+ const RelayExpr& expr, const Map<GlobalVar, BaseFunc>& global_funcs = {},
+ const Map<GlobalTypeVar, TypeData>& type_definitions = {},
+ std::unordered_set<String> import_set = {});
Review comment:
just wondering about FFI interaction with `std::pair` and
`std::unordered_set`, could there be problems?
--
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]