Skip to content
This repository was archived by the owner on Aug 1, 2025. It is now read-only.

Conversation

eellison
Copy link
Contributor

The two occurrences in torchbench of this op are both no-ops lol. When you disable the no-op optimization, the op is ~6x faster (again, for those two sets of inputs).

@ngimel
Copy link

ngimel commented Aug 23, 2022

Hm, I would think they reduce to 1x1 output and thus could be replaced by sum, not no-op?

# no-op if the same input and output
if h_in == h_out and w_in == w_out:
# TODO: do I need to copy ? _to_copy does not
return x
Copy link

Choose a reason for hiding this comment

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

better do a copy, yes (to make sure that previously run functionalization is still valid)

Copy link
Contributor

Choose a reason for hiding this comment

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

def clone(x, *, memory_format=0):

@eellison
Copy link
Contributor Author

>>> x = torch.rand(1, 1, 4, 4)
>>> y = torch.ops.aten._adaptive_avg_pool2d(x, [4, 4])
>>> (x - y).nonzero().shape
torch.Size([0, 4])

The output size is given, not the kernel size which differs from the other apis... When the output_size == input_size for adaptive average pooling, that means the kernel size will be [1, 1] and you're doing a 1-element average (no-op).

Copy link
Contributor

@jansel jansel left a comment

Choose a reason for hiding this comment

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

We should add a test for this.

Kind of funny these are no-ops, though not the first time I've seen cases like that.

# no-op if the same input and output
if h_in == h_out and w_in == w_out:
# TODO: do I need to copy ? _to_copy does not
return x
Copy link
Contributor

Choose a reason for hiding this comment

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

def clone(x, *, memory_format=0):

@eellison eellison requested review from jansel and ngimel August 23, 2022 16:14
@eellison eellison merged commit 5c18f71 into pytorch:main Aug 23, 2022
lezcano added a commit to pytorch/pytorch that referenced this pull request Aug 25, 2022
This was already implemented as a lowering in pytorch/torchdynamo#962. I'm putting the idea up here (I haven't even run this code, so it surely has *many* issues, but I reckon the general idea should hopefully be alright).

[ghstack-poisoned]
lezcano added a commit to pytorch/pytorch that referenced this pull request Aug 25, 2022
This was already implemented as a lowering in pytorch/torchdynamo#962. I'm putting the idea up here (I haven't even run this code, so it surely has *many* issues, but I reckon the general idea should hopefully be alright).

[ghstack-poisoned]
lezcano added a commit to pytorch/pytorch that referenced this pull request Aug 25, 2022
This was already implemented as a lowering in pytorch/torchdynamo#962. I'm putting the idea up here (I haven't even run this code, so it surely has *many* issues, but I reckon the general idea should hopefully be alright).

[ghstack-poisoned]
lezcano added a commit to pytorch/pytorch that referenced this pull request Aug 25, 2022
This was already implemented as a lowering in pytorch/torchdynamo#962. I'm putting the idea up here (I haven't even run this code, so it surely has *many* issues, but I reckon the general idea should hopefully be alright).

ghstack-source-id: 3875878
Pull Request resolved: #84062
lezcano added a commit to pytorch/pytorch that referenced this pull request Aug 26, 2022
This was already implemented as a lowering in pytorch/torchdynamo#962. I'm putting the idea up here (I haven't even run this code, so it surely has *many* issues, but I reckon the general idea should hopefully be alright).

[ghstack-poisoned]
lezcano added a commit to pytorch/pytorch that referenced this pull request Aug 26, 2022
This was already implemented as a lowering in pytorch/torchdynamo#962. I'm putting the idea up here (I haven't even run this code, so it surely has *many* issues, but I reckon the general idea should hopefully be alright).

[ghstack-poisoned]
lezcano added a commit to pytorch/pytorch that referenced this pull request Aug 26, 2022
This was already implemented as a lowering in pytorch/torchdynamo#962. I'm putting the idea up here (I haven't even run this code, so it surely has *many* issues, but I reckon the general idea should hopefully be alright).

[ghstack-poisoned]
lezcano added a commit to pytorch/pytorch that referenced this pull request Aug 26, 2022
This was already implemented as a lowering in pytorch/torchdynamo#962. I'm putting the idea up here (I haven't even run this code, so it surely has *many* issues, but I reckon the general idea should hopefully be alright).

[ghstack-poisoned]
lezcano added a commit to pytorch/pytorch that referenced this pull request Aug 26, 2022
This was already implemented as a lowering in pytorch/torchdynamo#962. I'm putting the idea up here (I haven't even run this code, so it surely has *many* issues, but I reckon the general idea should hopefully be alright).

[ghstack-poisoned]
lezcano added a commit to pytorch/pytorch that referenced this pull request Aug 26, 2022
This was already implemented as a lowering in pytorch/torchdynamo#962. I'm putting the idea up here (I haven't even run this code, so it surely has *many* issues, but I reckon the general idea should hopefully be alright).

[ghstack-poisoned]
lezcano added a commit to pytorch/pytorch that referenced this pull request Aug 26, 2022
This was already implemented as a lowering in pytorch/torchdynamo#962. I'm putting the idea up here (I haven't even run this code, so it surely has *many* issues, but I reckon the general idea should hopefully be alright).

[ghstack-poisoned]
lezcano added a commit to pytorch/pytorch that referenced this pull request Aug 26, 2022
This was already implemented as a lowering in pytorch/torchdynamo#962. I'm putting the idea up here (I haven't even run this code, so it surely has *many* issues, but I reckon the general idea should hopefully be alright).

[ghstack-poisoned]
lezcano added a commit to pytorch/pytorch that referenced this pull request Aug 26, 2022
This was already implemented as a lowering in pytorch/torchdynamo#962. I'm putting the idea up here (I haven't even run this code, so it surely has *many* issues, but I reckon the general idea should hopefully be alright).

[ghstack-poisoned]
lezcano added a commit to pytorch/pytorch that referenced this pull request Aug 26, 2022
This was already implemented as a lowering in pytorch/torchdynamo#962. I'm putting the idea up here (I haven't even run this code, so it surely has *many* issues, but I reckon the general idea should hopefully be alright).

[ghstack-poisoned]
lezcano added a commit to pytorch/pytorch that referenced this pull request Aug 26, 2022
This was already implemented as a lowering in pytorch/torchdynamo#962. I'm putting the idea up here (I haven't even run this code, so it surely has *many* issues, but I reckon the general idea should hopefully be alright).

ghstack-source-id: 0473704
Pull Request resolved: #84062
lezcano added a commit to pytorch/pytorch that referenced this pull request Aug 26, 2022
This was already implemented as a lowering in pytorch/torchdynamo#962. I'm putting the idea up here ~(I haven't even run this code, so it surely has *many* issues, but I reckon the general idea should hopefully be alright).~ The tests now pass and I corrected the issues that the first implementation had.

[ghstack-poisoned]
lezcano added a commit to pytorch/pytorch that referenced this pull request Aug 26, 2022
This was already implemented as a lowering in pytorch/torchdynamo#962. I'm putting the idea up here ~(I haven't even run this code, so it surely has *many* issues, but I reckon the general idea should hopefully be alright).~ The tests now pass and I corrected the issues that the first implementation had.

[ghstack-poisoned]
lezcano added a commit to pytorch/pytorch that referenced this pull request Aug 27, 2022
This was already implemented as a lowering in pytorch/torchdynamo#962. I'm putting the idea up here ~(I haven't even run this code, so it surely has *many* issues, but I reckon the general idea should hopefully be alright).~ The tests now pass and I corrected the issues that the first implementation had.

[ghstack-poisoned]
lezcano added a commit to pytorch/pytorch that referenced this pull request Aug 27, 2022
This was already implemented as a lowering in pytorch/torchdynamo#962. I'm putting the idea up here ~(I haven't even run this code, so it surely has *many* issues, but I reckon the general idea should hopefully be alright).~ The tests now pass and I corrected the issues that the first implementation had.

[ghstack-poisoned]
lezcano added a commit to pytorch/pytorch that referenced this pull request Aug 27, 2022
This was already implemented as a lowering in pytorch/torchdynamo#962. I'm putting the idea up here (I haven't even run this code, so it surely has *many* issues, but I reckon the general idea should hopefully be alright).

ghstack-source-id: 09e090f
Pull Request resolved: #84062
lezcano added a commit to pytorch/pytorch that referenced this pull request Aug 28, 2022
This was already implemented as a lowering in pytorch/torchdynamo#962. I'm putting the idea up here (I haven't even run this code, so it surely has *many* issues, but I reckon the general idea should hopefully be alright).

ghstack-source-id: 656a53e
Pull Request resolved: #84062
lezcano added a commit to pytorch/pytorch that referenced this pull request Aug 28, 2022
This was already implemented as a lowering in pytorch/torchdynamo#962. I'm putting the idea up here ~(I haven't even run this code, so it surely has *many* issues, but I reckon the general idea should hopefully be alright).~ The tests now pass and I corrected the issues that the first implementation had.

[ghstack-poisoned]
lezcano added a commit to pytorch/pytorch that referenced this pull request Aug 28, 2022
This was already implemented as a lowering in pytorch/torchdynamo#962. I'm putting the idea up here ~(I haven't even run this code, so it surely has *many* issues, but I reckon the general idea should hopefully be alright).~ The tests now pass and I corrected the issues that the first implementation had.

[ghstack-poisoned]
pytorchmergebot pushed a commit to pytorch/pytorch that referenced this pull request Aug 28, 2022
This was already implemented as a lowering in pytorch/torchdynamo#962. I'm putting the idea up here ~(I haven't even run this code, so it surely has *many* issues, but I reckon the general idea should hopefully be alright).~ The tests now pass and I corrected the issues that the first implementation had.
Pull Request resolved: #84062
Approved by: https://github.com/jansel
pytorchmergebot pushed a commit to pytorch/pytorch that referenced this pull request Aug 29, 2022
This was already implemented as a lowering in pytorch/torchdynamo#962. I'm putting the idea up here ~(I haven't even run this code, so it surely has *many* issues, but I reckon the general idea should hopefully be alright).~ The tests now pass and I corrected the issues that the first implementation had.
Pull Request resolved: #84062
Approved by: https://github.com/jansel
facebook-github-bot pushed a commit to pytorch/pytorch that referenced this pull request Aug 29, 2022
Summary:
This was already implemented as a lowering in pytorch/torchdynamo#962. I'm putting the idea up here ~(I haven't even run this code, so it surely has *many* issues, but I reckon the general idea should hopefully be alright).~ The tests now pass and I corrected the issues that the first implementation had.

Pull Request resolved: #84062
Approved by: https://github.com/jansel

Test Plan: contbuild & OSS CI, see https://hud.pytorch.org/commit/pytorch/pytorch/9fc02f6bc558f26a460241cbeaea915ea2b41005

Reviewed By: weiwangmeta

Differential Revision: D39091747

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants