Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
mrguenther authored Feb 25, 2025
1 parent e3ce339 commit 03597b1
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 4 deletions.
4 changes: 2 additions & 2 deletions WORKSPACE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ workspace(name = "stablehlo")

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

LLVM_COMMIT = "43d71baae36c8d8b5a9995aa35efebe09cc9c2d6"
LLVM_COMMIT = "d23da7d6300ec6732b462d475c331f289170cb83"

LLVM_SHA256 = "436af8b4c3403e251ab0b7a471eda7df6063f9da9d22ccbe498f3115cd35225a"
LLVM_SHA256 = "e9c22be167e2e58b585565efd5e38b7670e863571dd6f1d90ce718e21e293e38"

http_archive(
name = "llvm-raw",
Expand Down
2 changes: 1 addition & 1 deletion build_tools/llvm_version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
43d71baae36c8d8b5a9995aa35efebe09cc9c2d6
d23da7d6300ec6732b462d475c331f289170cb83
2 changes: 1 addition & 1 deletion stablehlo/tests/ops_stablehlo_bounded_dynamism.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func.func @constant_splat_broadcast() -> tensor<1x?xf32, #stablehlo.bounds<?, 5>
// -----

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>>
}
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,15 @@ func.func @failed_to_match_defining_op_is_not_a_uniform_dequantized_op(%arg0: te
%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>>
}
4 changes: 4 additions & 0 deletions stablehlo/transforms/StablehloLegalizeQDQToQuantizedOp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ struct QuantizedStablehloQDQToQuantizedOpConversion

// 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();
Expand Down

0 comments on commit 03597b1

Please sign in to comment.