[GlobalOpt] Support Img2Col Transformation for Conv2D Including Quantized Types#23278
[GlobalOpt] Support Img2Col Transformation for Conv2D Including Quantized Types#23278hanhanW merged 5 commits intoiree-org:mainfrom
Conversation
MaheshRavishankar
left a comment
There was a problem hiding this comment.
Thanks, but we cannot have the global optimization depend on preprocessing pass pipelines. Adding Global optimization to run some pre-processing pass pipeline is an inversion of dependencies. Could you describe what you are trying to see if there is a different way to approach this. In general using im2col at this level is not the best way to handle convs.
|
@MaheshRavishankar Thanks for the clarification. We observed that ConvertConv2DToImg2ColPass only handles a limited set of conv ops, so quantized models using QuantizedConv are not covered. While QuantizedConvToConvPass can handle this, it currently resides in GlobalOptimization. Our goal is to understand the intended lowering path for QuantizedConv and whether there is a more appropriate place to handle this without introducing dependency inversion. We’re open to alternative approaches and would appreciate guidance on the recommended direction. |
I think one option here is to use the Broadly if you have a proposal for moving some of the pre-processing pass pipelines into IREE global optimization phase we can definitely iterate on that. In this particular case, converting a convolution using im2col this early is typically seen as an anti-pattern due to the high replication this entails. We would prefer to try to handle the convolutions more natively and fix the backend code-generator to handle that better. That is a lot of work, so if you want to use the im2col approach as a stop-gap then I think the |
@MaheshRavishankar Thank you for the suggestion. We agree that iree-preprocessing-pass-pipeline is useful for experimentation and prototyping.
We're thinking that moving the im2col pass to GlobalOptimization with an opt-in flag could be a good fit for our scenario while avoiding the anti-pattern concern for backends that don't need it. We'll prepare a proposal with more details and rationale. Happy to iterate based on your feedback. |
5292a97 to
9ea4d0b
Compare
|
Thanks for taking the time to review! @MaheshRavishankar @benvanik @qedawkins @IanWood1 Please feel free to let me know if there's anything I can do to help with the next steps. |
2444d8a to
6706448
Compare
|
Rebased only. |
|
@MaheshRavishankar Could anyone help merge this PR : )? |
|
Ok, let me check if CI passes. cc @hanhanW as well to merge if everything passes. |
hanhanW
left a comment
There was a problem hiding this comment.
I can help trigger CI and merge it, please fix the failures.
|
Hi @hanhanW, the pre-commit workflow failure seems to be caused by a temporary GitHub Actions service issue during the setup phase. Re-running the workflow might resolve the problem. |
ooops, it ran for 2 mins, so I did not click into the link. Re-running the jobs now. |
|
Here is the new log from lint: https://github.com/iree-org/iree/actions/runs/22607978256/job/65965929632?pr=23278 You can run |
Move the Conv2D to Img2Col transformation pass from Preprocessing to GlobalOptimization phase. This allows the pass to run after LinalgQuantizedConvToConvPass, enabling quantized convolutions to benefit from the img2col transformation. Signed-off-by: Phoebe Chen <phoebe.chen@sifive.com>
…tion Add --iree-global-opt-enable-conv2d-to-img2col flag to enable the transformation. The pass is disabled by default and runs after LinalgQuantizedConvToConvPass in the global optimization pipeline. Signed-off-by: Phoebe Chen <phoebe.chen@sifive.com>
Move test file from Preprocessing to GlobalOptimization and update preprocessing_flags.mlir to remove references to the moved pass. Signed-off-by: Phoebe Chen <phoebe.chen@sifive.com>
- Rename option from enableConv2DToImg2Col to useIm2colForConvs - Update CLI flag from enable-conv2d-to-img2col to use-im2col-for-convs - Update pipeline flag from iree-global-opt-enable-conv2d-to-img2col to iree-global-opt-use-im2col-for-convs Signed-off-by: Phoebe Chen <phoebe.chen@sifive.com>
Signed-off-by: Phoebe Chen <phoebe.chen@sifive.com>
0d06a72 to
52a4579
Compare
@hanhanW Formatting fix applied. Thanks! |
Move the Conv2D to Img2Col transformation pass from Preprocessing to GlobalOptimization phase. This allows the pass to run after LinalgQuantizedConvToConvPass, enabling quantized convolutions to benefit from the img2col transformation.