[ndk] Add enable profile flag
[platform/core/ml/nntrainer.git] / jni / Android.mk
1 # ndk-build NDK_PROJECT_PATH=. APP_BUILD_SCRIPT=./Android.mk NDK_APPLICATION_MK=./Application.mk -j2
2 LOCAL_PATH := $(call my-dir)
3 include $(CLEAR_VARS)
4
5 ENABLE_TFLITE_BACKBONE := 1
6
7 ifndef NNTRAINER_ROOT
8 NNTRAINER_ROOT := $(LOCAL_PATH)/..
9 endif
10
11 ifndef NDK_LIBS_OUT
12 NDK_LIBS_OUT := $(NDK_PROJECT_PATH)
13 endif
14
15 include $(CLEAR_VARS)
16
17 ifndef INIPARSER_ROOT
18 ifneq ($(MAKECMDGOALS),clean)
19 $(warning INIPARSER_ROOT is not defined!)
20 $(warning INIPARSER SRC is going to be downloaded!)
21
22 INIPARSER_ROOT :=$(NDK_LIBS_OUT)/iniparser
23
24 $(info $(shell ($(LOCAL_PATH)/prepare_iniparser.sh $(NDK_LIBS_OUT))))
25
26 endif
27 endif
28
29
30 include $(CLEAR_VARS)
31
32 NNTRAINER_JNI_ROOT := $(NNTRAINER_ROOT)/jni
33
34 # Build tflite if its backbone is enabled
35 ifeq ($(ENABLE_TFLITE_BACKBONE),1)
36 $(warning BUILDING TFLITE BACKBONE !)
37 TENSORFLOW_VERSION := 1.13.1
38
39 ifndef TENSORFLOW_ROOT
40 ifneq ($(MAKECMDGOALS),clean)
41 $(warning TENSORFLOW_ROOT is not defined!)
42 $(warning TENSORFLOW SRC is going to be downloaded!)
43
44 TENSORFLOW_ROOT := $(NDK_LIBS_OUT)/tensorflow-$(TENSORFLOW_VERSION)/tensorflow-lite
45
46 $(info $(shell ($(NNTRAINER_JNI_ROOT)/prepare_tflite.sh $(TENSORFLOW_VERSION) $(NDK_LIBS_OUT))))
47
48 endif #TENSORFLOW_ROOT
49 endif #MAKECMDGOALS
50
51 LOCAL_MODULE := tensorflow-lite
52 LOCAL_SRC_FILES := $(TENSORFLOW_ROOT)/lib/arm64/libtensorflow-lite.a
53 LOCAL_C_INCLUDES := $(TENSORFLOW_ROOT)/include
54 TFLITE_INCLUDES := $(LOCAL_C_INCLUDES)
55
56 include $(PREBUILT_STATIC_LIBRARY)
57
58 include $(CLEAR_VARS)
59 endif #ENABLE_TFLITE_BACKBONE
60
61 NNTRAINER_SRCS := $(NNTRAINER_ROOT)/nntrainer/models/neuralnet.cpp \
62                   $(NNTRAINER_ROOT)/nntrainer/models/model_loader.cpp \
63                   $(NNTRAINER_ROOT)/nntrainer/dataset/databuffer.cpp \
64                   $(NNTRAINER_ROOT)/nntrainer/dataset/databuffer_factory.cpp \
65                   $(NNTRAINER_ROOT)/nntrainer/dataset/databuffer_func.cpp \
66                   $(NNTRAINER_ROOT)/nntrainer/dataset/databuffer_file.cpp \
67                   $(NNTRAINER_ROOT)/nntrainer/tensor/tensor.cpp \
68                   $(NNTRAINER_ROOT)/nntrainer/tensor/lazy_tensor.cpp \
69                   $(NNTRAINER_ROOT)/nntrainer/tensor/manager.cpp \
70                   $(NNTRAINER_ROOT)/nntrainer/tensor/var_grad.cpp \
71                   $(NNTRAINER_ROOT)/nntrainer/tensor/weight.cpp \
72                   $(NNTRAINER_ROOT)/nntrainer/tensor/tensor_dim.cpp \
73                   $(NNTRAINER_ROOT)/nntrainer/tensor/blas_interface.cpp \
74                   $(NNTRAINER_ROOT)/nntrainer/layers/layer.cpp \
75                   $(NNTRAINER_ROOT)/nntrainer/layers/layer_factory.cpp \
76                   $(NNTRAINER_ROOT)/nntrainer/layers/input_layer.cpp \
77                   $(NNTRAINER_ROOT)/nntrainer/layers/output_layer.cpp \
78                   $(NNTRAINER_ROOT)/nntrainer/layers/fc_layer.cpp \
79                   $(NNTRAINER_ROOT)/nntrainer/layers/bn_layer.cpp \
80                   $(NNTRAINER_ROOT)/nntrainer/layers/loss_layer.cpp \
81                   $(NNTRAINER_ROOT)/nntrainer/layers/conv2d_layer.cpp \
82                   $(NNTRAINER_ROOT)/nntrainer/layers/pooling2d_layer.cpp \
83                   $(NNTRAINER_ROOT)/nntrainer/layers/activation_layer.cpp \
84                   $(NNTRAINER_ROOT)/nntrainer/layers/flatten_layer.cpp \
85                   $(NNTRAINER_ROOT)/nntrainer/layers/addition_layer.cpp \
86                   $(NNTRAINER_ROOT)/nntrainer/layers/concat_layer.cpp \
87                   $(NNTRAINER_ROOT)/nntrainer/graph/network_graph.cpp \
88                   $(NNTRAINER_ROOT)/nntrainer/optimizers/optimizer.cpp \
89                   $(NNTRAINER_ROOT)/nntrainer/optimizers/adam.cpp \
90                   $(NNTRAINER_ROOT)/nntrainer/optimizers/sgd.cpp \
91                   $(NNTRAINER_ROOT)/nntrainer/optimizers/optimizer_factory.cpp \
92                   $(NNTRAINER_ROOT)/nntrainer/utils/util_func.cpp \
93                   $(NNTRAINER_ROOT)/nntrainer/utils/parse_util.cpp \
94                   $(NNTRAINER_ROOT)/nntrainer/app_context.cpp
95
96 # Add tflite backbone building
97 ifeq ($(ENABLE_TFLITE_BACKBONE),1)
98 NNTRAINER_SRCS += $(NNTRAINER_ROOT)/nntrainer/layers/tflite_layer.cpp
99 endif #ENABLE_TFLITE_BACKBONE
100
101 NNTRAINER_INCLUDES := $(NNTRAINER_ROOT)/nntrainer \
102                       $(NNTRAINER_ROOT)/nntrainer/dataset \
103                       $(NNTRAINER_ROOT)/nntrainer/layers \
104                       $(NNTRAINER_ROOT)/nntrainer/models \
105                       $(NNTRAINER_ROOT)/nntrainer/tensor \
106                       $(NNTRAINER_ROOT)/nntrainer/optimizers \
107                       $(NNTRAINER_ROOT)/nntrainer/utils \
108                       $(NNTRAINER_ROOT)/nntrainer/graph \
109                       $(NNTRAINER_ROOT)/api \
110                       $(NNTRAINER_ROOT)/api/ccapi/include \
111                       $(NNTRAINER_ROOT)/api/capi/include/platform
112
113 INIPARSER_SRCS := $(INIPARSER_ROOT)/src/iniparser.c \
114                   $(INIPARSER_ROOT)/src/dictionary.c
115
116 INIPARSER_INCLUDES := $(INIPARSER_ROOT)/src
117
118 LOCAL_ARM_NEON      := true
119 LOCAL_CFLAGS        += -pthread -fexceptions
120 LOCAL_CXXFLAGS      += -std=c++14 -frtti -fexceptions
121 LOCAL_LDFLAGS       += -fuse-ld=bfd
122 LOCAL_MODULE_TAGS   := optional
123
124 LOCAL_LDLIBS        := -llog
125
126 LOCAL_MODULE        := nntrainer
127 LOCAL_SRC_FILES     := $(NNTRAINER_SRCS) $(INIPARSER_SRCS)
128 LOCAL_C_INCLUDES    := $(NNTRAINER_INCLUDES) $(INIPARSER_INCLUDES)
129
130 # Add tflite backbone building
131 ifeq ($(ENABLE_TFLITE_BACKBONE),1)
132 LOCAL_STATIC_LIBRARIES := tensorflow-lite
133 LOCAL_C_INCLUDES += $(TFLITE_INCLUDES)
134 LOCAL_CFLAGS += -DENABLE_TFLITE_BACKBONE=1
135 endif #ENABLE_TFLITE_BACKBONE
136
137 # Enable Profile
138 ifeq ($(ENABLE_PROFILE), 1)
139 LOCAL_CFLAGS += -DPROFILE=1
140 endif #ENABLE_PROFILE
141
142 include $(BUILD_SHARED_LIBRARY)
143
144 include $(CLEAR_VARS)
145
146 CAPI_NNTRAINER_SRCS := $(NNTRAINER_ROOT)/api/capi/src/nntrainer.cpp \
147                   $(NNTRAINER_ROOT)/api/capi/src/nntrainer_util.cpp
148
149 CAPI_NNTRAINER_INCLUDES := $(NNTRAINER_ROOT)/nntrainer \
150                       $(NNTRAINER_ROOT)/nntrainer/dataset \
151                       $(NNTRAINER_ROOT)/nntrainer/layers \
152                       $(NNTRAINER_ROOT)/nntrainer/models \
153                       $(NNTRAINER_ROOT)/nntrainer/graph \
154                       $(NNTRAINER_ROOT)/nntrainer/tensor \
155                       $(NNTRAINER_ROOT)/nntrainer/optimizers \
156                       $(NNTRAINER_ROOT)/api \
157                       $(NNTRAINER_ROOT)/api/ccapi/include \
158                       $(NNTRAINER_ROOT)/api/capi/include \
159                       $(NNTRAINER_ROOT)/api/capi/include/platform
160
161 LOCAL_SHARED_LIBRARIES := nntrainer
162
163 LOCAL_ARM_NEON      := true
164 LOCAL_CFLAGS        += -pthread -fexceptions
165 LOCAL_CXXFLAGS      += -std=c++14 -frtti -fexceptions
166 LOCAL_LDFLAGS       += -fuse-ld=bfd
167 LOCAL_MODULE_TAGS   := optional
168
169 LOCAL_LDLIBS        := -llog
170
171 LOCAL_MODULE        := capi-nntrainer
172 LOCAL_SRC_FILES     := $(CAPI_NNTRAINER_SRCS)
173 LOCAL_C_INCLUDES    := $(CAPI_NNTRAINER_INCLUDES)
174
175 include $(BUILD_SHARED_LIBRARY)
176
177 include $(CLEAR_VARS)
178
179 CCAPI_NNTRAINER_SRCS := $(NNTRAINER_ROOT)/api/ccapi/src/factory.cpp
180
181 CCAPI_NNTRAINER_INCLUDES := $(NNTRAINER_ROOT)/nntrainer \
182                       $(NNTRAINER_ROOT)/nntrainer/dataset \
183                       $(NNTRAINER_ROOT)/nntrainer/layers \
184                       $(NNTRAINER_ROOT)/nntrainer/models \
185                       $(NNTRAINER_ROOT)/nntrainer/tensor \
186                       $(NNTRAINER_ROOT)/nntrainer/graph \
187                       $(NNTRAINER_ROOT)/nntrainer/optimizers \
188                       $(NNTRAINER_ROOT)/api \
189                       $(NNTRAINER_ROOT)/api/ccapi/include \
190                       $(NNTRAINER_ROOT)/api/capi/include/platform
191
192 LOCAL_SHARED_LIBRARIES := nntrainer
193
194 LOCAL_ARM_NEON      := true
195 LOCAL_CFLAGS        += -pthread -fexceptions
196 LOCAL_CXXFLAGS      += -std=c++14 -frtti -fexceptions
197 LOCAL_LDFLAGS       += -fuse-ld=bfd
198 LOCAL_MODULE_TAGS   := optional
199
200 LOCAL_LDLIBS        := -llog
201
202 LOCAL_MODULE        := ccapi-nntrainer
203 LOCAL_SRC_FILES     := $(CCAPI_NNTRAINER_SRCS)
204 LOCAL_C_INCLUDES    := $(CCAPI_NNTRAINER_INCLUDES)
205
206 include $(BUILD_SHARED_LIBRARY)