-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[Relay][Module] Refactor the way we interface between different modules of Relay. #3906
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
72ccd9a
b9a5f4c
1759219
67bde24
4bb1959
0f7880b
a61d209
95d1a0f
2cf6702
8351bf6
3a01c43
65030b7
f008410
a523317
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,6 +33,7 @@ | |
| #include <string> | ||
| #include <vector> | ||
| #include <unordered_map> | ||
| #include <unordered_set> | ||
|
|
||
| namespace tvm { | ||
| namespace relay { | ||
|
|
@@ -185,6 +186,23 @@ class ModuleNode : public RelayNode { | |
| */ | ||
| TVM_DLL void Update(const Module& other); | ||
|
|
||
| /*! | ||
| * \brief Import Relay code from the file at path. | ||
| * \param path The path of the Relay code to import. | ||
| * | ||
| * \note The path resolution behavior is standard, | ||
| * if abosolute will be the absolute file, if | ||
| * relative it will be resovled against the current | ||
| * working directory. | ||
| */ | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The current API mutates the module, this is a bit diverging from designs of trying to be immutable as much as possible. How about relay.Module.fromtext and relay.Module.load? |
||
| TVM_DLL void Import(const std::string& path); | ||
jroesch marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| /*! | ||
| * \brief Import Relay code from the file at path, relative to the standard library. | ||
| * \param path The path of the Relay code to import. | ||
| */ | ||
| TVM_DLL void ImportFromStd(const std::string& path); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. From users' perspective, Import and ImportFromStd seems to be a bit too similar and introduces metal overhead about choosing between them, can be combine them into one? |
||
|
|
||
| /*! \brief Construct a module from a standalone expression. | ||
| * | ||
| * Allows one to optionally pass a global function map and | ||
|
|
@@ -222,6 +240,11 @@ class ModuleNode : public RelayNode { | |
| * for convenient access | ||
| */ | ||
| std::unordered_map<int32_t, Constructor> constructor_tag_map_; | ||
|
|
||
| /*! \brief The files previously imported, required to ensure | ||
| importing is idempotent for each module. | ||
| */ | ||
| std::unordered_set<std::string> import_set_; | ||
| }; | ||
|
|
||
| struct Module : public NodeRef { | ||
|
|
@@ -235,6 +258,12 @@ struct Module : public NodeRef { | |
| using ContainerType = ModuleNode; | ||
| }; | ||
|
|
||
| /*! \brief Parse Relay source into a module. | ||
| * \param source A string of Relay source code. | ||
| * \param source_name The name of the source file. | ||
| * \return A Relay module. | ||
| */ | ||
| Module FromText(const std::string& source, const std::string& source_name); | ||
|
|
||
| } // namespace relay | ||
| } // namespace tvm | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.