Skip to content

Commit

Permalink
Added pass xla-legalize-tf-types. This pass converts quantized types …
Browse files Browse the repository at this point in the history
…to non-quantized (e.g. qint8 to i8).

PiperOrigin-RevId: 358217198
Change-Id: I0815555f5d0f7c00121825fd4bc75e5016b3ce17
  • Loading branch information
zhangyujing authored and tensorflower-gardener committed Feb 18, 2021
1 parent bd4af92 commit b6d3938
Show file tree
Hide file tree
Showing 6 changed files with 0 additions and 266 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,6 @@ void CreateConvertMlirToXlaHloPipeline(
// inside PromoteResourcesToArgs.
pm.addPass(mlir::mhlo::createLegalizeTFControlFlowPass());

pm.addPass(mlir::mhlo::CreateLegalizeTfTypesPass());
pm.addNestedPass<mlir::FuncOp>(mlir::mhlo::createLegalizeTFPass(
/*allow_partial_conversion=*/true, /*legalize_chlo=*/true,
/*tf2xla_fallback_device_type=*/device_type));
Expand Down
4 changes: 0 additions & 4 deletions tensorflow/compiler/mlir/xla/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ gentbl(
cc_library(
name = "xla_passes",
srcs = [
"transforms/legalize_tf_types.cc",
"transforms/passes_detail.h",
"transforms/prepare_for_export.cc",
],
Expand All @@ -82,12 +81,10 @@ cc_library(
deps = [
":xla_passes_inc_gen",
"//tensorflow/compiler/mlir/hlo",
"//tensorflow/compiler/mlir/tensorflow:tensorflow_types",
"@llvm-project//llvm:Support",
"@llvm-project//mlir:IR",
"@llvm-project//mlir:Pass",
"@llvm-project//mlir:Support",
"@llvm-project//mlir:TransformUtils",
],
alwayslink = 1,
)
Expand All @@ -112,7 +109,6 @@ cc_library(
"//tensorflow/compiler/mlir/hlo:convert_op_folder",
"//tensorflow/compiler/mlir/tensorflow",
"//tensorflow/compiler/mlir/tensorflow:lower_tf_lib",
"//tensorflow/compiler/mlir/tensorflow:tensorflow_types",
"//tensorflow/compiler/xla:shape_util",
"//tensorflow/compiler/xla:xla_data_proto_cc",
"//tensorflow/compiler/xla/client:padding",
Expand Down
54 changes: 0 additions & 54 deletions tensorflow/compiler/mlir/xla/tests/legalize-tf-types.mlir

This file was deleted.

185 changes: 0 additions & 185 deletions tensorflow/compiler/mlir/xla/transforms/legalize_tf_types.cc

This file was deleted.

4 changes: 0 additions & 4 deletions tensorflow/compiler/mlir/xla/transforms/passes.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,6 @@ std::unique_ptr<OperationPass<FuncOp>> createLegalizeTFPass(
std::unique_ptr<OperationPass<FuncOp>> createLegalizeTfWithTf2XlaPass(
llvm::StringRef device_type);

/// Replaces types that do not exist in MHLO with equivalent types that do
/// exist.
std::unique_ptr<OperationPass<ModuleOp>> CreateLegalizeTfTypesPass();

/// Adds the TF to XLA via TF2XLA rewrite patterns to the pattern list.
void PopulateLegalizeTfWithTf2XlaPatterns(llvm::StringRef device_type,
OwningRewritePatternList& patterns);
Expand Down
18 changes: 0 additions & 18 deletions tensorflow/compiler/mlir/xla/transforms/xla_passes.td
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,6 @@ limitations under the License.

include "mlir/Pass/PassBase.td"

def LegalizeTfTypesPass : Pass<"xla-legalize-tf-types"> {
let summary = "Replace TensorFlow types with types that are legal in the MHLO dialect";

let description = [{
The TF dialect uses some TF types that are illegal in the MHLO dialect and
some generic types that are legal in MHLO. This pass legalizes TF types into
types that are legal in MHLO. Rewrites here should run before TF to MHLO op
legalizations are run.

Specifically, this pass replaces each quantized integer type with the
corresponding ordinary types. For example, `TF::Qint8Type` is replaced with `i8`
everywhere it occurs. Types that are replaced are `TF::Qint8Type`,
`TF::Qint16Type`, `TF::Qint32Type`, `TF::Quint8Type`, and `TF::Quint16Type`.
}];

let constructor = "::mlir::mhlo::CreateLegalizeTfTypesPass()";
}

def PrepareForExportPass : FunctionPass<"xla-prepare-for-export"> {
let summary = "Prepare for XLA export";

Expand Down

0 comments on commit b6d3938

Please sign in to comment.