Skip to content

Merge attrs and attr_protos in IRFunction | chore(irbuilder) #625

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

Merged
merged 22 commits into from
Apr 14, 2023

Conversation

justinchuby
Copy link
Collaborator

@justinchuby justinchuby commented Apr 12, 2023

Stack from ghstack (oldest at bottom):

Merge the two list in IRFunction by changing its type to IRAttributeParameter. This way we retain type information for all attributes. It is useful for creating correct OpSchemas and ParamSchemas in the next PR.

Also Include typeinfo in add_attr_parameter.

Move version_utils to `_internal` so that it can be used my onnxscript

[ghstack-poisoned]
justinchuby added a commit that referenced this pull request Apr 12, 2023
justinchuby added a commit that referenced this pull request Apr 12, 2023
Stack from [ghstack](https://github.com/ezyang/ghstack) (oldest at
bottom):
* #626
* #625
* __->__ #624

Move version_utils to `_internal` so that it can be used my onnxscript
@justinchuby justinchuby changed the base branch from gh/justinchuby/15/base to main April 12, 2023 18:11
@titaiwangms
Copy link
Contributor

The changes aren't stacked? It seems being piled up to the next commit?

@justinchuby justinchuby changed the base branch from main to gh/justinchuby/15/base April 12, 2023 18:16
@justinchuby
Copy link
Collaborator Author

The changes aren't stacked? It seems being piled up to the next commit?

That's the thing I talked about with ghstack and how we use github to merge which is annoying. I changed the base branch back. Try now?

@titaiwangms
Copy link
Contributor

The changes aren't stacked? It seems being piled up to the next commit?

That's the thing I talked about with ghstack and how we use github to merge which is annoying. I changed the base branch back. Try now?

Working!

@justinchuby

This comment was marked as resolved.

@justinchuby justinchuby added the change base before merge Remember to change the merge base to main when the PR is ready to merge label Apr 12, 2023
…tion` | chore(irbuilder)"


Merge the two list in `IRFunction` by adding a `has_default` field in `IRAttributeValue`. This way we retain type information for all attributes. It is useful for creating correct `OpSchema`s and `ParamSchema`s in the next PR.

Also Include `typeinfo` in `add_attr_parameter`.

[ghstack-poisoned]
…builder)"


Merge the two list in `IRFunction` by adding a `has_default` field in `IRAttributeValue`. This way we retain type information for all attributes. It is useful for creating correct `OpSchema`s and `ParamSchema`s in the next PR.

Also Include `typeinfo` in `add_attr_parameter`.

[ghstack-poisoned]
@justinchuby justinchuby changed the base branch from gh/justinchuby/15/base to main April 12, 2023 20:55
@justinchuby justinchuby removed the change base before merge Remember to change the merge base to main when the PR is ready to merge label Apr 12, 2023
@codecov
Copy link

codecov bot commented Apr 12, 2023

Codecov Report

Merging #625 (6c54f07) into main (9bde82d) will decrease coverage by 0.15%.
The diff coverage is 77.35%.

@@            Coverage Diff             @@
##             main     #625      +/-   ##
==========================================
- Coverage   73.95%   73.81%   -0.15%     
==========================================
  Files         107      107              
  Lines       11389    11390       +1     
  Branches     1185     1185              
==========================================
- Hits         8423     8407      -16     
- Misses       2645     2657      +12     
- Partials      321      326       +5     
Impacted Files Coverage Δ
onnxscript/converter.py 81.74% <ø> (-1.20%) ⬇️
onnxscript/type_annotation.py 71.62% <0.00%> (-1.36%) ⬇️
onnxscript/values.py 91.35% <60.00%> (-0.36%) ⬇️
onnxscript/irbuilder.py 75.17% <80.00%> (-1.78%) ⬇️
onnxscript/converter_test.py 84.39% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

…tion` | chore(irbuilder)"


