Skip to content

Create InitTensorOp based on input operand shapes. - #5070

Merged
hanhanW merged 3 commits into
iree-org:mainfrom
hanhanW:gather-init
Mar 12, 2021
Merged

hanhanW merged 3 commits into
iree-org:mainfrom
hanhanW:gather-init

Conversation

@hanhanW

@hanhanW hanhanW commented Mar 11, 2021 •

Copy link
Copy Markdown
Contributor

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.

@google-cla google-cla Bot added the cla: yes label Mar 11, 2021
@hanhanW
hanhanW changed the base branch from main to google March 11, 2021 19:18
@hanhanW
hanhanW changed the base branch from google to main March 11, 2021 19:19

@MaheshRavishankar MaheshRavishankar left a comment

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.

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));

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.

Nit: Use createOrFold here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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>(

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.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

@hanhanW hanhanW Mar 12, 2021 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I tried, but the fix would be SUPER painful. It breaks a lot of things, including bunch of integration tests and tests outside IREE.

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.

Sure NP. Ill look into it later. I didnt think it would hit these issues. Thanks for trying

@hanhanW
hanhanW merged commit 6d41b9d into iree-org:main Mar 12, 2021
@hanhanW
hanhanW deleted the gather-init branch March 12, 2021 17:41
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