-
Notifications
You must be signed in to change notification settings - Fork 751
/
Copy pathtensorflow-android.patch
193 lines (183 loc) · 7.17 KB
/
tensorflow-android.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
diff -ruN tensorflow-1.12.0-rc0/tensorflow/BUILD tensorflow-1.12.0-rc0-android/tensorflow/BUILD
--- tensorflow-1.12.0-rc0/tensorflow/BUILD 2018-10-09 03:36:57.000000000 +0900
+++ tensorflow-1.12.0-rc0-android/tensorflow/BUILD 2018-10-20 23:50:28.032692484 +0900
@@ -448,29 +448,26 @@
tf_cc_shared_object(
name = "libtensorflow_cc.so",
- linkopts = select({
- "//tensorflow:darwin": [
- "-Wl,-exported_symbols_list", # This line must be directly followed by the exported_symbols.lds file
- "$(location //tensorflow:tf_exported_symbols.lds)",
- ],
- "//tensorflow:windows": [],
- "//conditions:default": [
- "-z defs",
- "-Wl,--version-script", # This line must be directly followed by the version_script.lds file
- "$(location //tensorflow:tf_version_script.lds)",
- ],
- }),
+# copts = tf_copts(),
+ linkopts = [
+ "-landroid",
+ "-ljnigraphics",
+ "-llog",
+ "-lm",
+ "-z defs",
+ "-s",
+ "-ldl",
+# "-Wl,--icf=all", # Identical Code Folding
+ ],
+ tags = [
+ "manual",
+ "notap",
+ ],
+# linkshared = 1,
+ linkstatic = 1,
visibility = ["//visibility:public"],
deps = [
- "//tensorflow:tf_exported_symbols.lds",
- "//tensorflow:tf_version_script.lds",
- "//tensorflow/c:c_api",
- "//tensorflow/c/eager:c_api",
- "//tensorflow/cc:cc_ops",
- "//tensorflow/cc:client_session",
- "//tensorflow/cc:scope",
- "//tensorflow/cc/profiler",
- "//tensorflow/core:tensorflow",
+ "//tensorflow/core:android_tensorflow_lib",
] + if_ngraph(["@ngraph_tf//:ngraph_tf"]),
)
diff -ruN tensorflow-1.12.0-rc0/tensorflow/c/BUILD tensorflow-1.12.0-rc0-android/tensorflow/c/BUILD
--- tensorflow-1.12.0-rc0/tensorflow/c/BUILD 2018-10-09 03:36:57.000000000 +0900
+++ tensorflow-1.12.0-rc0-android/tensorflow/c/BUILD 2018-10-20 23:50:28.032692484 +0900
@@ -145,6 +145,22 @@
visibility = ["//visibility:public"],
)
+filegroup(
+ name = "c_api_files",
+ srcs = glob(
+ ["**/*"],
+ exclude = [
+ "**/METADATA",
+ "**/OWNERS",
+ "**/*test*.cc",
+ "**/python_api.cc",
+ "c_api_experimental.cc",
+ "c_api_experimental.h",
+ ],
+ ),
+ visibility = ["//visibility:public"],
+)
+
tf_cuda_library(
name = "tf_status_helper",
srcs = ["tf_status_helper.cc"],
diff -ruN tensorflow-1.12.0-rc0/tensorflow/core/BUILD tensorflow-1.12.0-rc0-android/tensorflow/core/BUILD
--- tensorflow-1.12.0-rc0/tensorflow/core/BUILD 2018-10-09 03:36:57.000000000 +0900
+++ tensorflow-1.12.0-rc0-android/tensorflow/core/BUILD 2018-10-20 23:50:28.033692483 +0900
@@ -1704,7 +1704,11 @@
# binary size (by packaging a reduced operator set) is a concern.
cc_library(
name = "android_tensorflow_lib",
- srcs = if_android([":android_op_registrations_and_gradients"]),
+ srcs = if_android([
+ ":android_op_registrations_and_gradients",
+ "//tensorflow/c:c_api_files",
+ "//tensorflow/java/src/main/native:java_api_files",
+ ]),
copts = tf_copts(),
tags = [
"manual",
diff -ruN tensorflow-1.12.0-rc0/tensorflow/core/framework/tensor.h tensorflow-1.12.0-rc0-android/tensorflow/core/framework/tensor.h
--- tensorflow-1.12.0-rc0/tensorflow/core/framework/tensor.h 2018-10-09 03:36:57.000000000 +0900
+++ tensorflow-1.12.0-rc0-android/tensorflow/core/framework/tensor.h 2018-10-20 23:50:28.033692483 +0900
@@ -118,6 +118,11 @@
/// are not valid.
Tensor(Tensor&& other);
+ // Creates a tensor with the input datatype, shape and buf.
+ //
+ // Acquires a ref on buf that belongs to this Tensor.
+ Tensor(DataType type, const TensorShape& shape, TensorBuffer* buf);
+
~Tensor();
/// Returns the data type.
@@ -523,11 +528,6 @@
friend class NumpyTensorBuffer; // For access to the private constructor
// taking the buffer.
- // Creates a tensor with the input datatype, shape and buf.
- //
- // Acquires a ref on buf that belongs to this Tensor.
- Tensor(DataType type, const TensorShape& shape, TensorBuffer* buf);
-
bool CanUseDMA() const;
// Only needed by variable op to set the shape of an uninitialized
diff -ruN tensorflow-1.12.0-rc0/tensorflow/core/kernels/BUILD tensorflow-1.12.0-rc0-android/tensorflow/core/kernels/BUILD
--- tensorflow-1.12.0-rc0/tensorflow/core/kernels/BUILD 2018-10-09 03:36:57.000000000 +0900
+++ tensorflow-1.12.0-rc0-android/tensorflow/core/kernels/BUILD 2018-10-20 23:50:28.034692482 +0900
@@ -5206,6 +5206,7 @@
"transpose_op.h",
"where_op.h",
"xent_op.h",
+ "cwise_op_floor.cc",
],
)
diff -ruN tensorflow-1.12.0-rc0/tensorflow/java/BUILD tensorflow-1.12.0-rc0-android/tensorflow/java/BUILD
--- tensorflow-1.12.0-rc0/tensorflow/java/BUILD 2018-10-09 03:36:57.000000000 +0900
+++ tensorflow-1.12.0-rc0-android/tensorflow/java/BUILD 2018-10-20 23:50:42.181675353 +0900
@@ -23,7 +23,6 @@
":java_op_sources",
":java_sources",
],
- data = [":libtensorflow_jni"],
javacopts = JAVACOPTS,
plugins = [":processor"],
visibility = ["//visibility:public"],
diff -ruN tensorflow-1.12.0-rc0/tensorflow/java/src/main/native/BUILD tensorflow-1.12.0-rc0-android/tensorflow/java/src/main/native/BUILD
--- tensorflow-1.12.0-rc0/tensorflow/java/src/main/native/BUILD 2018-10-09 03:36:57.000000000 +0900
+++ tensorflow-1.12.0-rc0-android/tensorflow/java/src/main/native/BUILD 2018-10-20 23:50:28.034692482 +0900
@@ -86,3 +86,15 @@
),
visibility = ["//tensorflow:__subpackages__"],
)
+
+filegroup(
+ name = "java_api_files",
+ srcs = glob(
+ ["**/*"],
+ exclude = [
+ "**/METADATA",
+ "**/OWNERS",
+ ],
+ ),
+ visibility = ["//visibility:public"],
+)
diff -ruN tensorflow-1.12.0-rc0/tensorflow/tensorflow.bzl tensorflow-1.12.0-rc0-android/tensorflow/tensorflow.bzl
--- tensorflow-1.12.0-rc0/tensorflow/tensorflow.bzl 2018-10-09 03:36:57.000000000 +0900
+++ tensorflow-1.12.0-rc0-android/tensorflow/tensorflow.bzl 2018-10-20 23:50:28.035692480 +0900
@@ -230,7 +230,7 @@
# to be used, pass android_optimization_level_override=None
android_copts = [
"-std=c++11",
- "-DTF_LEAN_BINARY",
+# "-DTF_LEAN_BINARY",
"-Wno-narrowing",
"-fomit-frame-pointer",
]
diff -ruN tensorflow-1.12.0-rc0/WORKSPACE tensorflow-1.12.0-rc0-android/WORKSPACE
--- tensorflow-1.12.0-rc0/WORKSPACE 2018-10-09 03:36:57.000000000 +0900
+++ tensorflow-1.12.0-rc0-android/WORKSPACE 2018-10-20 23:50:28.035692480 +0900
@@ -27,6 +27,16 @@
load("@local_config_android//:android.bzl", "android_workspace")
android_workspace()
+android_ndk_repository(
+ name="androidndk",
+ path="<PATH_TO_NDK>",
+ # This needs to be 14 or higher to compile TensorFlow.
+ # Please specify API level to >= 21 to build for 64-bit
+ # archtectures or the Android NDK will automatically select biggest
+ # API level that it supports without notice.
+ # Note that the NDK version is not the API level.
+ api_level=14)
+
# Please add all new TensorFlow dependencies in workspace.bzl.
tf_workspace()