Merge the two list in `IRFunction` by adding a `has_default` field in `IRAttributeValue`. This way we retain type information for all attributes. It is useful for creating correct `OpSchema`s and `ParamSchema`s in the next PR.

Also Include `typeinfo` in `add_attr_parameter`.

[ghstack-poisoned]
…builder)"


Merge the two list in `IRFunction` by adding a `has_default` field in `IRAttributeValue`. This way we retain type information for all attributes. It is useful for creating correct `OpSchema`s and `ParamSchema`s in the next PR.

Also Include `typeinfo` in `add_attr_parameter`.

[ghstack-poisoned]
…tion` | chore(irbuilder)"


Merge the two list in `IRFunction` by adding a `has_default` field in `IRAttributeValue`. This way we retain type information for all attributes. It is useful for creating correct `OpSchema`s and `ParamSchema`s in the next PR.

Also Include `typeinfo` in `add_attr_parameter`.

[ghstack-poisoned]
…builder)"


Merge the two list in `IRFunction` by adding a `has_default` field in `IRAttributeValue`. This way we retain type information for all attributes. It is useful for creating correct `OpSchema`s and `ParamSchema`s in the next PR.

Also Include `typeinfo` in `add_attr_parameter`.

[ghstack-poisoned]
@@ -108,10 +108,16 @@ def _opt_var_to_str(x):


class IRAttributeValue:
"""An attribute value (representing an actual parameter)."""
"""An attribute value (representing an actual parameter).
Copy link
Collaborator

Choose a reason for hiding this comment

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

With the current changes, this class is being used to cover both actual parameters (which are values) as well as formal parameters (with or without a default-value). I am not 100% sure if we should unify all of these into a single type/class. But if we do, may be the name should be changed to reflect this? May be IRAttributeParameter ? And, of course, the above documentation line should be changed to actual+formal parameter.

Copy link
Collaborator

Choose a reason for hiding this comment

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

For example, should we add an assertion/check in the IRStmt init method that all attrs have a default-value?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks! I added IRAttributeParameter. I wonder if it should be a subclass of IRAttributeValue or be its own class? For now I subclassed but semantically should it be that?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I made an update on IRAttributeParameter. PTAL

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, semantically it should not be a subclass. The current form is preferable.

…tion` | chore(irbuilder)"


Merge the two list in `IRFunction` by adding a `has_default` field in `IRAttributeValue`. This way we retain type information for all attributes. It is useful for creating correct `OpSchema`s and `ParamSchema`s in the next PR.

Also Include `typeinfo` in `add_attr_parameter`.

[ghstack-poisoned]
…builder)"


Merge the two list in `IRFunction` by adding a `has_default` field in `IRAttributeValue`. This way we retain type information for all attributes. It is useful for creating correct `OpSchema`s and `ParamSchema`s in the next PR.

Also Include `typeinfo` in `add_attr_parameter`.

[ghstack-poisoned]
…tion` | chore(irbuilder)"


Merge the two list in `IRFunction` by adding a `has_default` field in `IRAttributeValue`. This way we retain type information for all attributes. It is useful for creating correct `OpSchema`s and `ParamSchema`s in the next PR.

Also Include `typeinfo` in `add_attr_parameter`.

[ghstack-poisoned]
…builder)"


Merge the two list in `IRFunction` by adding a `has_default` field in `IRAttributeValue`. This way we retain type information for all attributes. It is useful for creating correct `OpSchema`s and `ParamSchema`s in the next PR.

Also Include `typeinfo` in `add_attr_parameter`.

[ghstack-poisoned]
…tion` | chore(irbuilder)"


Merge the two list in `IRFunction` by changing its type to `IRAttributeParameter`. This way we retain type information for all attributes. It is useful for creating correct `OpSchema`s and `ParamSchema`s in the next PR.

Also Include `typeinfo` in `add_attr_parameter`.

[ghstack-poisoned]
…builder)"


