Skip to content

Commit 2ff5bd5

Browse files
Use the internal version of builtin_op_data.h in mlir/lite.
PiperOrigin-RevId: 646170820
1 parent 20fa4d9 commit 2ff5bd5

File tree

5 files changed

+54
-9
lines changed

5 files changed

+54
-9
lines changed

tensorflow/compiler/mlir/lite/BUILD

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1028,6 +1028,7 @@ cc_library(
10281028
":convert_type",
10291029
":converter_inc",
10301030
":tensorflow_lite",
1031+
"//tensorflow/compiler/mlir/lite/core/c:private_common",
10311032
"//tensorflow/compiler/mlir/lite/schema:schema_fbs",
10321033
"//tensorflow/compiler/mlir/lite/schema:schema_fbs_with_mutable",
10331034
"//tensorflow/compiler/mlir/lite/schema:schema_utils",
@@ -1036,7 +1037,6 @@ cc_library(
10361037
"//tensorflow/core/platform:errors",
10371038
"//tensorflow/core/platform:status",
10381039
"//tensorflow/core/platform:statusor",
1039-
"//tensorflow/lite/core/c:private_common",
10401040
"//tensorflow/lite/kernels/internal:kernel_utils",
10411041
"@com_google_absl//absl/container:flat_hash_map",
10421042
"@com_google_absl//absl/status:statusor",
@@ -1092,6 +1092,7 @@ cc_library(
10921092
":tensorflow_lite",
10931093
"//tensorflow/compiler/mlir:op_or_arg_name_mapper",
10941094
"//tensorflow/compiler/mlir/lite:control_edges",
1095+
"//tensorflow/compiler/mlir/lite/core/c:private_common",
10951096
"//tensorflow/compiler/mlir/lite/experimental/remat:metadata_util",
10961097
"//tensorflow/compiler/mlir/lite/metrics:error_collector_inst",
10971098
"//tensorflow/compiler/mlir/lite/quantization/ir:QuantOps",
@@ -1106,7 +1107,6 @@ cc_library(
11061107
"//tensorflow/core:portable_gif_internal",
11071108
"//tensorflow/core:protos_all_cc",
11081109
"//tensorflow/lite/core:framework",
1109-
"//tensorflow/lite/core/c:private_common",
11101110
"//tensorflow/lite/delegates/flex:allowlisted_flex_ops_lib",
11111111
"//tensorflow/lite/python/metrics:converter_error_data_proto_cc",
11121112
"//tensorflow/lite/toco:toco_flags_proto_cc",

tensorflow/compiler/mlir/lite/core/c/BUILD

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,31 @@ package(
99
licenses = ["notice"],
1010
)
1111

12-
# LINT.IfChange(cc_library_common)
12+
# LINT.IfChange(common)
1313
cc_library(
1414
name = "common",
1515
srcs = [],
1616
hdrs = ["builtin_op_data.h"],
1717
compatible_with = get_compatible_with_portable(),
1818
copts = tflite_copts(),
1919
visibility = [
20-
"//tensorflow/compiler/mlir/lite/kernels:__pkg__",
20+
"//tensorflow/compiler/mlir/lite:__subpackages__",
2121
"//tensorflow/compiler/mlir/quantization/tensorflow/utils:__pkg__",
2222
],
2323
alwayslink = 1, # Why?? TODO(b/161243354): eliminate this.
2424
)
25-
# LINT.ThenChange(//tensorflow/lite/core/c/BUILD)
25+
# LINT.ThenChange(//tensorflow/lite/core/c:common)
26+
27+
# LINT.IfChange(private_common)
28+
# This is a private target, its visibility is set to public only to be
29+
# used by "tflite_custom_c_library" and "tflite_flex_cc_library".
30+
# Do not use this target directly and don't consider it as a part of the public API.
31+
alias(
32+
name = "private_common",
33+
actual = ":common",
34+
tags = ["avoid_dep"],
35+
visibility = [
36+
"//visibility:public",
37+
],
38+
)
39+
# LINT.ThenChange(//tensorflow/lite/core/c:private_common)

tensorflow/compiler/mlir/lite/core/c/builtin_op_data.h

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,45 @@ limitations under the License.
1515
#ifndef TENSORFLOW_COMPILER_MLIR_LITE_CORE_C_BUILTIN_OP_DATA_H_
1616
#define TENSORFLOW_COMPILER_MLIR_LITE_CORE_C_BUILTIN_OP_DATA_H_
1717

18-
// LINT.IfChange
18+
// LINT.IfChange(enum)
1919
typedef enum {
2020
kTfLitePaddingUnknown = 0,
2121
kTfLitePaddingSame,
2222
kTfLitePaddingValid,
2323
} TfLitePadding;
2424

25+
// Possible fused activation functions.
26+
typedef enum {
27+
kTfLiteActNone = 0,
28+
kTfLiteActRelu,
29+
kTfLiteActReluN1To1, // min(max(-1, x), 1)
30+
kTfLiteActRelu6, // min(max(0, x), 6)
31+
kTfLiteActTanh,
32+
kTfLiteActSignBit,
33+
kTfLiteActSigmoid,
34+
} TfLiteFusedActivation;
35+
// LINT.ThenChange(//tensorflow/lite/core/c/builtin_op_data.h)
36+
37+
// LINT.IfChange(struct)
38+
// TODO(b/130259536): We should move this out of builtin_op_data.
39+
typedef struct {
40+
int width;
41+
int height;
42+
int width_offset;
43+
int height_offset;
44+
} TfLitePaddingValues;
45+
46+
typedef struct {
47+
TfLitePadding padding;
48+
int stride_width;
49+
int stride_height;
50+
int filter_width;
51+
int filter_height;
52+
TfLiteFusedActivation activation;
53+
struct {
54+
TfLitePaddingValues padding;
55+
} computed;
56+
} TfLitePoolParams;
2557
// LINT.ThenChange(//tensorflow/lite/core/c/builtin_op_data.h)
2658

2759
#endif // TENSORFLOW_COMPILER_MLIR_LITE_CORE_C_BUILTIN_OP_DATA_H_

tensorflow/compiler/mlir/lite/flatbuffer_export.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ limitations under the License.
8181
#include "mlir/Support/LogicalResult.h" // from @llvm-project
8282
#include "stablehlo/dialect/StablehloOps.h" // from @stablehlo
8383
#include "stablehlo/dialect/VhloOps.h" // from @stablehlo
84+
#include "tensorflow/compiler/mlir/lite/core/c/builtin_op_data.h"
8485
#include "tensorflow/compiler/mlir/lite/experimental/remat/metadata_util.h"
8586
#include "tensorflow/compiler/mlir/lite/flatbuffer_operator.h"
8687
#include "tensorflow/compiler/mlir/lite/ir/tfl_ops.h"
@@ -109,7 +110,6 @@ limitations under the License.
109110
#include "tensorflow/core/framework/tensor.h"
110111
#include "tensorflow/core/framework/types.pb.h"
111112
#include "tensorflow/core/platform/tstring.h"
112-
#include "tensorflow/lite/core/c/builtin_op_data.h"
113113
#include "tensorflow/lite/core/interpreter.h"
114114
#include "tensorflow/lite/core/macros.h"
115115
#include "tensorflow/lite/delegates/flex/allowlisted_flex_ops.h"

tensorflow/compiler/mlir/lite/flatbuffer_operator.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ limitations under the License.
4646
#include "mlir/Support/LLVM.h" // from @llvm-project
4747
#include "stablehlo/dialect/StablehloOps.h" // from @stablehlo
4848
#include "stablehlo/dialect/VhloOps.h" // from @stablehlo
49+
#include "tensorflow/compiler/mlir/lite/core/c/builtin_op_data.h"
4950
#include "tensorflow/compiler/mlir/lite/ir/tfl_ops.h"
5051
#include "tensorflow/compiler/mlir/lite/schema/mutable/schema_generated.h"
5152
#include "tensorflow/compiler/mlir/lite/schema/schema_utils.h"
@@ -54,8 +55,6 @@ limitations under the License.
5455
#include "tensorflow/compiler/mlir/tensorflow/utils/dynamic_shape_utils.h"
5556
#include "tensorflow/core/platform/errors.h"
5657
#include "tensorflow/core/platform/status.h"
57-
#include "tensorflow/lite/core/c/builtin_op_data.h"
58-
#include "tensorflow/lite/kernels/internal/kernel_utils.h"
5958
#include "tsl/platform/status.h"
6059

6160
namespace {

0 commit comments

Comments
 (0)