Skip to content
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

Merged
merged 14 commits into from
Sep 12, 2019

Conversation

jroesch
Copy link
Member

@jroesch jroesch commented Sep 6, 2019

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.

include/tvm/relay/module.h Show resolved Hide resolved
include/tvm/relay/module.h Outdated Show resolved Hide resolved
src/relay/ir/module.cc Outdated Show resolved Hide resolved
include/tvm/relay/module.h Outdated Show resolved Hide resolved
src/relay/ir/module.cc Outdated Show resolved Hide resolved
Copy link
Member

@zhiics zhiics left a 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.

@zhiics zhiics merged commit 4e2d707 into apache:master Sep 12, 2019
@zhiics
Copy link
Member

zhiics commented Sep 12, 2019

Thanks everyone, this is now merged.

Copy link
Member

@tqchen tqchen left a 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);
Copy link
Member

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.
*/
Copy link
Member

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?

wweic pushed a commit to wweic/tvm that referenced this pull request Sep 16, 2019
…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
wweic pushed a commit to wweic/tvm that referenced this pull request Sep 16, 2019
…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
wweic pushed a commit to neo-ai/tvm that referenced this pull request Sep 16, 2019
…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
@jroesch jroesch deleted the module-refactor branch February 4, 2021 04:40
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.

5 participants