Merge the two list in `IRFunction` by changing its type to `IRAttributeParameter`. This way we retain type information for all attributes. It is useful for creating correct `OpSchema`s and `ParamSchema`s in the next PR.

Also Include `typeinfo` in `add_attr_parameter`.

[ghstack-poisoned]
…tion` | chore(irbuilder)"


Merge the two list in `IRFunction` by changing its type to `IRAttributeParameter`. This way we retain type information for all attributes. It is useful for creating correct `OpSchema`s and `ParamSchema`s in the next PR.

Also Include `typeinfo` in `add_attr_parameter`.

[ghstack-poisoned]
…builder)"


Merge the two list in `IRFunction` by changing its type to `IRAttributeParameter`. This way we retain type information for all attributes. It is useful for creating correct `OpSchema`s and `ParamSchema`s in the next PR.

Also Include `typeinfo` in `add_attr_parameter`.

[ghstack-poisoned]
…tion` | chore(irbuilder)"


Merge the two list in `IRFunction` by changing its type to `IRAttributeParameter`. This way we retain type information for all attributes. It is useful for creating correct `OpSchema`s and `ParamSchema`s in the next PR.

Also Include `typeinfo` in `add_attr_parameter`.

[ghstack-poisoned]
…builder)"


Merge the two list in `IRFunction` by changing its type to `IRAttributeParameter`. This way we retain type information for all attributes. It is useful for creating correct `OpSchema`s and `ParamSchema`s in the next PR.

Also Include `typeinfo` in `add_attr_parameter`.

[ghstack-poisoned]

It may or may not carry a default value.

Attributes:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this out-dated, or is this the accepted convention? That is, should this list be "name, type, default_value" or as below?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I should add the other attributes. thanks for catching

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't see the changes. Not sure if something's wrong with what I am seeing, or the change was not pushed.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

image

Is this the same view you saw?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Wait so was this good or did you mean something else?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I guess I am trying to understand the conventions here. The current form makes sense as the "public interface" exposed. Technically, however, default_value is also an attribute. Is the idea that it is "private"? Would renaming default_value to _default_value be appropriate?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added default_value. Thanks!

…tion` | chore(irbuilder)"


Merge the two list in `IRFunction` by changing its type to `IRAttributeParameter`. This way we retain type information for all attributes. It is useful for creating correct `OpSchema`s and `ParamSchema`s in the next PR.

Also Include `typeinfo` in `add_attr_parameter`.

[ghstack-poisoned]
…builder)"


Merge the two list in `IRFunction` by changing its type to `IRAttributeParameter`. This way we retain type information for all attributes. It is useful for creating correct `OpSchema`s and `ParamSchema`s in the next PR.

Also Include `typeinfo` in `add_attr_parameter`.

[ghstack-poisoned]
…tion` | chore(irbuilder)"


Merge the two list in `IRFunction` by changing its type to `IRAttributeParameter`. This way we retain type information for all attributes. It is useful for creating correct `OpSchema`s and `ParamSchema`s in the next PR.

Also Include `typeinfo` in `add_attr_parameter`.

[ghstack-poisoned]
…builder)"


Merge the two list in `IRFunction` by changing its type to `IRAttributeParameter`. This way we retain type information for all attributes. It is useful for creating correct `OpSchema`s and `ParamSchema`s in the next PR.

Also Include `typeinfo` in `add_attr_parameter`.

[ghstack-poisoned]
@justinchuby justinchuby merged commit 5701cbf into main Apr 14, 2023
@justinchuby justinchuby deleted the gh/justinchuby/15/head branch April 14, 2023 21:39
Indie365 pushed a commit to Indie365/onnxscript that referenced this pull request Oct 26, 2023
ghstack-source-id: 24c2201
Pull Request resolved: microsoft/onnxscript#625

Signed-off-by: Justin Chu <[email protected]>
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.

3 participants