Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove mhlo_quant_legalize_to_int pass Pass from openxla/mhlo #69815

Merged
merged 1 commit into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions tensorflow/compiler/mlir/quantization/stablehlo/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,7 @@ cc_library(
"@local_xla//xla/mlir_hlo:mhlo_passes",
"@local_xla//xla/translate/hlo_to_mhlo:attribute_importer",
"@stablehlo//:chlo_ops",
"@stablehlo//:stablehlo_passes",
],
)

Expand Down
1 change: 1 addition & 0 deletions tensorflow/compiler/mlir/quantization/stablehlo/cc/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ cc_library(
"@llvm-project//mlir:ReconcileUnrealizedCasts",
"@llvm-project//mlir:Transforms",
"@local_xla//xla/mlir_hlo:mhlo_passes",
"@stablehlo//:stablehlo_passes",
],
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ limitations under the License.
#include "mlir/Pass/PassManager.h" // from @llvm-project
#include "mlir/Pass/PassRegistry.h" // from @llvm-project
#include "mlir/Transforms/Passes.h" // from @llvm-project
#include "stablehlo/transforms/Passes.h" // from @stablehlo
#include "tensorflow/compiler/mlir/quantization/stablehlo/passes/bridge/passes.h"
#include "tensorflow/compiler/mlir/quantization/stablehlo/passes/passes.h"
#include "tensorflow/compiler/mlir/quantization/stablehlo/quantization_config.pb.h"
Expand Down Expand Up @@ -127,9 +128,10 @@ void AddShapeLegalizationPasses(OpPassManager& pm) {
}

void AddStablehloQuantToIntPasses(OpPassManager& pm) {
pm.addNestedPass<func::FuncOp>(
mlir::stablehlo::createStablehloLegalizeQuantToIntPass());
// StableHLO -> MHLO legalization.
pm.addPass(mhlo::createStablehloLegalizeToHloPass());
pm.addNestedPass<func::FuncOp>(mhlo::createMhloQuantLegalizeToIntPass());
pm.addNestedPass<func::FuncOp>(createCanonicalizerPass());
// Integer graph optimization relies on chlo broadcast ops for easier handling
// of dynamic shapes. Therefore we lower chlo ops after optimization.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ limitations under the License.
#include "mlir/Pass/PassManager.h" // from @llvm-project
#include "mlir/Pass/PassOptions.h" // from @llvm-project
#include "mlir/Transforms/Passes.h" // from @llvm-project
#include "stablehlo/transforms/Passes.h" // from @stablehlo
#include "xla/mlir_hlo/mhlo/transforms/passes.h"

namespace mlir::quant::stablehlo {
Expand All @@ -28,8 +29,10 @@ void AddQuantizationLoweringPasses(mlir::OpPassManager& pm) {
pm.addNestedPass<mlir::func::FuncOp>(CreateConvertTFQuantOpsToMHLOPass());
pm.addNestedPass<mlir::func::FuncOp>(mhlo::createChloLegalizeToHloPass());
pm.addNestedPass<mlir::func::FuncOp>(mlir::createCanonicalizerPass());
pm.addPass(mhlo::createHloLegalizeToStablehloPass());
pm.addNestedPass<mlir::func::FuncOp>(
mhlo::createMhloQuantLegalizeToIntPass());
mlir::stablehlo::createStablehloLegalizeQuantToIntPass());
pm.addPass(mhlo::createStablehloLegalizeToHloPass());
pm.addNestedPass<mlir::func::FuncOp>(mlir::createCanonicalizerPass());
pm.addNestedPass<mlir::func::FuncOp>(CreateVerifyQuantLegalizationPass());
}
Expand Down
1 change: 0 additions & 1 deletion third_party/xla/xla/mlir_hlo/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,6 @@ cc_library(
"mhlo/transforms/mhlo_canonicalize_scatter/mhlo_canonicalize_scatter.cc",
"mhlo/transforms/mhlo_flatten_tuple/mhlo_flatten_tuple.cc",
"mhlo/transforms/mhlo_passes.h.inc",
"mhlo/transforms/mhlo_quant_legalize_to_int/mhlo_quant_legalize_to_int.cc",
"mhlo/transforms/optimize_mhlo/optimize_mhlo.cc",
"mhlo/transforms/optimize_mhlo/optimize_mhlo_pass.cc",
"mhlo/transforms/prepare_for_export/prepare_for_export.cc",
Expand Down
21 changes: 0 additions & 21 deletions third_party/xla/xla/mlir_hlo/mhlo/transforms/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -103,26 +103,6 @@ add_mlir_library(MhloPasses
StablehloBroadcastUtils
)

add_mlir_library(MhloQuantToIntConversion
mhlo_quant_legalize_to_int/mhlo_quant_legalize_to_int.cc

DEPENDS
MLIRhlo_opsIncGen
MLIRMhloPassIncGen

LINK_COMPONENTS
Core

LINK_LIBS PUBLIC
MhloDialect
MhloTypeConversion
MLIRIR
MLIRPass
MLIRMathDialect
MLIRTransforms
MLIRTransformUtils
)

add_mlir_library(MhloToMemrefConversion
hlo_legalize_to_memref/hlo_legalize_to_memref.cc

Expand Down Expand Up @@ -280,7 +260,6 @@ add_library(AllMhloPasses INTERFACE)
target_link_libraries(AllMhloPasses INTERFACE
ChloPasses
MhloPasses
MhloQuantToIntConversion
MhloToArithmeticConversion
MhloToMemrefConversion
MhloToStandard
Expand Down
13 changes: 0 additions & 13 deletions third_party/xla/xla/mlir_hlo/mhlo/transforms/mhlo_passes.td
Original file line number Diff line number Diff line change
Expand Up @@ -374,16 +374,3 @@ def ShapeLegalizeToHloPass : Pass<"shape-legalize-to-hlo", "func::FuncOp"> {
/*default=*/"false", "Whether to legalize Cstr Ops to shape_assertion custom_call">
];
}

def MhloQuantLegalizeToInt : Pass<"mhlo-quant-legalize-to-int", "mlir::func::FuncOp"> {
let summary = "Convert from MHLO quantized ops to MHLO primitive ops.";

let description = [{
Convert from MHLO quantized ops with MHLO quant types to MHLO primitive ops
like int ops.
}];
let constructor = "createMhloQuantLegalizeToIntPass()";
let dependentDialects = ["chlo::ChloDialect", "mhlo::MhloDialect",
"quant::QuantizationDialect",
"func::FuncDialect"];
}
Loading
Loading