aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow
diff options
context:
space:
mode:
authorGravatar A. Unique TensorFlower <nobody@tensorflow.org>2016-06-01 12:19:59 -0800
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2016-06-01 13:33:56 -0700
commited15987bb7698d4019c24877420d16d072028f6a (patch)
tree5d35ce37a3cfd974b1d558e23d38e12d5b95ab2c /tensorflow
parentfc33e0f3783cab0d7486f6e277e77e1c95ce291d (diff)
Adding a new cc_library for Android which supports selective
registration. Change: 123787111
Diffstat (limited to 'tensorflow')
-rw-r--r--tensorflow/core/BUILD37
-rw-r--r--tensorflow/core/framework/register_types.h3
-rw-r--r--tensorflow/core/framework/types.cc2
-rw-r--r--tensorflow/core/kernels/BUILD43
4 files changed, 79 insertions, 6 deletions
diff --git a/tensorflow/core/BUILD b/tensorflow/core/BUILD
index 7a16a19be7..96cb371fca 100644
--- a/tensorflow/core/BUILD
+++ b/tensorflow/core/BUILD
@@ -43,6 +43,8 @@
# filegroup ":android_proto_srcs" - Protos
# filegroup ":android_srcs" - Core sources
# cc_library ":android_tensorflow_lib" - Native library
+# cc_library ":android_tensorflow_lib_selective_registration" - Native library
+# supporting SELECTIVE_REGISTRATION feature.
# portable_proto_library ":android_proto_lib" (Google-internal)
package(default_visibility = ["//tensorflow:internal"])
@@ -650,9 +652,9 @@ filegroup(
visibility = ["//visibility:public"],
)
-# Native library support for Android applications.
-# Does not contain operators, use :android_tensorflow_lib if you want full
-# operator support.
+# Native library support for Android applications. Does not contain
+# operators, use :android_tensorflow_lib if you want full operator
+# support.
#
# Compiles to a trivial library on non-Android to prevent irrelevant
# build errors. If not building this as part of an android_binary,
@@ -708,6 +710,35 @@ cc_library(
alwayslink = 1,
)
+# Android library for use with the SELECTIVE_REGISTRATION feature.
+# Does not contain operators. In contrast to android_tensorflow_lib_lite,
+# this links in framework support for all types, relying on selective
+# registration of ops to prune code size.
+cc_library(
+ name = "android_tensorflow_lib_selective_registration",
+ srcs =
+ select({
+ "//tensorflow:android": [
+ "//tensorflow/core:android_srcs",
+ ],
+ "//conditions:default": [],
+ }),
+ copts = tf_copts() + [
+ "-Os",
+ "-DSUPPORT_SELECTIVE_REGISTRATION",
+ ],
+ tags = [
+ "manual",
+ "notap",
+ ],
+ visibility = ["//visibility:public"],
+ deps = [
+ ":protos_cc",
+ "//third_party/eigen3",
+ ],
+ alwayslink = 1,
+)
+
filegroup(
name = "android_op_registrations_and_gradients",
srcs = glob(
diff --git a/tensorflow/core/framework/register_types.h b/tensorflow/core/framework/register_types.h
index d1baac5d20..af82948b04 100644
--- a/tensorflow/core/framework/register_types.h
+++ b/tensorflow/core/framework/register_types.h
@@ -43,8 +43,7 @@ limitations under the License.
#undef REGISTER_PARTITION
*/
-#if !defined(__ANDROID__)
-
+#if !defined(__ANDROID__) || defined(SUPPORT_SELECTIVE_REGISTRATION)
// Call "m" for all number types that support the comparison operations "<" and
// ">".
#define TF_CALL_INTEGRAL_TYPES(m) \
diff --git a/tensorflow/core/framework/types.cc b/tensorflow/core/framework/types.cc
index 48eae6c6a4..ca4f4700b0 100644
--- a/tensorflow/core/framework/types.cc
+++ b/tensorflow/core/framework/types.cc
@@ -181,7 +181,7 @@ DataTypeVector AllTypes() {
DT_QUINT16, DT_QINT32, DT_HALF};
}
-#if !defined(__ANDROID__)
+#if !defined(__ANDROID__) || defined(SUPPORT_SELECTIVE_REGISTRATION)
DataTypeVector RealNumberTypes() {
return {DT_FLOAT, DT_DOUBLE, DT_INT32, DT_INT64, DT_UINT8,
diff --git a/tensorflow/core/kernels/BUILD b/tensorflow/core/kernels/BUILD
index 76056d71aa..2e4a84d5a1 100644
--- a/tensorflow/core/kernels/BUILD
+++ b/tensorflow/core/kernels/BUILD
@@ -1785,6 +1785,49 @@ filegroup(
],
)
+# A file group which contains nearly all available operators which
+# may work on Android. This is intended to be used with selective
+# registration.
+filegroup(
+ name = "android_all_ops",
+ srcs = glob(
+ [
+ "*.cc",
+ "*.h",
+ ],
+ exclude = [
+ "*test.cc",
+ "*testutil*",
+ "*testlib*",
+ "*main.cc",
+ "*_gpu*",
+ "*_3d*",
+ "*.cu.*",
+ # Ops already in android_srcs
+ "ops_util.cc",
+ "pooling_ops_common.cc",
+ # Ops which we are currently excluding because they are likely
+ # not used on Android. Those ops also do not compile if included,
+ # unless we add the additional deps they need.
+ "tf_record_reader_op.*",
+ "string_to_hash_bucket_op.*",
+ "text_line_reader_op.*",
+ "summary_image_op.*",
+ "encode_png_op.*",
+ "decode_png_op.*",
+ "encode_jpeg_op.*",
+ "decode_jpeg_op.*",
+ "identity_reader_op.*",
+ "reader_base.*",
+ "fixed_length_record_reader_op.*",
+ "whole_file_read_ops.*",
+ "sample_distorted_bounding_box_op.*",
+ "ctc_loss_op.*",
+ ],
+ ),
+ visibility = ["//visibility:public"],
+)
+
cc_library(
name = "android_tensorflow_kernels",
srcs = select({