Split out dialect hooks into separate targets

This allows not linking in the hooks too if, for example, one wants the TF dialect but not constant folding via fallback hook.

PiperOrigin-RevId: 347436371
Change-Id: Ib4790e8282073b7c0c6488be5faa1a245c81c372
This commit is contained in:
Jacques Pienaar 2020-12-14 11:54:22 -08:00 committed by TensorFlower Gardener
parent 37b8e9be12
commit ebd14c2c12
7 changed files with 22 additions and 36 deletions

View File

@ -110,6 +110,7 @@ cc_library(
"//tensorflow/compiler/mlir/tensorflow:compile_mlir_util_pass",
"//tensorflow/compiler/mlir/tensorflow:tensorflow_passes",
"//tensorflow/compiler/mlir/tensorflow:tensorflow_test_passes",
"//tensorflow/compiler/mlir/tensorflow:tf_dialect_passes",
"//tensorflow/compiler/mlir/tensorflow:tf_legalize_hlo",
"//tensorflow/compiler/mlir/tfjs:tensorflow_js_passes",
"//tensorflow/compiler/mlir/tosa:tf_passes",

View File

@ -937,7 +937,8 @@ cc_library(
"//tensorflow/compiler/mlir/tensorflow:decode_constant_pass",
"//tensorflow/compiler/mlir/tensorflow:error_util",
"//tensorflow/compiler/mlir/tensorflow:mlir_roundtrip_flags",
"//tensorflow/compiler/mlir/tensorflow:tf_dialect_hooks",
"//tensorflow/compiler/mlir/tensorflow:tf_dialect_lib",
"//tensorflow/compiler/mlir/tensorflow:tf_dialect_passes",
"//tensorflow/compiler/mlir/tensorflow:translate_lib",
"//tensorflow/core:framework",
"//tensorflow/core:protos_all_cc",

View File

@ -1107,6 +1107,7 @@ cc_library(
":mlir_roundtrip_flags",
":tensorflow",
":tensorflow_attributes",
":tensorflow_passes",
":tensorflow_types",
":tf_saved_model_passes",
":translate_utils",
@ -1450,21 +1451,27 @@ cc_library(
)
cc_library(
name = "tf_constant_fallback_hook",
name = "tf_dialect_passes",
srcs = [
"transforms/constant_fold.cc",
"transforms/decode_attributes_hook.cc",
],
hdrs = [
"transforms/constant_fold.h",
],
deps = [
":convert_tensor",
":decode_constant_pass",
":eval_util",
":tensorflow",
":tensorflow_traits",
":tensorflow_types",
"//tensorflow/c:tf_status",
"//tensorflow/c/eager:c_api",
"//tensorflow/core:framework",
"//tensorflow/core:lib",
"//tensorflow/stream_executor",
"//tensorflow/stream_executor/lib",
"@llvm-project//llvm:Support",
"@llvm-project//mlir:IR",
"@llvm-project//mlir:SideEffects",
@ -1474,39 +1481,13 @@ cc_library(
)
cc_library(
name = "tf_decode_attributes_hook",
srcs = [
"transforms/decode_attributes_hook.cc",
],
name = "tf_dialect_lib",
deps = [
":convert_tensor",
":decode_constant_pass",
":tensorflow",
"//tensorflow/core:framework",
"//tensorflow/stream_executor",
"//tensorflow/stream_executor/lib",
"@llvm-project//llvm:Support",
"@llvm-project//mlir:IR",
"@llvm-project//mlir:Support",
],
alwayslink = 1,
)
cc_library(
name = "tf_dialect_hooks",
deps = [
":tf_constant_fallback_hook",
":tf_decode_attributes_hook",
":tf_dialect_passes",
"@llvm-project//mlir:AllPassesAndDialectsNoRegistration",
],
)
# TODO(jpienaar): Remove post updating all.
alias(
name = "tf_dialect_lib",
actual = ":tf_dialect_hooks",
)
cc_library(
name = "tf_graph_optimization_pass",
srcs = ["transforms/tf_graph_optimization_pass.cc"],
@ -1722,8 +1703,8 @@ cc_library(
name = "compile_mlir_util",
hdrs = ["utils/compile_mlir_util.h"],
deps = COMPILE_MLIR_UTIL_DEPS + [
":compile_mlir_util_no_tf_dialect_passes",
":tf_dialect_hooks",
"compile_mlir_util_no_tf_dialect_passes",
":tf_dialect_passes",
],
)

View File

@ -20,6 +20,7 @@ limitations under the License.
#include "mlir/IR/OpDefinition.h" // from @llvm-project
#include "mlir/Interfaces/SideEffectInterfaces.h" // from @llvm-project
#include "mlir/Support/LogicalResult.h" // from @llvm-project
#include "tensorflow/c/eager/c_api.h"
#include "tensorflow/c/tf_status.h"
#include "tensorflow/compiler/mlir/tensorflow/ir/tf_ops.h"
#include "tensorflow/compiler/mlir/tensorflow/ir/tf_traits.h"

View File

@ -25,9 +25,9 @@ limitations under the License.
namespace mlir {
namespace TF {
LogicalResult ConstantFoldFallbackHook(Operation *inst,
ArrayRef<Attribute> operands,
SmallVectorImpl<OpFoldResult> &results);
LogicalResult ConstantFoldFallbackHook(
Operation *inst, ArrayRef<Attribute> operands,
SmallVectorImpl<OpFoldResult> &results); // NOLINT
} // namespace TF
} // namespace mlir

View File

@ -23,6 +23,7 @@ limitations under the License.
#include "mlir/IR/Types.h" // from @llvm-project
#include "mlir/Support/LogicalResult.h" // from @llvm-project
#include "tensorflow/compiler/mlir/tensorflow/ir/tf_ops.h"
#include "tensorflow/compiler/mlir/tensorflow/transforms/constant_fold.h"
#include "tensorflow/compiler/mlir/tensorflow/utils/convert_tensor.h"
#include "tensorflow/core/framework/logging.h"
#include "tensorflow/stream_executor/lib/statusor.h"

View File

@ -175,7 +175,8 @@ cc_library(
"//tensorflow/compiler/mlir/tensorflow",
"//tensorflow/compiler/mlir/tensorflow:decode_constant_pass",
"//tensorflow/compiler/mlir/tensorflow:error_util",
"//tensorflow/compiler/mlir/tensorflow:tf_dialect_hooks",
"//tensorflow/compiler/mlir/tensorflow:tf_dialect_lib",
"//tensorflow/compiler/mlir/tensorflow:tf_dialect_passes",
"//tensorflow/compiler/mlir/tensorflow:translate_cl_options",
"//tensorflow/compiler/mlir/tensorflow:translate_lib",
"//tensorflow/core:framework",