Skip to content

Introduced AliasInfo for OpInfo#50368

Closed
vfdev-5 wants to merge 14 commits intopytorch:masterfrom
Quansight:add-opinfo-aliases
Closed

Introduced AliasInfo for OpInfo#50368
vfdev-5 wants to merge 14 commits intopytorch:masterfrom
Quansight:add-opinfo-aliases

Conversation

@vfdev-5
Copy link
Copy Markdown
Contributor

@vfdev-5 vfdev-5 commented Jan 11, 2021

Introduced AliasInfo for OpInfo.

Context: Split of #49158

cc @mruberry , please let me know if you'd like to see here more code to cover

[ ] fold test_op_aliases.py into OpInfo-based testing in test_ops.py

from #50006

and/or add UnaryUfuncInfo('abs') as discussed https://github.com/pytorch/pytorch/pull/49158/files#r548774221

@facebook-github-bot
Copy link
Copy Markdown
Contributor

facebook-github-bot commented Jan 11, 2021

💊 CI failures summary and remediations

As of commit 3d32fa4 (more details on the Dr. CI page):


💚 💚 Looks good so far! There are no failures yet. 💚 💚


This comment was automatically generated by Dr. CI (expand for details).Follow this link to opt-out of these comments for your Pull Requests.

Please report bugs/suggestions to the (internal) Dr. CI Users group.

@codecov
Copy link
Copy Markdown

codecov Bot commented Jan 11, 2021

Codecov Report

Merging #50368 (3d32fa4) into master (f7e90cf) will decrease coverage by 0.15%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master   #50368      +/-   ##
==========================================
- Coverage   80.87%   80.72%   -0.16%     
==========================================
  Files        1931     1931              
  Lines      210690   210701      +11     
==========================================
- Hits       170406   170085     -321     
- Misses      40284    40616     +332     

@zhangguanheng66 zhangguanheng66 added module: testing Issues related to the torch.testing module (not tests) triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module labels Jan 11, 2021
Comment thread torch/testing/_internal/common_methods_invocations.py Outdated
@mruberry
Copy link
Copy Markdown
Collaborator

mruberry commented Jan 13, 2021

Hey @vfdev-5, this is exactly what I was thinking. I think we should extend this PR a little further like you suggest.

Let's port

def _test_jit_op_alias_normalization(self, device, info=info):

and

def _test_alias_computation(self, device, info=info):

to test_ops.py and update to be run on OpInfos that have one or more AliasInfos. This is going to be a little tricky because you'll have to separate those tests from the custom test generator they're in. The original tests should remain for now, too, until we port all the aliases in test_op_aliases.py to OpInfo metadata. To test that these two new alias tests are working properly we can add an AliasInfo to acos:

