-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
[Relay][Module] Refactor the way we interface between different modules of Relay. #3906
Conversation
129389a
to
95d1a0f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great to see this PR. Reuse of prelude gave me errors before as well. Please fix some style issues pointed out by @MarisaKirisame and @weberlo. I will merge once CI passes.
Thanks everyone, this is now merged. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know it is merged,but some thoughts on API design
* \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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The 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?
* if abosolute will be the absolute file, if | ||
* relative it will be resovled against the current | ||
* working directory. | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The 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?
…es of Relay. (apache#3906) * Module refactor * Add load module * Add support for idempotent import * Tweak load paths * Move path around * Expose C++ import functions in Python * Fix import * Add doc string * Fix * Fix lint * Fix lint * Fix test failure * Add type solver * Fix lint
…es of Relay. (apache#3906) * Module refactor * Add load module * Add support for idempotent import * Tweak load paths * Move path around * Expose C++ import functions in Python * Fix import * Add doc string * Fix * Fix lint * Fix lint * Fix test failure * Add type solver * Fix lint
…es of Relay. (apache#3906) * Module refactor * Add load module * Add support for idempotent import * Tweak load paths * Move path around * Expose C++ import functions in Python * Fix import * Add doc string * Fix * Fix lint * Fix lint * Fix test failure * Add type solver * Fix lint
Introduces an idempotent import mechanism for Relay and restructures some of the code around handling Relay files. One of the challenges for introducing new dialects of Relay as I was doing in #3560 is the ability to define new external types, and operations over them.
In order to track new types such as
Storage
we need the ability to share chunks of code in a idempotent way. The current module design is lacking in this regard and the import mechanism addresses this.An example of where this fails now is if we introduce new builtin types, where do we place the code to install them in a module? for example if we use the instantiate the prelude more than once we will receive an error right now.
This is required for my memory analysis PR which is upcoming, and depends on @weberlo's parser PR.
@weberlo will follow up by moving the entire Prelude to the text format.
This PR also cleans up InferType's handling of modules which is currently sub-optimal.