Skip to content

[JIT] add support for torch.norm#33783

Closed
eellison wants to merge 10 commits intogh/eellison/58/basefrom
gh/eellison/58/head
Closed

[JIT] add support for torch.norm#33783
eellison wants to merge 10 commits intogh/eellison/58/basefrom
gh/eellison/58/head

Conversation

@eellison
Copy link
Copy Markdown
Contributor

@eellison eellison commented Feb 25, 2020

Stack from ghstack:

Fix for #20113

Differential Revision: D20121917

[ghstack-poisoned]
eellison pushed a commit that referenced this pull request Feb 25, 2020
ghstack-source-id: 7ccc4f7
Pull Request resolved: #33783
Comment thread torch/functional.py Outdated
elif dtype is None:
return torch._C._VariableFunctions.norm(input, p, dim, keepdim=keepdim, out=out)
return torch._C._VariableFunctions.norm(input, p, dim, keepdim=keepdim, dtype=dtype, out=out)
dim = [i for i in range(ndim)] # noqa: C416 TODO: rewrite as list(range(m))
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 noticed this in at least one other preceding PR as well, perhaps we could consider adding this as a separate function to reduce duplicate code.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Sounds good. I’m also going to try to add list(range()) support to TS in the next week

Comment thread test/test_jit.py

def norm():
c = torch.tensor([[1, 2, 3], [-1, 1, 4]], dtype=torch.float)
return torch.norm(c, p="fro"), torch.norm(c, p="nuc"), torch.norm(c), torch.norm(c, p=.5)
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.

Is it not necessary to test with different function arguments, or are they left out since they are covered by standard tests in test_torch

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yea, I was mostly testing that it compiles with different types of arguments. Since test_torch tests with different argument values and the code is the same for python/TorchScript, that should be sufficient

@dr-ci
Copy link
Copy Markdown

dr-ci Bot commented Feb 25, 2020

💊 CircleCI build failures summary and remediations

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


Commit ce36b72 was recently pushed. Waiting for builds...


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 on the GitHub issue tracker.

This comment has been revised 51 times.

eellison pushed a commit that referenced this pull request Mar 2, 2020
ghstack-source-id: e3f6db5
Pull Request resolved: #33783
@facebook-github-bot
Copy link
Copy Markdown
Contributor

@eellison merged this pull request in 479c3b0.

@facebook-github-bot facebook-github-bot deleted the gh/eellison/58/head branch March 9, 2020 14:16
@eellison eellison mentioned this pull request Apr 7, 2020
facebook-github-bot pushed a commit that referenced this pull request Apr 7, 2020
Summary:
Relanding #33783
Pull Request resolved: #36146

Differential Revision: D20895316

Pulled By: eellison

fbshipit-source-id: 9a2bc0e6bdcbd43f9abe51eadaa28f90bccafcc9
ashishfarmer pushed a commit to ashishfarmer/pytorch that referenced this pull request Apr 13, 2020
Summary:
Relanding pytorch#33783
Pull Request resolved: pytorch#36146

Differential Revision: D20895316

Pulled By: eellison

fbshipit-source-id: 9a2bc0e6bdcbd43f9abe51eadaa28f90bccafcc9
facebook-github-bot pushed a commit that referenced this pull request May 13, 2020
Summary:
Fix for #37986

Follows the stack in #33783 stack to make functions in `torch/functional.py` resolve to their python implementations. Because the return type of `torch.unique` depends on `return_inverse` and `return_counts` I had to refactor the implementation to use our boolean_dispatch mechanism.
Pull Request resolved: #38156

Differential Revision: D21504449

Pulled By: eellison

fbshipit-source-id: 7efb1dff3b5c00655da10168403ac4817286ff59
gchanan pushed a commit to gchanan/pytorch that referenced this pull request Jun 1, 2020
Summary:
Fix for pytorch#37986

Follows the stack in pytorch#33783 stack to make functions in `torch/functional.py` resolve to their python implementations. Because the return type of `torch.unique` depends on `return_inverse` and `return_counts` I had to refactor the implementation to use our boolean_dispatch mechanism.
Pull Request resolved: pytorch#38156

Differential Revision: D21504449

Pulled By: eellison

fbshipit-source-id: 7efb1dff3b5c00655da10168403ac4817286ff59
gchanan pushed a commit that referenced this pull request Jun 2, 2020
Summary:
Fix for #37986

Follows the stack in #33783 stack to make functions in `torch/functional.py` resolve to their python implementations. Because the return type of `torch.unique` depends on `return_inverse` and `return_counts` I had to refactor the implementation to use our boolean_dispatch mechanism.
Pull Request resolved: #38156

Differential Revision: D21504449

Pulled By: eellison

fbshipit-source-id: 7efb1dff3b5c00655da10168403ac4817286ff59
laurentdupin pushed a commit to laurentdupin/pytorch that referenced this pull request Apr 24, 2026
Summary:
Pull Request resolved: pytorch#33783

Fix for pytorch#20113

Test Plan: Imported from OSS

Differential Revision: D20121917

Pulled By: eellison

fbshipit-source-id: ffedcc40678cd80f5529ff9323088eed544e5158
laurentdupin pushed a commit to laurentdupin/pytorch that referenced this pull request Apr 24, 2026
Summary:
Relanding pytorch#33783
Pull Request resolved: pytorch#36146

Differential Revision: D20895316

Pulled By: eellison

fbshipit-source-id: 9a2bc0e6bdcbd43f9abe51eadaa28f90bccafcc9
laurentdupin pushed a commit to laurentdupin/pytorch that referenced this pull request Apr 24, 2026
Summary:
Fix for pytorch#37986

Follows the stack in pytorch#33783 stack to make functions in `torch/functional.py` resolve to their python implementations. Because the return type of `torch.unique` depends on `return_inverse` and `return_counts` I had to refactor the implementation to use our boolean_dispatch mechanism.
Pull Request resolved: pytorch#38156

Differential Revision: D21504449

Pulled By: eellison

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

Labels

Merged oncall: jit Add this issue/PR to JIT oncall triage queue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants