Skip to content

Commit

Permalink
Integrate StableHLO at openxla/stablehlo@03597b1e
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 731067220
  • Loading branch information
mrguenther authored and Google-ML-Automation committed Feb 28, 2025
1 parent d7238b5 commit 03f912d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 47 deletions.
45 changes: 0 additions & 45 deletions third_party/stablehlo/temporary.patch
Original file line number Diff line number Diff line change
Expand Up @@ -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<?, 5>> {
- // 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<?, 5>>
return %c : tensor<1x?xf32, #stablehlo.bounds<?, 5>>
}
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
Expand All @@ -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<ui8:f32, 34.0:16>>
func.return %4: tensor<16x16x!quant.uniform<ui8:f32, 34.0:16>>
}
+
+// -----
+
+// 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<u8:f32, 3.400000e+01:16>>
+// CHECK-NEXT: return %0 : tensor<2x!quant.uniform<u8:f32, 3.400000e+01:16>>
+func.func @failed_to_match_zero_defining_op() -> tensor<2x!quant.uniform<u8:f32, 3.400000e+01:16>> {
+ %0 = stablehlo.constant dense<0.000000e+00> : tensor<2xf32>
+ %1 = stablehlo.uniform_quantize %0 : (tensor<2xf32>) -> tensor<2x!quant.uniform<u8:f32, 3.400000e+01:16>>
+ return %1 : tensor<2x!quant.uniform<u8:f32, 3.400000e+01:16>>
+}
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<Value> 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
Expand Down
4 changes: 2 additions & 2 deletions third_party/stablehlo/workspace.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 03f912d

Please sign in to comment.