Repository navigation
Create InitTensorOp based on input operand shapes. - #5070
Conversation
MaheshRavishankar
left a comment
There was a problem hiding this comment.
Thanks a lot for keeping this issue in mind and fixing it. I added the giant hack to make test pass when Linalg on tensors op semantics changed to use outs
| for (int i = 0; i < rank; ++i) { | ||
| if (!resultType.isDynamicDim(i)) continue; | ||
| if (i < axis) { | ||
| dynSizes.push_back(rewriter.create<DimOp>(loc, adaptor.input(), i)); |
There was a problem hiding this comment.
Nit: Use createOrFold here.
There was a problem hiding this comment.
It only benefits static shapes because it will be folded into a constant. Since it is not easy to support mixed shapes, let's keep it this way. (see explanation below)
| dynSizes.push_back(rewriter.create<DimOp>(loc, adaptor.input(), idx)); | ||
| } | ||
| } | ||
| Value initOp = rewriter.create<linalg::InitTensorOp>( |
There was a problem hiding this comment.
Not required, but InitTensorOp needs a builder method that can take ArrayRef<OpFoldResult> for the shape. Bonus points for doing that upstream and using that here.
There was a problem hiding this comment.
InitTensorOp has a builder method that can take ArrayRef<OpFoldResult>. But this doesn't work to me. I feel createOrFold returns a Value, so it will not be treated as an Attribute. So it is actually storing a ConstantOp, not Attribute.
I feel the better way is to fix dispatchIndexOpFoldResult in LinalgOps.cpp to handle the case of ConstantOp.
There was a problem hiding this comment.
I tried, but the fix would be SUPER painful. It breaks a lot of things, including bunch of integration tests and tests outside IREE.
There was a problem hiding this comment.
Sure NP. Ill look into it later. I didnt think it would hit these issues. Thanks for trying
* 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
* 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
* 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
According to the documentation, the output shape is:
params.shape[:axis] + indices.shape[batch_dims:] + params.shape[axis + 1:]E.g., if the varibles are:
params.shape = [16, 2, 3]
indices.shape = [16, 5]
axis = 2
batch_dims = 1
Then the output shape is
[16, 2] + [5] + [] = [16, 2, 5].See https://www.tensorflow.org/api_docs/python/tf/gather for more details.