KEMBAR78
Add necessary lowerings and decompositions to run adaptive_avg_pool2d by lezcano · Pull Request #1121 · pytorch/torchdynamo · GitHub
Skip to content
This repository was archived by the owner on Aug 1, 2025. It is now read-only.

Conversation

@lezcano
Copy link
Contributor

@lezcano lezcano commented Sep 2, 2022

…_avg_pool2d"

As per title.

[ghstack-poisoned]
lezcano added a commit that referenced this pull request Sep 2, 2022
As per title.

ghstack-source-id: bf8e972
Pull Request resolved: #1121
@lezcano lezcano requested a review from jansel September 2, 2022 19:38
@lezcano
Copy link
Contributor Author

lezcano commented Sep 2, 2022

Done!

…_avg_pool2d"

As per title.

[ghstack-poisoned]
lezcano added a commit that referenced this pull request Sep 2, 2022
As per title.

ghstack-source-id: 5797f34
Pull Request resolved: #1121
@jansel
Copy link
Contributor

jansel commented Sep 2, 2022

It would be good to have a test for signbit

aten.expand_as,
aten.flip,
aten.floor_divide.default,
aten.fmod.Tensor,
Copy link

@ngimel ngimel Sep 3, 2022

Choose a reason for hiding this comment

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

even though nominally we have fmod decomposition, attempting to use it leads to

def forward(self, arg0_1, arg1_1):
    fmod = torch.ops.prims.fmod.default(arg0_1, arg1_1);  arg0_1 = arg1_1 = None
    return (fmod,)
    
torchinductor.graph: [WARNING] Creating implicit fallback for:
  target: prims.fmod.default
  args[0]: TensorBox(StorageBox(
    InputBuffer(name='arg0_1', layout=FixedLayout('cuda', torch.int32, size=[s0], stride=[1]))
  ))
  args[1]: TensorBox(StorageBox(
    InputBuffer(name='arg1_1', layout=FixedLayout('cuda', torch.int32, size=[s0], stride=[1]))
  ))
torchinductor.ir: [WARNING] Using FallbackKernel: torch.ops.prims.fmod.default

(because decomposition just calls directly into prim)
so again we'd either have to write a real decomposition on the pytorch side, or lowering on the inductor side to support fmod.
Libdevice has fmod, there's also std::fmod so we should just add lowering

@jansel jansel self-requested a review September 3, 2022 02:06
…_avg_pool2d"

As per title.

[ghstack-poisoned]
lezcano added a commit that referenced this pull request Sep 5, 2022
As per title.

ghstack-source-id: dba2ed5
Pull Request resolved: #1121
@lezcano
Copy link
Contributor Author

lezcano commented Sep 5, 2022

Done. I also added some tests. For signbit, there was no equivalent triton function, so I added an implementation. The implementation is not 100% correct, as it would return 1 for the case -0.0 (ikr). In triton they have this implementation, probably taken from some STL:
https://github.com/openai/triton/blob/52d311f30208605add1c65695d071196319de76b/include/triton/external/half.hpp#L430-L442
which implementation should we have for CUDA?

…_avg_pool2d"

As per title.

[ghstack-poisoned]
lezcano added a commit that referenced this pull request Sep 5, 2022
As per title.

ghstack-source-id: d0b3e63
Pull Request resolved: #1121
…_avg_pool2d"

As per title.

[ghstack-poisoned]
lezcano added a commit that referenced this pull request Sep 5, 2022
As per title.

ghstack-source-id: dabf7cf
Pull Request resolved: #1121
…_avg_pool2d"

As per title.

[ghstack-poisoned]
lezcano added a commit that referenced this pull request Sep 6, 2022
As per title.

ghstack-source-id: 2ec80c8
Pull Request resolved: #1121
@lezcano
Copy link
Contributor Author

lezcano commented Sep 6, 2022

The error seems unrelated

…_avg_pool2d"

As per title.

[ghstack-poisoned]
lezcano added a commit that referenced this pull request Sep 7, 2022
As per title.

ghstack-source-id: bb371b0
Pull Request resolved: #1121
@lezcano
Copy link
Contributor Author

lezcano commented Sep 7, 2022

@ngimel @jansel these two PRs should be ready. I don't know what needs doing with the first PR of the stack, but I don't seem to be able to re-open it. Should I open a new one?

@desertfire desertfire merged commit 43d6055 into gh/Lezcano/2/base Sep 7, 2022
@lezcano
Copy link
Contributor Author

lezcano commented Sep 7, 2022

Ok, this PR had the same issue as described here #1120 (comment). Please tell me if I need to do anything on my side to fix this.

@lezcano lezcano deleted the gh/Lezcano/2/head branch September 8, 2022 08:57
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.

5 participants