[NFC] Switch dynamic inputs to flow.tensor.dynamic_constant.#21461
Merged
hanhanW merged 1 commit intoiree-org:mainfrom Jul 23, 2025
Merged
[NFC] Switch dynamic inputs to flow.tensor.dynamic_constant.#21461hanhanW merged 1 commit intoiree-org:mainfrom
hanhanW merged 1 commit intoiree-org:mainfrom
Conversation
The compiler is very smart on static shape inference that can generate partially dynamic shape during the lowering. It makes data-tiling fusion very struggle because they are expected to be dynamic shape but some dimensions are inferred to static values in Stream AnnotateDispatchAssumptions pass. Because it will lead to `tensor.cast -> set_encoding -> tensor.cast` sequence in a dispatch while we expect the bindings have encoded tensor types. E.g., Input IR: ```mlir %0 = iree_tensor_ext.dispatch_load ... tensor<?x?xi8> %1 = set_encoding %0 : tensor<?x?xi8> -> tensor<?x?xi8, #encoding> iree_tensor_ext.dispatch_store %1, ... tensor<?x?xi8, #encoding> -> ... tensor<?x?xi8, #encoding> ``` After annotation: ```mlir %0 = iree_tensor_ext.dispatch_load ... tensor<4x?xi8> %cast = tensor.cast %0 : tensor<4x?xi8> -> tensor<?x?xi8> %1 = set_encoding %cast : tensor<?x?xi8> -> tensor<?x?xi8, #encoding> %cast_0 = tensor.cast %1 : tensor<?x?xi8, #encoding> to tensor<4x5xi8> iree_tensor_ext.dispatch_store %cast_0, ... tensor<4x5xi8> -> ... tensor<?x?xi8, #encoding> ``` It is hard to materialize the encodings when cast op is present. Given that the original goal is testing dynamic shape, modifying the input program is an easier fix. Signed-off-by: hanhanW <hanhan0912@gmail.com>
benvanik
approved these changes
Jul 23, 2025
AWoloszyn
pushed a commit
that referenced
this pull request
Dec 1, 2025
The compiler is very smart on static shape inference that can generate partially dynamic shape during the lowering. It makes data-tiling fusion very struggle because they are expected to be dynamic shape but some dimensions are inferred to static values in Stream AnnotateDispatchAssumptions pass. Because it will lead to `tensor.cast -> set_encoding -> tensor.cast` sequence in a dispatch, while we expect the bindings have encoded tensor types. E.g., Input IR: ```mlir %0 = iree_tensor_ext.dispatch_load ... tensor<?x?xi8> %1 = set_encoding %0 : tensor<?x?xi8> -> tensor<?x?xi8, #encoding> iree_tensor_ext.dispatch_store %1, ... tensor<?x?xi8, #encoding> -> ... tensor<?x?xi8, #encoding> ``` After annotation: ```mlir %0 = iree_tensor_ext.dispatch_load ... tensor<4x?xi8> %cast = tensor.cast %0 : tensor<4x?xi8> -> tensor<?x?xi8> %1 = set_encoding %cast : tensor<?x?xi8> -> tensor<?x?xi8, #encoding> %cast_0 = tensor.cast %1 : tensor<?x?xi8, #encoding> to tensor<4x5xi8> iree_tensor_ext.dispatch_store %cast_0, ... tensor<4x5xi8> -> ... tensor<?x?xi8, #encoding> ``` It is hard to materialize the encodings when cast op is present. Given that the original goal is testing dynamic shape, modifying the input program is an easier fix. The issue is observed from #21441. Signed-off-by: hanhanW <hanhan0912@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The compiler is very smart on static shape inference that can generate partially dynamic shape during the lowering. It makes data-tiling fusion very struggle because they are expected to be dynamic shape but some dimensions are inferred to static values in Stream AnnotateDispatchAssumptions pass. Because it will lead to
tensor.cast -> set_encoding -> tensor.castsequence in a dispatch, while we expect the bindings have encoded tensor types. E.g.,Input IR:
After annotation:
It is hard to materialize the encodings when cast op is present.
Given that the original goal is testing dynamic shape, modifying the input program is an easier fix.
The issue is observed from #21441.