Skip to content

Commit 891e048

Browse files
Fix stablehlo constant folding bugs through patch (#401)
This PR provides a patch to fix two issues in StableHlo upstream, - If some op is constant folded and op users are certain stablehlo ops (which don't allow different type for operand and result) OR ops with different dialect, `tensor.cast` should be inserted. MLIR-TensorRT constant folding pass does this but upstream stablehlo pass doesn't do this, causing error. Some logic from MLIR-TRT is patched into upstream. - Upstream `ReshapeOpCanon` pattern to simplify `stablehlo.reshape` op failed if input to reshape is `DenseResourceElementsAttr`. This is fixed. - Many patterns where replacing op with a new op, without giving consideration to casting. This is fixed. Solves: #378
1 parent c8ee99f commit 891e048

File tree

2 files changed

+657
-1
lines changed

2 files changed

+657
-1
lines changed

mlir-tensorrt/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,9 @@ if(MLIR_TRT_ENABLE_HLO AND NOT TARGET StablehloOps)
183183
VERSION 1.6.4
184184
GIT_TAG 1456dfa1e1a83aab0cc717714ba3695886f60302
185185
GIT_REPOSITORY "https://github.com/openxla/stablehlo.git"
186-
PATCHES "${MLIR_TENSORRT_ROOT_DIR}/build_tools/stablehlo.patch"
186+
PATCHES
187+
"${MLIR_TENSORRT_ROOT_DIR}/build_tools/stablehlo.patch"
188+
"${MLIR_TENSORRT_ROOT_DIR}/build_tools/stablehlo_aggressive_folder.patch"
187189
OPTIONS
188190
"STABLEHLO_ENABLE_BINDINGS_PYTHON ${MLIR_TRT_ENABLE_PYTHON}"
189191
"STABLEHLO_BUILD_EMBEDDED ON"

0 commit comments

Comments
 (0)