Skip to content

Commit

Permalink
Refactor fused quantization patterns into quantize pass.
Browse files Browse the repository at this point in the history
Current Quantize{DotGeneral, Convolution}OpPattern matching takes place after post_quantize,
which may be misleading.
Instead, factor out patterns in a separate file and handle in quantize.cc.

MLIR tests for fused patterns are left in quantize_composite_functions.mlir for
module-level evaluation of functions.

PiperOrigin-RevId: 586934993
  • Loading branch information
chococigar authored and tensorflower-gardener committed Dec 1, 2023
1 parent db58265 commit 54af26e
Show file tree
Hide file tree
Showing 7 changed files with 528 additions and 431 deletions.
17 changes: 14 additions & 3 deletions tensorflow/compiler/mlir/quantization/stablehlo/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ cc_library(
":lift_quantizable_spots_as_functions_fusion_inc_gen",
":lift_quantizable_spots_as_functions_simple_inc_gen",
":quantization_options_proto_cc",
":quantization_pattern",
":quantization_patterns",
":stablehlo_passes_inc_gen",
":stablehlo_type_utils",
":uniform_quantized_types",
Expand Down Expand Up @@ -106,27 +106,38 @@ cc_library(
)

cc_library(
name = "quantization_pattern",
name = "quantization_patterns",
srcs = ["passes/quantization_patterns.cc"],
hdrs = [
"passes/quantization_pattern.h",
"passes/quantization_patterns.h",
],
compatible_with = get_compatible_with_portable(),
deps = [
":bridge_passes",
":uniform_quantized_types",
"//tensorflow/compiler/mlir/lite/quantization:quantization_config",
"//tensorflow/compiler/mlir/lite/quantization:quantization_lib",
"//tensorflow/compiler/mlir/lite/quantization/ir:QuantOps",
"//tensorflow/compiler/mlir/quantization/stablehlo/ops:stablehlo_op_quant_spec",
"//tensorflow/compiler/mlir/quantization/tensorflow:passes",
"//tensorflow/compiler/mlir/quantization/tensorflow:quantization_options_proto_cc",
"//tensorflow/compiler/mlir/quantization/tensorflow/cc:run_passes",
"//tensorflow/compiler/mlir/tensorflow",
"//tensorflow/compiler/mlir/tensorflow:xla_call_module_attrs",
"//tensorflow/core:protos_all_cc",
"//tensorflow/core/platform:path",
"@com_google_absl//absl/algorithm:container",
"@com_google_absl//absl/container:flat_hash_set",
"@com_google_absl//absl/status",
"@llvm-project//llvm:Support",
"@llvm-project//mlir:FuncDialect",
"@llvm-project//mlir:IR",
"@llvm-project//mlir:Pass",
"@llvm-project//mlir:QuantOps",
"@llvm-project//mlir:ShapeDialect",
"@llvm-project//mlir:Support",
"@llvm-project//mlir:TransformUtils",
"@stablehlo//:stablehlo_ops",
],
)

Expand Down
Loading

0 comments on commit 54af26e

Please sign in to comment.