From 4286b80151d68d28baf1f2cafb586e060dfbbd63 Mon Sep 17 00:00:00 2001 From: Sandeep Dasgupta Date: Fri, 26 Jul 2024 01:56:21 +0000 Subject: [PATCH] Support qdq decomposition of TanOp (#2459) [parent PR](https://github.com/openxla/stablehlo/pull/2458) The PR adds patterns for qdq decomposition patterns for newly added `TanOp` Note to the reviewers: To may just focus on the very last commit of the chain. The rest is coming from parent PR. [childPR](https://github.com/openxla/stablehlo/pull/2460) --- stablehlo/tests/stablehlo_legalize_quant_to_int.mlir | 6 +++++- stablehlo/transforms/StablehloLegalizeQuantizedOpToQDQ.cpp | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/stablehlo/tests/stablehlo_legalize_quant_to_int.mlir b/stablehlo/tests/stablehlo_legalize_quant_to_int.mlir index c7fc7fdb0f..67e489fd46 100644 --- a/stablehlo/tests/stablehlo_legalize_quant_to_int.mlir +++ b/stablehlo/tests/stablehlo_legalize_quant_to_int.mlir @@ -2388,12 +2388,16 @@ func.func @send(%arg0: tensor<1x2x2x!quant.uniform>, %token0: !s } // ----- + +// CHECK-LABEL: func.func @tan func.func @tan(%arg0: tensor<1x2x2x!quant.uniform>) -> tensor<1x2x2x!quant.uniform> { - // expected-error@+1 {{failed to legalize operation 'stablehlo.tan' that was explicitly marked illegal}} %0 = "stablehlo.tan"(%arg0) : (tensor<1x2x2x!quant.uniform>) -> tensor<1x2x2x!quant.uniform> func.return %0 : tensor<1x2x2x!quant.uniform> } +// CHECK: stablehlo.tan {{.*}} : tensor<1x2x2xf32> + + // ----- func.func @tuple(%arg0: tensor<1x2x2x!quant.uniform>, %arg1: tensor<1x2x2x!quant.uniform>) { diff --git a/stablehlo/transforms/StablehloLegalizeQuantizedOpToQDQ.cpp b/stablehlo/transforms/StablehloLegalizeQuantizedOpToQDQ.cpp index 1b4f1d0316..719eb5128e 100644 --- a/stablehlo/transforms/StablehloLegalizeQuantizedOpToQDQ.cpp +++ b/stablehlo/transforms/StablehloLegalizeQuantizedOpToQDQ.cpp @@ -124,7 +124,7 @@ void populateStablehloLegalizeQuantizedOpToQDQPatterns( CosineOp, DivOp, Expm1Op, ExpOp, FloorOp, Log1pOp, LogisticOp, LogOp, MaxOp, MinOp, MulOp, NegOp, PowOp, ReducePrecisionOp, RemOp, RoundOp, RoundNearestEvenOp, RsqrtOp, SelectOp, SignOp, SineOp, SqrtOp, SubtractOp, - TanhOp, TriangularSolveOp>(patterns, context, benefit); + TanhOp, TanOp, TriangularSolveOp>(patterns, context, benefit); } } // namespace stablehlo