Skip to content

Fix bugs in PromoteI1ToI8Pass and move it to common input conversion. - #7078

Closed
hanhanW wants to merge 1 commit into
iree-org:mainfrom
hanhanW:i1-to-i8
Closed

hanhanW wants to merge 1 commit into
iree-org:mainfrom
hanhanW:i1-to-i8

Conversation

@hanhanW

@hanhanW hanhanW commented Sep 17, 2021

Copy link
Copy Markdown
Contributor

Deletes inserting the op right before the first use of the constant.
Generating the op right after the constant guarantees the dominitio
because the constant already meets it. Plus, a constant could be used in
different blocks. In this context, it will crash in the check.

Also adds the pass to MHLO pipeline.

Deletes inserting the op right before the first use of the constant.
Generating the op right after the constant guarantees the dominitio
because the constant already meets it. Plus, a constant could be used in
different blocks. In this context, it will crash in the check.

Also adds the pass to MHLO pipeline.
@hanhanW
hanhanW requested a review from rsuderman September 17, 2021 22:10
@google-cla google-cla Bot added the cla: yes label Sep 17, 2021
Comment on lines +67 to +68
passManager.addNestedPass<FuncOp>(
mlir::iree_compiler::createPromoteI1ToI8Pass());

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.

What prompted this change? I recently removed a similar pass from this file in #6852 based on discussion here: #6756 (comment). We really need a clear stance (that is documented) on how i1 types should be handled (#5223).

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.

There are i1 constants (e.g., tensor<1024xi1>), and IREE does not know how to handle i1 constants.

I think it is slightly different from #6852 because PromoteTensorLoads is mainly to handle 0D i1 tensors (i.e. tensor) which are introduced by CFG.

I would see this change in these ways:

  1. The pass is already used in TOSA pipeline. This makes the MHLO pipeline align the TOSA pipeline. I.e., the pass is added because IREE does not handle i1 constants correctly now.
  2. The i1 constants could be used in computations. Ideally, IREE should pack constants, and codegen side should be able to handle it. We will see similar situations in quantized model, e.g., tensor<1024xi4>, though the quant stories are not clear to me at this moment.

To be more clear, I think this case should be handled like:

  1. At flow level, the host side decides how to pack/store these non-native types (e.g., i1, i4).
  2. IREE compiler will configure codegen side to store constants in some types. E.g., today we are storing i1 in 8 bits on SPIR-V side. See https://github.com/llvm/llvm-project/blob/a95ba8107359e17cb1669c01f416fd2723a23126/mlir/include/mlir/Dialect/SPIRV/Transforms/SPIRVConversion.h#L55-L63

Once IREE HAL can store these types correctly (maybe pack them back-to-back), and all the backends can emulate the case. I think we will have a clearer picture.

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.

Thanks for that breakdown! I'm starting a doc for #5223 and it will be good to capture some of this in there.

I've seen these i8 passes shuffled around enough times that I'd really like to see us land on the actual structure we want (what you mention for flow and codegen), rather than carry forward the stopgaps.

@hanhanW

hanhanW commented Oct 8, 2021

Copy link
Copy Markdown
Contributor Author

testing if adding label works to me

@iree-github-actions-bot

Copy link
Copy Markdown
Contributor

Abbreviated Benchmark Summary

@ commit 57618da81d92ad505c5b24fc922fccc58f55ce8e (vs. base 401338bded50cf20b1f3e4d6f0724847896a505b)

Regressed Benchmarks 🚩

Benchmark Name Average Latency (ms) Median Latency (ms) Latency Standard Deviation (ms)
MobileSSD [fp32] (TFLite) full-inference with IREE-Vulkan @ Pixel-4 (GPU-Adreno-640) 568 (vs. 94, 504.26%↑) 563 16
DeepLabV3 [fp32] (TFLite) kernel-execution with IREE-Vulkan @ SM-G980F (GPU-Mali-G77) 193 (vs. 39, 394.87%↑) 143 65
MobileSSD [fp32] (TFLite) full-inference with IREE-Vulkan @ SM-G980F (GPU-Mali-G77) 360 (vs. 81, 344.44%↑) 360 4

[Top 3 out of 54 benchmark results showed]

Improved Benchmarks 🎉

Benchmark Name Average Latency (ms) Median Latency (ms) Latency Standard Deviation (ms)
MobileNetV3Small [fp32,imagenet] (TensorFlow) kernel-execution with IREE-Vulkan @ Pixel-4 (GPU-Adreno-640) 13 (vs. 15, 13.33%↓) 13 0

For more information:

@hanhanW

hanhanW commented Feb 1, 2022

Copy link
Copy Markdown
Contributor Author

This is no longer needed. The issue is addressed and the pass is deleted in #8199

@hanhanW hanhanW closed this Feb 1, 2022
@hanhanW
hanhanW deleted the i1-to-i8 branch May 6, 2026 17:18
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.

3 participants