Skip to content

Adapt Tile+Fuse to handle multi-result dispatches. - #12020

Merged
MaheshRavishankar merged 1 commit into
iree-org:mainfrom
MaheshRavishankar:multi_result_tile_and_fuse
Feb 2, 2023
Merged

MaheshRavishankar merged 1 commit into
iree-org:mainfrom
MaheshRavishankar:multi_result_tile_and_fuse

Conversation

@MaheshRavishankar

@MaheshRavishankar MaheshRavishankar commented Feb 1, 2023 •

Copy link
Copy Markdown
Collaborator

The tile and fuse transformation upstream has been split into its individual steps allowing caller more control in terms of which producers to fuse and which values to yield from within the tiled loop nest. This moves IREEs tile+fuse to use these components, allowing for handling of multi-result dispatches.

Currently multi-result dispatches do seem to cause bufferization issues. IREE currently doesnt form such dispatches by default, but will do so with PR #11980. The bufferization issue is tracked in #12019

Also fixes #11505.

The tile and fuse transformation upstream has been split into its
individual steps allowing caller more control in terms of which
producers to fuse and which values to yield from within the tiled loop
nest. This moves IREEs tile+fuse to use these components, allowing for
handling of multi-result dispatches.

Currently multi-result dispatches do seem to cause bufferization
issues. IREE currently doesnt form such dispatches by default, but
will do so with PR iree-org#11980. The bufferization issue is tracked in

Also fixes iree-org#11505.
@iree-github-actions-bot

iree-github-actions-bot commented Feb 1, 2023 •

Copy link
Copy Markdown
Contributor

Abbreviated Linux Benchmark Summary

@ commit 81df2e1a117b79e873b106cd105f88ea08ca817c (vs. base f19cc5b977e5210411068c820dab688cec5cc377)

Improved Latencies 🎉

Benchmark Name Average Latency (ms) Median Latency (ms) Latency Standard Deviation (ms)
MobileBertSquad [int8] (TFLite) 8-thread,full-inference,default-flags with IREE-LLVM-CPU @ GCP-c2-standard-16 (CPU-x86\_64-CascadeLake) 96.338 (vs. 102.762, 6.25%↓) 96.351 0.284

Regressed Compilation Times 🚩

Benchmark Name Compilation Time (ms)
BertForMaskedLM [fp32,seqlen512] (TF) CPU-x86\_64-CascadeLake 8-thread,full-inference,default-flags 15156 (vs. 13222, 14.63%↑)
BertForMaskedLM [fp32,seqlen512] (TF) CPU-x86\_64-CascadeLake full-inference,default-flags 15156 (vs. 13222, 14.63%↑)
BertForMaskedLM [fp32,seqlen512] (TF) CPU-x86\_64-CascadeLake 4-thread,full-inference,default-flags 15156 (vs. 13222, 14.63%↑)

[Top 3 out of 37 results showed]

Improved Compilation Times 🎉

Benchmark Name Compilation Time (ms)
PersonDetect [int8] (TFLite) CPU-RV32-Generic full-inference,default-flags 18397 (vs. 21170, 13.10%↓)
MobileNetV1 [fp32,imagenet] (TFLite) CPU-RV64-Generic full-inference,default-flags 13728 (vs. 15136, 9.30%↓)
EfficientNetV2STF [fp32] (TF) GPU-CUDA-SM\_80 full-inference,default-flags 8995 (vs. 9881, 8.97%↓)

[Top 3 out of 7 results showed]

For more information:

@iree-github-actions-bot

iree-github-actions-bot commented Feb 1, 2023 •

Copy link
Copy Markdown
Contributor

Abbreviated Android Benchmark Summary

@ commit 81df2e1a117b79e873b106cd105f88ea08ca817c (vs. base f19cc5b977e5210411068c820dab688cec5cc377)

Regressed Latencies 🚩

Benchmark Name Average Latency (ms) Median Latency (ms) Latency Standard Deviation (ms)
MobileSSD [fp32] (TFLite) 4-thread,big-core,full-inference,default-flags with IREE-LLVM-CPU @ Pixel-6-Pro (CPU-ARMv8.2-A) 45.527 (vs. 42.087, 8.17%↑) 45.448 0.944
DeepLabV3 [fp32] (TFLite) 4-thread,little-core,full-inference,default-flags with IREE-LLVM-CPU @ Pixel-6-Pro (CPU-ARMv8.2-A) 144.921 (vs. 134.885, 7.44%↑) 147.028 7.241
MobileSSD [fp32] (TFLite) 4-thread,big-core,full-inference,experimental-flags with IREE-LLVM-CPU @ Pixel-6-Pro (CPU-ARMv8.2-A) 40.120 (vs. 37.427, 7.19%↑) 40.015 1.570

[Top 3 out of 4 results showed]

Improved Latencies 🎉

Benchmark Name Average Latency (ms) Median Latency (ms) Latency Standard Deviation (ms)
MobileSSD [fp32] (TFLite) big-core,full-inference,default-flags with IREE-LLVM-CPU-Sync @ Pixel-4 (CPU-ARMv8.2-A) 91.091 (vs. 106.883, 14.78%↓) 91.088 0.118
PoseNet [fp32] (TFLite) little-core,full-inference,experimental-flags with IREE-LLVM-CPU-Sync @ Pixel-6-Pro (CPU-ARMv8.2-A) 290.226 (vs. 324.848, 10.66%↓) 290.218 0.142
PoseNet [fp32] (TFLite) kernel-execution,experimental-flags with IREE-Vulkan @ Pixel-6-Pro (GPU-Mali-G78) 13.267 (vs. 14.396, 7.84%↓) 13.256 0.034

[Top 3 out of 5 results showed]

Regressed Compilation Times 🚩

Benchmark Name Compilation Time (ms)
MobileSSD [fp32] (TFLite) GPU-Mali-Valhall full-inference,default-flags 36500 (vs. 26293, 38.82%↑)
MobileSSD [fp32] (TFLite) CPU-ARM64-v8A little-core,full-inference,default-flags 87389 (vs. 64593, 35.29%↑)
MobileSSD [fp32] (TFLite) CPU-ARM64-v8A 4-thread,little-core,full-inference,default-flags 87389 (vs. 64593, 35.29%↑)

[Top 3 out of 88 results showed]

Improved Compilation Times 🎉

Benchmark Name Compilation Time (ms)
DeepLabV3 [fp32] (TFLite) GPU-Adreno full-inference,experimental-flags 8241 (vs. 11240, 26.68%↓)
PoseNet [fp32] (TFLite) GPU-Mali-Valhall full-inference,default-flags 8696 (vs. 11118, 21.78%↓)
DeepLabV3 [fp32] (TFLite) GPU-Mali-Valhall full-inference,experimental-flags 8463 (vs. 10007, 15.43%↓)

[Top 3 out of 14 results showed]

For more information:

@hanhanW hanhanW left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nice work!

Comment on lines +205 to +225
/// Starting from `op` walk all operands backwards to find all
/// potentially fusable operations, i.e. operations that implement
/// the `TilingInterface`.
llvm::SmallDenseSet<Operation *> static collectTiledAndFusedOps(Operation *op) {
SmallVector<Operation *> worklist;
llvm::SmallDenseSet<Operation *> producers;
worklist.push_back(op);
producers.insert(op);
while (!worklist.empty()) {
Operation *current = worklist.pop_back_val();
for (OpOperand &operand : current->getOpOperands()) {
Operation *producer = operand.get().getDefiningOp();
if (!producer || !isa<TilingInterface>(producer) ||
producers.count(producer))
continue;
worklist.push_back(producer);
producers.insert(producer);
}
}
return producers;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Thats a bit hard. The constraints are a bit involved to spell out, by IREE satisfies those by construction. Basically you need to be doing tile+fuse without redundancy in the producer tiles computed within the consumer tile loop. We have that requirement anyway. This is why the test is basically capturing and testing in MLIR this requirement, and we use that directly here in IREE. I think over time we will get a better idea of how to write those constraints upstream, in which case we can then move to use the upstream methods.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

thanks for the details, SGTM!

@dcaballe dcaballe left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Really excited to see this!

@MaheshRavishankar
MaheshRavishankar merged commit b77145d into iree-org:main Feb 2, 2023
nithinsubbiah pushed a commit to nod-ai/SRT that referenced this pull request Feb 3, 2023
The tile and fuse transformation upstream has been split into its individual steps allowing caller more control in terms of which producers to fuse and which values to yield from within the tiled loop nest. This moves IREEs tile+fuse to use these components, allowing for handling of multi-result dispatches.

Currently multi-result dispatches do seem to cause bufferization issues. IREE currently doesnt form such dispatches by default, but will do so with PR iree-org#11980. The bufferization issue is tracked in iree-org#12019

Also fixes iree-org#11505.
qedawkins pushed a commit to qedawkins/iree that referenced this pull request Apr 2, 2023
The tile and fuse transformation upstream has been split into its individual steps allowing caller more control in terms of which producers to fuse and which values to yield from within the tiled loop nest. This moves IREEs tile+fuse to use these components, allowing for handling of multi-result dispatches.

Currently multi-result dispatches do seem to cause bufferization issues. IREE currently doesnt form such dispatches by default, but will do so with PR iree-org#11980. The bufferization issue is tracked in iree-org#12019

Also fixes iree-org#11505.
jpienaar pushed a commit that referenced this pull request May 1, 2023
The tile and fuse transformation upstream has been split into its individual steps allowing caller more control in terms of which producers to fuse and which values to yield from within the tiled loop nest. This moves IREEs tile+fuse to use these components, allowing for handling of multi-result dispatches.

Currently multi-result dispatches do seem to cause bufferization issues. IREE currently doesnt form such dispatches by default, but will do so with PR #11980. The bufferization issue is tracked in #12019

Also fixes #11505.
rengolin pushed a commit to plaidml/iree that referenced this pull request May 2, 2023
The tile and fuse transformation upstream has been split into its individual steps allowing caller more control in terms of which producers to fuse and which values to yield from within the tiled loop nest. This moves IREEs tile+fuse to use these components, allowing for handling of multi-result dispatches.

Currently multi-result dispatches do seem to cause bufferization issues. IREE currently doesnt form such dispatches by default, but will do so with PR iree-org#11980. The bufferization issue is tracked in iree-org#12019

Also fixes iree-org#11505.
@MaheshRavishankar
MaheshRavishankar deleted the multi_result_tile_and_fuse branch April 13, 2024 20:02
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.

scf::tileConsumerAndFuseProducerGreedilyUsingSCFForOp does not work for unpack + generic case

4 participants