From 03f912d9621dc05f660118be4726676467099faa Mon Sep 17 00:00:00 2001 From: Matthias Guenther Date: Tue, 25 Feb 2025 16:13:45 -0800 Subject: [PATCH] Integrate StableHLO at openxla/stablehlo@03597b1e PiperOrigin-RevId: 731067220 --- third_party/stablehlo/temporary.patch | 45 --------------------------- third_party/stablehlo/workspace.bzl | 4 +-- 2 files changed, 2 insertions(+), 47 deletions(-) diff --git a/third_party/stablehlo/temporary.patch b/third_party/stablehlo/temporary.patch index 91dd90d1da855c..167bc8b6bb4c18 100755 --- a/third_party/stablehlo/temporary.patch +++ b/third_party/stablehlo/temporary.patch @@ -31,18 +31,6 @@ diff --ruN a/stablehlo/stablehlo/conversions/tosa/transforms/StablehloLegalizeTo return success(); } }; -diff --ruN a/stablehlo/stablehlo/tests/ops_stablehlo_bounded_dynamism.mlir b/stablehlo/stablehlo/tests/ops_stablehlo_bounded_dynamism.mlir ---- stablehlo/stablehlo/tests/ops_stablehlo_bounded_dynamism.mlir -+++ stablehlo/stablehlo/tests/ops_stablehlo_bounded_dynamism.mlir -@@ -57,7 +57,7 @@ - // ----- - - func.func @constant_with_dynamic_shape() -> tensor<1x?xf32, #stablehlo.bounds> { -- // expected-error@+2 {{elements literal type must have static shape}} -+ // expected-error@below {{elements literal type must have static shape}} - %c = stablehlo.constant dense<1> : tensor<1x?xf32, #stablehlo.bounds> - return %c : tensor<1x?xf32, #stablehlo.bounds> - } diff --ruN a/stablehlo/stablehlo/tests/transforms/stablehlo_aggressive_simplification.mlir b/stablehlo/stablehlo/tests/transforms/stablehlo_aggressive_simplification.mlir --- stablehlo/stablehlo/tests/transforms/stablehlo_aggressive_simplification.mlir +++ stablehlo/stablehlo/tests/transforms/stablehlo_aggressive_simplification.mlir @@ -62,39 +50,6 @@ diff --ruN a/stablehlo/stablehlo/tests/transforms/stablehlo_aggressive_simplific } // ----- -diff --ruN a/stablehlo/stablehlo/tests/transforms/stablehlo_legalize_qdq_to_quantized_op.mlir b/stablehlo/stablehlo/tests/transforms/stablehlo_legalize_qdq_to_quantized_op.mlir ---- stablehlo/stablehlo/tests/transforms/stablehlo_legalize_qdq_to_quantized_op.mlir -+++ stablehlo/stablehlo/tests/transforms/stablehlo_legalize_qdq_to_quantized_op.mlir -@@ -127,3 +127,15 @@ - %4 = stablehlo.uniform_quantize %3 : (tensor<16x16xf32>) -> tensor<16x16x!quant.uniform> - func.return %4: tensor<16x16x!quant.uniform> - } -+ -+// ----- -+ -+// CHECK-LABEL @failed_to_match_zero_defining_op -+// CHECK{LITERAL}: %cst = stablehlo.constant dense<0.000000e+00> : tensor<2xf32> -+// CHECK-NEXT: %0 = stablehlo.uniform_quantize %cst : (tensor<2xf32>) -> tensor<2x!quant.uniform> -+// CHECK-NEXT: return %0 : tensor<2x!quant.uniform> -+func.func @failed_to_match_zero_defining_op() -> tensor<2x!quant.uniform> { -+ %0 = stablehlo.constant dense<0.000000e+00> : tensor<2xf32> -+ %1 = stablehlo.uniform_quantize %0 : (tensor<2xf32>) -> tensor<2x!quant.uniform> -+ return %1 : tensor<2x!quant.uniform> -+} -diff --ruN a/stablehlo/stablehlo/transforms/StablehloLegalizeQDQToQuantizedOp.cpp b/stablehlo/stablehlo/transforms/StablehloLegalizeQDQToQuantizedOp.cpp ---- stablehlo/stablehlo/transforms/StablehloLegalizeQDQToQuantizedOp.cpp -+++ stablehlo/stablehlo/transforms/StablehloLegalizeQDQToQuantizedOp.cpp -@@ -63,6 +63,10 @@ - - // Collect quantized operands and result types to rewrite. - // All operands and results must be quantized -+ if (computeOp->getNumOperands() == 0) -+ return rewriter.notifyMatchFailure(computeOp, -+ "requires non empty operands"); -+ - llvm::SmallVector quantizedComputeOpOperands; - for (const Value& operand : computeOp->getOperands()) { - auto* definingOp = operand.getDefiningOp(); diff --ruN a/stablehlo/stablehlo/transforms/optimization/StablehloAggressiveSimplification.cpp b/stablehlo/stablehlo/transforms/optimization/StablehloAggressiveSimplification.cpp --- stablehlo/stablehlo/transforms/optimization/StablehloAggressiveSimplification.cpp +++ stablehlo/stablehlo/transforms/optimization/StablehloAggressiveSimplification.cpp diff --git a/third_party/stablehlo/workspace.bzl b/third_party/stablehlo/workspace.bzl index 044ea86f8d6887..7835f451fe4505 100644 --- a/third_party/stablehlo/workspace.bzl +++ b/third_party/stablehlo/workspace.bzl @@ -4,8 +4,8 @@ load("//third_party:repo.bzl", "tf_http_archive", "tf_mirror_urls") def repo(): # LINT.IfChange - STABLEHLO_COMMIT = "5e9b356b928955a308d87746b1b32294f1f3eebe" - STABLEHLO_SHA256 = "6d47ba59d7433911d6adef12ddd48d0ee4d8a1c960d7fc21f84268be28cb7860" + STABLEHLO_COMMIT = "03597b1e592129f0c79e99e5ed65dac7ebee240f" + STABLEHLO_SHA256 = "0424d8bdb8f367efc28bc02f24229ba1b1c98a0dae47215fef53177038ba58e7" # LINT.ThenChange(Google-internal path) tf_http_archive(