Skip to content

[CodeGen] Avoid eliminating output store unconditionally - #5073

Merged
antiagainst merged 2 commits into
iree-org:mainfrom
antiagainst:fix-bufferize
Mar 12, 2021
Merged

antiagainst merged 2 commits into
iree-org:mainfrom
antiagainst:fix-bufferize

Conversation

@antiagainst

Copy link
Copy Markdown
Member

In LinalgBufferizePass, we first create memref counterparts for all
hal.interface.binding.subspan ops. So for flow.dispatch.tensor.store,
the target will always have a mapped-to value. If its value's
producer is a Linalg op, the Linalg op will perform operations
in place when converted to buffers. For such cases we can remove
the flow.dispatch.tensor.store op. Otherwise, we cannot, as we may
see the degenerated case where we immediately store after loading
a buffer.

In LinalgBufferizePass, we first create memref counterparts for all
hal.interface.binding.subspan ops. So for flow.dispatch.tensor.store,
the target will always have a mapped-to value. If its value's
producer is a Linalg op, the Linalg op will perform operations
in place when converted to buffers. For such cases we can remove
the flow.dispatch.tensor.store op. Otherwise, we cannot, as we may
see the degenerated case where we immediately store after loading
a buffer.
// cases, we can just remove this store.
auto storeTo = bvm.lookup(storeOp.target())
.getDefiningOp<IREE::HAL::InterfaceBindingSubspanOp>();
auto storeFrom = bvm.lookup(storeOp.value())

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The value could also be a subview (like I mentioned in the previous comment). See preProcessInterfaceStoreTensorOp

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Actually on second thought, this might be safer. Lets go with this for now and revisit later.

// cases, we can just remove this store.
auto storeTo = bvm.lookup(storeOp.target())
.getDefiningOp<IREE::HAL::InterfaceBindingSubspanOp>();
auto storeFrom = bvm.lookup(storeOp.value())

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Actually on second thought, this might be safer. Lets go with this for now and revisit later.

@antiagainst
antiagainst merged commit e16759c into iree-org:main Mar 12, 2021
@antiagainst
antiagainst deleted the fix-bufferize branch March 12, 2021 22:40
copybara-service Bot pushed a commit that referenced this pull request Mar 12, 2021
* 161f932 Enable CUDA tests on Turing platforms (#5091)
* e16759c [CodeGen] Avoid eliminating output store unconditionally (#5073)
* e2fe13e Add wasm-micro-runtime submodule and get building with CMake. (#5077)
* 33c4e39 Bump Tracy submodule to v0.7.6. (#5094)
* 3f6335f Use correct tied operand index when creating DispatchWorkgroupsOp (#5090)
* e5cfa53 Allow all matmul variants to be a root op (#5065)
* a5a0f1d Merge google -> main (#5086)
* 1ef76ba Merge pull request #5083 from google/benvanik-flow-passes
* 0668b55 Configure compiler to generate 'wasm' executables using wasm-llvm-aot. (#5079)
* 6d41b9d Create InitTensorOp based on input operand shapes. (#5070)
* bb819df Shuffling the SIP reflection attrs pass around a bit. This is in preparation f..
* 6b63dac Fixing deprecation warning.
* 5c5d2aa Removing old identify dispatch regions. Not yet the new old identify dispatch ..
* 80cdcce Splitting out input passes from flow passes. Eventually the TOSA/HLO stuff wil..
* a2a464d Add missing CMake dep (#5081)
* ca29d25 [CodeGen] NFC: Rename LinalgTileAndFusePass (#5075)
* f3d7654 Add MobileNetV2 to benchmarking targets. (#5064)
* 8aace66 Rename CMake target DYLIB-LLVM-AOT to just LLVM-AOT.
* 98f2135 Add WASM executable format and produce it with LLVMAOTTarget.
* 2795092 Add CMake configuration for WAMR's runtime "iwasm VM core".
* 2b5c7b9 Add third_party/wasm-micro-runtime submodule.

COPYBARA_INTEGRATE_REVIEW=#5097 from ThomasRaoux:main-to-google 161f932
PiperOrigin-RevId: 362617674
iree-github-actions-bot pushed a commit that referenced this pull request Mar 12, 2021
* 161f932 Enable CUDA tests on Turing platforms (#5091)
* e16759c [CodeGen] Avoid eliminating output store unconditionally (#5073)
* e2fe13e Add wasm-micro-runtime submodule and get building with CMake. (#5077)
* 33c4e39 Bump Tracy submodule to v0.7.6. (#5094)
* 3f6335f Use correct tied operand index when creating DispatchWorkgroupsOp (#5090)
* e5cfa53 Allow all matmul variants to be a root op (#5065)
* a5a0f1d Merge google -> main (#5086)
* 1ef76ba Merge pull request #5083 from google/benvanik-flow-passes
* 0668b55 Configure compiler to generate 'wasm' executables using wasm-llvm-aot. (#5079)
* 6d41b9d Create InitTensorOp based on input operand shapes. (#5070)
* bb819df Shuffling the SIP reflection attrs pass around a bit. This is in preparation f..
* 6b63dac Fixing deprecation warning.
* 5c5d2aa Removing old identify dispatch regions. Not yet the new old identify dispatch ..
* 80cdcce Splitting out input passes from flow passes. Eventually the TOSA/HLO stuff wil..
* a2a464d Add missing CMake dep (#5081)
* ca29d25 [CodeGen] NFC: Rename LinalgTileAndFusePass (#5075)
* f3d7654 Add MobileNetV2 to benchmarking targets. (#5064)
* 8aace66 Rename CMake target DYLIB-LLVM-AOT to just LLVM-AOT.
* 98f2135 Add WASM executable format and produce it with LLVMAOTTarget.
* 2795092 Add CMake configuration for WAMR's runtime "iwasm VM core".
* 2b5c7b9 Add third_party/wasm-micro-runtime submodule.

PiperOrigin-RevId: 362617674
ThomasRaoux added a commit that referenced this pull request Mar 13, 2021
* 161f932 Enable CUDA tests on Turing platforms (#5091)
* e16759c [CodeGen] Avoid eliminating output store unconditionally (#5073)
* e2fe13e Add wasm-micro-runtime submodule and get building with CMake. (#5077)
* 33c4e39 Bump Tracy submodule to v0.7.6. (#5094)
* 3f6335f Use correct tied operand index when creating DispatchWorkgroupsOp (#5090)
* e5cfa53 Allow all matmul variants to be a root op (#5065)
* a5a0f1d Merge google -> main (#5086)
* 1ef76ba Merge pull request #5083 from google/benvanik-flow-passes
* 0668b55 Configure compiler to generate 'wasm' executables using wasm-llvm-aot. (#5079)
* 6d41b9d Create InitTensorOp based on input operand shapes. (#5070)
* bb819df Shuffling the SIP reflection attrs pass around a bit. This is in preparation f..
* 6b63dac Fixing deprecation warning.
* 5c5d2aa Removing old identify dispatch regions. Not yet the new old identify dispatch ..
* 80cdcce Splitting out input passes from flow passes. Eventually the TOSA/HLO stuff wil..
* a2a464d Add missing CMake dep (#5081)
* ca29d25 [CodeGen] NFC: Rename LinalgTileAndFusePass (#5075)
* f3d7654 Add MobileNetV2 to benchmarking targets. (#5064)
* 8aace66 Rename CMake target DYLIB-LLVM-AOT to just LLVM-AOT.
* 98f2135 Add WASM executable format and produce it with LLVMAOTTarget.
* 2795092 Add CMake configuration for WAMR's runtime "iwasm VM core".
* 2b5c7b9 Add third_party/wasm-micro-runtime submodule.

PiperOrigin-RevId: 362617674
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants