-
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] Move prelude to text format #3939
Conversation
python/tvm/relay/prelude.rly
Outdated
@@ -18,12 +18,290 @@ | |||
*/ | |||
v0.0.4 | |||
|
|||
def @id[a](%x: a) -> a { | |||
%x | |||
// TODO(weberlo): should we add sugar for scalar types (e.g., `int32` => `Tensor[(), int32]`)? |
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.
Good idea, though it probably merits wider discussion
Will do over the weekend. |
It needs to also follow the "add unchecked, add checked" pattern
58be955
to
67302e9
Compare
@@ -151,6 +151,22 @@ void ModuleNode::Add(const GlobalVar& var, | |||
AddUnchecked(var, checked_func); | |||
} | |||
|
|||
void ModuleNode::AddUnchecked(const GlobalVar& var, |
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.
Isn't this function the same as before?
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.
yeah. I just moved it next to Add
for readability. I can move it back if you want.
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.
LGTM. I'll approve once CI is fixed.
The CI failure was because the VM compiler can't compile programs which make use of first-class constructors. For example,
needs to be rewritten as
, in order to successfully compile. @jroesch We do want first-class constructors, right? If so, I'll submit a follow-up PR that adds that functionality. |
@wweic CI is green |
We should handle this with a full eta-expansion pass, I will try to find some resources on performing eta-expansion for these types of purposes. |
* Fix parser * Doc fix * Add module utility functions necessary for prelude * Implement prelude in text format * Remove programmatically constructed prelude defs * Fix 0-arity type conses in pretty printer and test * Make prelude loading backwards-compatible * Fix patterns * Improve some prelude defs * Fix `ImportFromStd` It needs to also follow the "add unchecked, add checked" pattern * Lint roller * Woops * Address feedback * Fix `test_list_constructor` VM test * Fix `test_adt.py` failures
* Fix parser * Doc fix * Add module utility functions necessary for prelude * Implement prelude in text format * Remove programmatically constructed prelude defs * Fix 0-arity type conses in pretty printer and test * Make prelude loading backwards-compatible * Fix patterns * Improve some prelude defs * Fix `ImportFromStd` It needs to also follow the "add unchecked, add checked" pattern * Lint roller * Woops * Address feedback * Fix `test_list_constructor` VM test * Fix `test_adt.py` failures
* Fix parser * Doc fix * Add module utility functions necessary for prelude * Implement prelude in text format * Remove programmatically constructed prelude defs * Fix 0-arity type conses in pretty printer and test * Make prelude loading backwards-compatible * Fix patterns * Improve some prelude defs * Fix `ImportFromStd` It needs to also follow the "add unchecked, add checked" pattern * Lint roller * Woops * Address feedback * Fix `test_list_constructor` VM test * Fix `test_adt.py` failures
* master: Fix split's last factor issue (apache#4044) [COMMUNITY] ajtulloch -> committer (apache#4043) [TOPI]Add op argwhere (apache#3994) [topi] add ARM v8.2 udot (uint8) support (apache#3978) [COMMUNITY] anijain2305 -> reviewer (apache#4036) [QNN] Renaming dense operator. (apache#4033) [Relay][Compile_engine] Int64 shape handling for outputs. (apache#4031) Add dmlc-core to the list of installed header directories. (apache#4035) [ARITH] migrate indexdiv/mod to floordiv/mod (apache#4008) [Relay] Move prelude to text format (apache#3939) make tvm compilable by gcc 4.9.2 (apache#4032) [AUTOTVM][DOCS] Add a link to the defining network description of auto-tuning tutorial (apache#4023) [ARITH] cleanup the indexmod/div on python side (apache#4028) [Fix] Add more pad_mode support for onnx converter (apache#4029) Add parser support for ReLU tflite operator (apache#4022) Additional MXNet Convolution and Deconvolution tests (apache#4026) docs: minor spelling tweaks (apache#4027)
This PR is a follow-up to #3863, which replaces the hand-constructed ASTs in the current prelude with equivalent definitions in the text format.
One question I have about syntax is how we should handle zero-arity constructors. Most functional languages desugar, for example,
Nil
intoNil()
, and I've implemented that functionality here. Let me know if that's not what we want.CC @MarisaKirisame @slyubomirsky @jroesch @junrushao1994