Skip to content

Refactor and normalization of mhlo convolutions - #4113

Merged
rsuderman merged 5 commits into
iree-org:mainfrom
rsuderman:ConvolutionRefactor
Dec 9, 2020
Merged

rsuderman merged 5 commits into
iree-org:mainfrom
rsuderman:ConvolutionRefactor

Conversation

@rsuderman

Copy link
Copy Markdown
Collaborator

Added a refactor to normalize convolution values. This is designed to decompose and simplify
convolutions for use with IREE's compiler passes. The different dimension orders are not
usually constructed via the TF compilation pass but are technically legal.

@google-cla google-cla Bot added the cla: yes label Dec 7, 2020
@rsuderman
rsuderman requested a review from ScottTodd December 7, 2020 20:12
@ScottTodd ScottTodd added the compiler/dialects Relating to the IREE compiler dialects (flow, hal, vm) label Dec 7, 2020

@ScottTodd ScottTodd left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Code seems ok, I'm wondering if this is the right place for it and why it needs to exist though.

Can you elaborate on how this simplifies IREE's compiler passes? How does this affect other projects? Would they be indifferent, or would they similarly benefit from this normalization/canonicalization?

Comment on lines +232 to +234
// Guarantee that the input dimensions are ordered batch, spatial_dims, feature
// dim.
class ReorderConvOpInputDimensions : public OpRewritePattern<mhlo::ConvOp> {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Would this make more sense as a canonicalization on mhlo::ConvOp upstream? Or a structural change to mhlo to just order them consistently wherever they are created?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Would this make more sense as a canonicalization on mhlo::ConvOp upstream?

Personally I would think it does however technically that goes against how the main
XLA backend works. Because they generate using the convolution attributes these kind of
decompositions are usually discouraged.

Or a structural change to mhlo to just order them consistently wherever they are created?

If this were only a matter of a couple locations, this would be fine, however we can get
XLA from a couple different sources (mlir xla-builder, xla proto, TF legalization) and
guaranteeing only a single form would be difficult to guarantee.

If the XLA legalization path agrees on a similar canonical representation I would be
inclined to upstream, however thats extremely unlikely.

@rsuderman
rsuderman requested a review from ScottTodd December 8, 2020 23:53
@rsuderman
rsuderman merged commit cb1e46e into iree-org:main Dec 9, 2020
@rsuderman
rsuderman deleted the ConvolutionRefactor branch December 9, 2020 18:22
This was referenced Dec 10, 2020
@hanhanW hanhanW mentioned this pull request Dec 10, 2020
copybara-service Bot pushed a commit that referenced this pull request Dec 10, 2020
* 1b71cac Adding hal.interface.workgroup.* ops. (#4149)
* 04b7c37 Add ctests for the tensorflow/e2e directory.
* c3fc9a1 Remove all !r from python f-strings (#4157)
* fdb88b9 improve tracy docs (#4117)
* 204f652 Write the doc page on profiling cpu events (#4126)
* 613efa8 Add build instructions to python getting started (#4153)
* d889ac1 Revert "Fix missing f-string (#4150)"
* aaa08b1 Enable dylib-llvm-aot tests and switch from testing JIT to AOT. (#3928)
* cb1e46e Refactor and normalization of mhlo convolutions (#4113)
* 0590b3c Fix missing f-string (#4150)
* 2f7cab5 Check in BuildKite pipeline for android tests (#4137)
* c195ae9 Fix types for std::min on MSVC. (#4148)
* 5fefe30 Integrate MLIR-EmitC at iml130/mlir-emitc@a438d3b (#4145)
* f03307d Fix ImGui function in iree-run-module-vulkan-gui-main. (#4147)

COPYBARA_INTEGRATE_REVIEW=#4168 from hanhanW:main-to-google 7c443d3
PiperOrigin-RevId: 346812805
hanhanW added a commit that referenced this pull request Dec 10, 2020
* 1b71cac Adding hal.interface.workgroup.* ops. (#4149)
* 04b7c37 Add ctests for the tensorflow/e2e directory.
* c3fc9a1 Remove all !r from python f-strings (#4157)
* fdb88b9 improve tracy docs (#4117)
* 204f652 Write the doc page on profiling cpu events (#4126)
* 613efa8 Add build instructions to python getting started (#4153)
* d889ac1 Revert "Fix missing f-string (#4150)"
* aaa08b1 Enable dylib-llvm-aot tests and switch from testing JIT to AOT. (#3928)
* cb1e46e Refactor and normalization of mhlo convolutions (#4113)
* 0590b3c Fix missing f-string (#4150)
* 2f7cab5 Check in BuildKite pipeline for android tests (#4137)
* c195ae9 Fix types for std::min on MSVC. (#4148)
* 5fefe30 Integrate MLIR-EmitC at iml130/mlir-emitc@a438d3b (#4145)
* f03307d Fix ImGui function in iree-run-module-vulkan-gui-main. (#4147)

COPYBARA_INTEGRATE_REVIEW=#4168 from hanhanW:main-to-google 7c443d3
PiperOrigin-RevId: 346812805
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

compiler/dialects Relating to the IREE compiler dialects (flow, hal, vm)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants