Add pass to replace some ops with channels last variants.#20788
Add pass to replace some ops with channels last variants.#20788MartinPavella wants to merge 2 commits into
Conversation
When replacing aten.avg_pool2d` with `channels_last.avg_pool2d`, some attributes of the aten operator can be left out, and must be replaced by default values. This can either be done in the "to channels last" transformation pass, or in the definition of the operator. Adding the default attributes of the aten operator to the channels_last operator seems cleaner to me.
The pass currently supports `convolution` and `avg_pool2d`, as those are the only 2 operators with a channels last variant. The pass can be easily extended to more ops in the future.
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/20788
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit 41d0b63 with merge base 6018283 ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
|
This PR needs a
|
|
@AdrianLundell this is the first part of #20094. I am planning on introducing the second part (a pass which makes the graph contiguous) separately. |
Summary
Add a transformation pass to replace some operators with their channels last variant. Currently only
convolutionandavg_pool2dare implemented, as those are the only operators with a channels last variant. In the future, the pass can be easily extended to support more operators.Test plan
Tested by
pytest backends/transforms/test/test_replace_ops_with_channels_last_variants.py.