1/*
2 * Copyright 2017 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17cc_library_headers {
18    name: "libneuralnetworks_common_headers",
19    host_supported: false,
20    export_include_dirs: ["include"],
21}
22
23cc_defaults {
24    name: "neuralnetworks_operations",
25    srcs: [
26        "OperationResolver.cpp",
27        "operations/Activation.cpp",
28        "operations/BidirectionalSequenceRNN.cpp",
29        "operations/Broadcast.cpp",
30        "operations/ChannelShuffle.cpp",
31        "operations/Comparisons.cpp",
32        "operations/Concatenation.cpp",
33        "operations/Conv2D.cpp",
34        "operations/Dequantize.cpp",
35        "operations/Elementwise.cpp",
36        "operations/FullyConnected.cpp",
37        "operations/Gather.cpp",
38        "operations/GenerateProposals.cpp",
39        "operations/HeatmapMaxKeypoint.cpp",
40        "operations/InstanceNormalization.cpp",
41        "operations/L2Normalization.cpp",
42        "operations/LogicalAndOr.cpp",
43        "operations/LogicalNot.cpp",
44        "operations/LogSoftmax.cpp",
45        "operations/Neg.cpp",
46        "operations/Pooling.cpp",
47        "operations/PRelu.cpp",
48        "operations/Quantize.cpp",
49        "operations/Reduce.cpp",
50        "operations/ResizeImageOps.cpp",
51        "operations/RoiAlign.cpp",
52        "operations/RoiPooling.cpp",
53        "operations/Select.cpp",
54        "operations/Slice.cpp",
55        "operations/Softmax.cpp",
56        "operations/Transpose.cpp",
57        "operations/TransposeConv2D.cpp",
58        "operations/UnidirectionalSequenceLSTM.cpp",
59        "operations/UnidirectionalSequenceRNN.cpp",
60    ],
61}
62
63cc_library_static {
64    name: "libneuralnetworks_utils",
65    defaults: ["neuralnetworks_defaults", "neuralnetworks_operations"],
66    host_supported: false,
67    vendor_available: true,
68    export_include_dirs: ["include"],
69    srcs: [
70        "Utils.cpp",
71        "ExecutionBurstController.cpp",
72        "ExecutionBurstServer.cpp",
73    ],
74    header_libs: [
75        "libneuralnetworks_headers",
76        "libeigen",
77        "gemmlowp_headers",
78        "tensorflow_headers",
79    ],
80    shared_libs: [
81        "libhidltransport",
82        "libhidlmemory",
83        "libnativewindow",
84        "libfmq",
85        "android.hardware.neuralnetworks@1.0",
86        "android.hardware.neuralnetworks@1.1",
87        "android.hardware.neuralnetworks@1.2",
88        "android.hidl.allocator@1.0",
89        "android.hidl.memory@1.0",
90    ],
91    whole_static_libs: [
92        "libarect",
93    ],
94    cflags: [
95        "-DTF_LITE_DISABLE_X86_NEON",
96        "-Werror",
97        "-Wall",
98        "-Wextra",
99        "-Wno-extern-c-compat",
100        "-Wno-sign-compare",
101        "-Wno-unused-local-typedef",
102        "-Wno-unused-parameter",
103        "-Wno-unused-private-field",
104        "-Wno-unused-variable",
105        "-Wno-invalid-partial-specialization",
106    ],
107}
108
109cc_library_static {
110    name: "libneuralnetworks_common",
111    defaults: ["neuralnetworks_defaults", "neuralnetworks_operations"],
112    host_supported: false,
113    vendor_available: true,
114    // b/109953668, disable OpenMP
115    // openmp: true,
116    export_include_dirs: [
117        "include",
118    ],
119    srcs: [
120        "CpuExecutor.cpp",
121        "ExecutionBurstController.cpp",
122        "ExecutionBurstServer.cpp",
123        "GraphDump.cpp",
124        "IndexedShapeWrapper.cpp",
125        "OperationsUtils.cpp",
126        "TokenHasher.cpp",
127        "Utils.cpp",
128        "ValidateHal.cpp",
129        "operations/ArgMinMax.cpp",
130        "operations/BidirectionalSequenceLSTM.cpp",
131        "operations/Cast.cpp",
132        "operations/DepthwiseConv2D.cpp",
133        "operations/EmbeddingLookup.cpp",
134        "operations/ExpandDims.cpp",
135        "operations/GroupedConv2D.cpp",
136        "operations/HashtableLookup.cpp",
137        "operations/LSHProjection.cpp",
138        "operations/LSTM.cpp",
139        "operations/MaximumMinimum.cpp",
140        "operations/Multinomial.cpp",
141        "operations/Normalization.cpp",
142        "operations/Pow.cpp",
143        "operations/TopK_V2.cpp",
144        "operations/QuantizedLSTM.cpp",
145        "operations/Reshape.cpp",
146        "operations/RNN.cpp",
147        "operations/SimpleMath.cpp",
148        "operations/Split.cpp",
149        "operations/StridedSlice.cpp",
150        "operations/SVDF.cpp",
151        "operations/Tile.cpp",
152    ],
153    shared_libs: [
154        "libbase",
155        "libcutils",
156        "libhidlbase",
157        "libhidltransport",
158        "libhidlmemory",
159        "libnativewindow",
160        "libfmq",
161        "libtextclassifier_hash",
162        "libui",
163        "liblog",
164        "libutils",
165        "android.hardware.neuralnetworks@1.0",
166        "android.hardware.neuralnetworks@1.1",
167        "android.hardware.neuralnetworks@1.2",
168        "android.hidl.allocator@1.0",
169        "android.hidl.memory@1.0",
170    ],
171    static_libs: [
172        "libcrypto_static",
173    ],
174    header_libs: [
175        "libneuralnetworks_headers",
176        "libtextclassifier_hash_headers",
177        "libeigen",
178        "gemmlowp_headers",
179        "philox_random_headers",
180        "tensorflow_headers",
181    ],
182    whole_static_libs: [
183        "libarect",
184        "libtflite_kernel_utils",
185        "philox_random",
186    ],
187
188    cflags: [
189        "-DNN_INCLUDE_CPU_IMPLEMENTATION",
190        "-DNAMESPACE_FOR_HASH_FUNCTIONS=farmhash",
191        "-DTF_LITE_DISABLE_X86_NEON",
192        "-Werror",
193        "-Wall",
194        "-Wextra",
195        "-Wno-extern-c-compat",
196        "-Wno-sign-compare",
197        "-Wno-unused-local-typedef",
198        "-Wno-unused-parameter",
199        "-Wno-unused-private-field",
200        "-Wno-unused-variable",
201        "-Wno-invalid-partial-specialization",
202        "-Wno-array-bounds",
203    ],
204}
205
206cc_test {
207    name: "NeuralNetworksTest_operations",
208    shared_libs: [
209        "libhidlmemory",
210        "libnativewindow",
211        "libneuralnetworks",
212        "android.hardware.neuralnetworks@1.0",
213        "android.hardware.neuralnetworks@1.1",
214        "android.hardware.neuralnetworks@1.2",
215        "android.hidl.allocator@1.0",
216        "android.hidl.memory@1.0",
217    ],
218    static_libs: [
219        "libbase",
220        "libgmock",
221        "liblog",
222        "libneuralnetworks_common",
223    ],
224    cflags: [
225        "-Wno-extern-c-compat",
226        "-Wno-unused-parameter",
227        "-Wno-invalid-partial-specialization",
228    ],
229    srcs: [
230        "operations/*Test.cpp",
231    ],
232    local_include_dirs: [ "include" ],
233    header_libs: [
234        "libeigen",
235        "philox_random_headers",
236        "tensorflow_headers",
237    ],
238}
239
240cc_test {
241    name: "NeuralNetworksTest_utils",
242    shared_libs: [
243        "libhidlmemory",
244        "libnativewindow",
245        "libneuralnetworks",
246        "android.hardware.neuralnetworks@1.0",
247        "android.hardware.neuralnetworks@1.1",
248        "android.hardware.neuralnetworks@1.2",
249        "android.hidl.allocator@1.0",
250        "android.hidl.memory@1.0",
251    ],
252    static_libs: [
253        "libbase",
254        "libgmock",
255        "liblog",
256        "libneuralnetworks_common",
257    ],
258    cflags: [
259        "-Wno-extern-c-compat",
260        "-Wno-unused-variable",
261    ],
262    srcs: [
263        "UtilsTest.cpp",
264    ],
265    local_include_dirs: [ "include" ],
266    header_libs: [
267        "tensorflow_headers",
268    ],
269}
270