Skip to content

[RELAY][IR] Move type_annotation to Var, remove Param#1900

Merged
tqchen merged 2 commits intoapache:masterfrom
tqchen:master
Oct 15, 2018
Merged

[RELAY][IR] Move type_annotation to Var, remove Param#1900
tqchen merged 2 commits intoapache:masterfrom
tqchen:master

Conversation

@tqchen
Copy link
Copy Markdown
Member

@tqchen tqchen commented Oct 14, 2018

  • Move type_annotation as a field of Var
    • Remove value_type in Let
    • Remove Param and use Var instead
  • Add/correct docstring of all python Expr class, make them self-contained.

The reasoning behind the change:

  • The current Param was a bit confusing and is only used in the place of the function parameter declaration. Folding the type annotation into Var allows removing one concept.
  • This will make the future graph style programming easier, which I will follow up with subsequent PR.

@tqchen
Copy link
Copy Markdown
Member Author

tqchen commented Oct 14, 2018

@MarisaKirisame @jroesch @slyubomirsky @joshpoll please review

@joshpoll
Copy link
Copy Markdown
Contributor

This actually makes a lot of sense and simplifies several things on the front end. 👍

@MarisaKirisame
Copy link
Copy Markdown
Contributor

I just did a skim, and LGTM.
Should we rename typeparam -> typevar then?

@tqchen
Copy link
Copy Markdown
Member Author

tqchen commented Oct 14, 2018

We can discuss typeparam vs typevar later with @jroesch

Comment thread include/tvm/relay/expr.h
/*! \brief The tuple */
/*! \brief The tuple expression */
Expr tuple;
/*! \brief which value to get */
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

capitalize

Comment thread python/tvm/relay/expr.py Outdated
@property
def checked_type(self):
"""Get the checked type of relay.
"""Get the checked type of tvm.relay.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be "...of a tvm.relay type." ?

Comment thread python/tvm/relay/expr.py Outdated
class Constant(Expr):
"""A constant tensor in Relay, see tvm/relay/type.h for more details.
"""
"""A constant expression in Tvm.Relay.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"... in tvm.relay."

Comment thread python/tvm/relay/expr.py Outdated

Parameters
----------
fields : list of tvm.relay.Expr.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"fields: List[tvm.relay.Expr]"

Comment thread python/tvm/relay/expr.py
@register_relay_node
class Var(Expr):
"""A local variable in Relay."""
"""A local variable in Tvm.Relay.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"tvm.relay."

Comment thread python/tvm/relay/expr.py Outdated
attrs: tvm.Attrs, optional
Attributes to the call, can be None

type_args: list of tvm.relay.Type
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

type_args: List[tvm.relay.Type]

Comment thread python/tvm/relay/expr.py

type_args: list of tvm.relay.Type
The additional type arguments, this is only
used in advanced usecase of template functions.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same edit as previous.

Comment thread python/tvm/relay/expr.py Outdated
Parameters
----------
var: tvm.relay.Var
The local variable to be binded.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

binded -> bound

Comment thread python/tvm/relay/expr.py Outdated
The local variable to be binded.

value: tvm.relay.Expr
The value to be binded.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

binded -> bound

Comment thread python/tvm/relay/expr.py
@register_relay_node
class If(Expr):
"""A conditional expression in Relay, see tvm/relay/expr.h for more details."""
"""A conditional expression in Relay.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Relay -> tvm.relay

Comment thread python/tvm/relay/expr.py Outdated
@property
def checked_type(self):
"""Get the checked type of relay.
"""Get the checked type of tvm.relay.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

of relay expr?

Comment thread python/tvm/relay/expr.py
@register_relay_node
class Call(Expr):
"""A function call in Relay, see tvm/relay/expr.h for more details."""
"""Function call node in Relay.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tvm.Relay

std::vector<Doc> vec;
for (size_t i = 0; i < arr.size(); ++i) {
vec.push_back(Docify(arr[i]));
for (Var param : arr) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you call docify directly?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My understanding is that we cannot directly docify because there are two behaviors(at the declaration point where the type annotation need to be printed), at the usage point where we don't want to print type annotations

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see.

@tqchen
Copy link
Copy Markdown
Member Author

tqchen commented Oct 14, 2018

@MarisaKirisame @joshpoll Thanks for the reviews, I have made changes according to your comments

@slyubomirsky
Copy link
Copy Markdown
Contributor

slyubomirsky commented Oct 15, 2018

Agreed with previous comments, this is certainly a good simplification to make. LGTM, for the most part.

test_tensor_type_alpha_equal()
test_incomplete_type_alpha_equal()
test_constant_alpha_equal()
test_type_param_alpha_equal()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why have test_type_param_alpha_equal() and test_var_alpha_equal() been eliminated from the main method? Those test cases don't appear to have been eliminated.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was removed because TypeParam nolonger exists

@tqchen tqchen merged commit 0b4cc05 into apache:master Oct 15, 2018
@tqchen
Copy link
Copy Markdown
Member Author

tqchen commented Oct 15, 2018

Thanks @slyubomirsky @joshpoll @MarisaKirisame , this is merged

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.

4 participants