AliasInfo('arccos', torch.arccos, 'acos', torch.acos,

And remove the arccos entries from alias_infos.

Then after we get the new tests working and demonstrate that by updating an existing OpInfo to use the pattern we can follow-up by porting the other alias_infos and delete test_op_aliases.py. Sound good?

@vfdev-5
Copy link
Copy Markdown
Contributor Author

vfdev-5 commented Jan 13, 2021

@mruberry thanks a lot for the review and a thourough description on the improvements ! Sounds great ! Let me update the PR and I'll let you know once it is ready for another review round.

Comment thread test/test_ops.py Outdated
Comment thread test/test_ops.py Outdated
@vfdev-5 vfdev-5 requested a review from mruberry January 20, 2021 00:51
@vfdev-5 vfdev-5 force-pushed the add-opinfo-aliases branch from 6a835d1 to 306420b Compare January 25, 2021 10:35
Comment thread torch/testing/_internal/common_methods_invocations.py Outdated
Comment thread torch/testing/_internal/common_methods_invocations.py Outdated
Comment thread test/test_ops.py Outdated
Comment thread test/test_ops.py Outdated
Comment thread test/test_ops.py Outdated
Comment thread test/test_ops.py Outdated
Comment thread test/test_ops.py Outdated
Copy link
Copy Markdown
Collaborator

@mruberry mruberry left a comment

Choose a reason for hiding this comment

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

Hey @vfdev-5! This is really cool. All the OpInfo changes look great. I have two questions about the tests which I inline, but can be summarized as:

  • for the eager consistency test, should we just add alias variants as variants?
  • for the jit consistency test, should we just check that the jit correctly remaps the operation in jit graphs, instead, like the current alias tests do?

Looking forward to hearing your thoughts. This new approach to alias testing (having to just add one alias line in an OpInfo) is way better than the old approach.

Last issue is that this should update this guidance:

# 7) Add entries to test/test_op_aliases.py's "alias_infos"

to reflect the new approach. Basically I think we should tell people to add the line to an op's OpInfo if the OpInfo exists, and add the OpInfo (and then add the line) if it doesn't exist.

Comment thread torch/testing/_internal/common_methods_invocations.py
- jit_name_remapping instead jit consistency
- removed auto generated tests for abs
- added aliases tests inside test_variant_consistency_eager
- added aliases tests to test_out
Comment thread test/test_ops.py Outdated
Comment thread test/test_ops.py Outdated
Comment thread test/test_ops.py
Comment thread test/test_ops.py Outdated
Comment thread torch/testing/_internal/common_methods_invocations.py Outdated
- added jit scripting in test_jit_alias_remapping
- etc
Comment thread test/test_ops.py
_test(a_op)

@ops([op for op in op_db if op.aliases])
def test_jit_alias_remapping(self, device, dtype, op):
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@eellison would you take a look at this port of the test from test_op_aliases.py? @vfdev-5 is creating a version of that test that uses OpInfos instead of the custom AliasInfos that test_op_aliases.py uses. The idea is to eventually remove the AliasInfos by adding their metadata to OpInfos.

@eellison eellison self-requested a review January 27, 2021 17:44
@vfdev-5
Copy link
Copy Markdown
Contributor Author

vfdev-5 commented Feb 1, 2021

@eellison could you please review this PR in order to unblock other PRs. Thanks !

Copy link
Copy Markdown
Contributor

@eellison eellison left a comment

Choose a reason for hiding this comment

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

LGTM

@mruberry mruberry self-requested a review February 1, 2021 17:38
Copy link
Copy Markdown
Collaborator

@mruberry mruberry left a comment

Choose a reason for hiding this comment

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

Cool! Thanks @vfdev-5! It's great to have the architecture to further simplify our test suite by making alias testing as simple as adding a line of metadata to an OpInfo.

Copy link
Copy Markdown
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

@mruberry has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@vfdev-5 vfdev-5 deleted the add-opinfo-aliases branch February 2, 2021 08:39
@facebook-github-bot
Copy link
Copy Markdown
Contributor

@mruberry merged this pull request in b106250.

facebook-github-bot pushed a commit that referenced this pull request Feb 10, 2021
Summary:
Description:
- Added clamp, trunc tests with aliases
- Added tests for aliases for asin(h), acos(h), etc
- fixed 'fix' alias implementation
- fixed annotations in test_jit_alias_remapping
- updated native_functions.yaml aliases guidelines

Blocked by #50368

cc mruberry

Pull Request resolved: #51167

Reviewed By: gchanan

Differential Revision: D26245753

Pulled By: mruberry

fbshipit-source-id: e17b657f0515139735a8a677b1ae284904f98aef
xsacha pushed a commit to xsacha/pytorch that referenced this pull request Mar 31, 2021
Summary:
Description:
- Added clamp, trunc tests with aliases
- Added tests for aliases for asin(h), acos(h), etc
- fixed 'fix' alias implementation
- fixed annotations in test_jit_alias_remapping
- updated native_functions.yaml aliases guidelines

Blocked by pytorch#50368

cc mruberry

Pull Request resolved: pytorch#51167

Reviewed By: gchanan

Differential Revision: D26245753

Pulled By: mruberry

fbshipit-source-id: e17b657f0515139735a8a677b1ae284904f98aef
laurentdupin pushed a commit to laurentdupin/pytorch that referenced this pull request Apr 24, 2026
Summary:
Introduced AliasInfo for OpInfo.

Context: Split of pytorch#49158

cc mruberry , please let me know if you'd like to see here more code to cover

> [ ] fold test_op_aliases.py into OpInfo-based testing in test_ops.py

from pytorch#50006

and/or add `UnaryUfuncInfo('abs')` as discussed https://github.com/pytorch/pytorch/pull/49158/files#r548774221

Pull Request resolved: pytorch#50368

Reviewed By: ngimel

Differential Revision: D26177261

Pulled By: mruberry

fbshipit-source-id: 2e3884a387e8d5365fe05945375f0a9d1b5f5d82
laurentdupin pushed a commit to laurentdupin/pytorch that referenced this pull request Apr 24, 2026
Summary:
Description:
- Added clamp, trunc tests with aliases
- Added tests for aliases for asin(h), acos(h), etc
- fixed 'fix' alias implementation
- fixed annotations in test_jit_alias_remapping
- updated native_functions.yaml aliases guidelines

Blocked by pytorch#50368

cc mruberry

Pull Request resolved: pytorch#51167

Reviewed By: gchanan

Differential Revision: D26245753

Pulled By: mruberry

fbshipit-source-id: e17b657f0515139735a8a677b1ae284904f98aef
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla signed Merged module: testing Issues related to the torch.testing module (not tests) open source triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants