Skip to content

Commit

Permalink
Support multiple build types in Android build.gradle with the makefil…
Browse files Browse the repository at this point in the history
…e build (tensorflow#16640)

* updating CUDA srcs for Makefile build to fix unsatisfied link error

* more makefile refactoring

* Fixing Tegra build logic for Android

* reverting ndk dir

* set ccache back to default
  • Loading branch information
andrewharp authored and gunan committed Feb 1, 2018
1 parent df62a67 commit 9e7ce91
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
12 changes: 6 additions & 6 deletions tensorflow/contrib/makefile/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ $(MARCH_OPTION) \
-I$(JETPACK)/cuda/extras/CUPTI/include


LIBS += \
CUDA_LIBS := \
-ltfcuda \
-lcudart_static \
-lcudnn \
Expand All @@ -420,10 +420,10 @@ $(MARCH_OPTION) \
-lculibos \
-lcurand_static

OBJDIR := $(OBJDIR)Tegra/
LIBDIR := $(LIBDIR)Tegra/
BINDIR := $(BINDIR)Tegra/
DEPDIR := $(DEPDIR)Tegra/
OBJDIR := $(OBJDIR)android_arm64-v8a/
LIBDIR := $(LIBDIR)android_arm64-v8a/
BINDIR := $(BINDIR)android_arm64-v8a/
DEPDIR := $(DEPDIR)android_arm64-v8a/

TEGRA_LIBS := \
-L$(JETPACK)/cuda/targets/aarch64-linux-androideabi/lib \
Expand Down Expand Up @@ -729,7 +729,7 @@ $(BENCHMARK_NAME): $(BENCHMARK_OBJS) $(LIB_PATH) $(CUDA_LIB_DEPS)
@mkdir -p $(dir $@)
$(CXX) $(CXXFLAGS) $(INCLUDES) \
-o $(BENCHMARK_NAME) $(BENCHMARK_OBJS) \
$(LIBFLAGS) $(TEGRA_LIBS) $(LIB_PATH) $(LDFLAGS) $(LIBS)
$(LIBFLAGS) $(TEGRA_LIBS) $(LIB_PATH) $(LDFLAGS) $(LIBS) $(CUDA_LIBS)

# NVCC compilation rules for Tegra
ifeq ($(BUILD_FOR_TEGRA),1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ $(INFERENCE_SO_PATH): $(LIB_OBJS) $(INFERENCE_OBJS) $(CUDA_LIB_DEPS)
-o $@ $(INFERENCE_OBJS) $(LIB_OBJS) $(TEGRA_LIBS) \
$(LIBFLAGS) $(LDFLAGS) \
-shared -Wl,-soname,$(INFERENCE_SO_NAME) \
$(LIBS)
$(LIBS) $(CUDA_LIBS)

$(INFERENCE_SO_NAME): $(INFERENCE_SO_PATH)

Expand Down
9 changes: 6 additions & 3 deletions tensorflow/examples/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,12 @@ def nativeOutDir = 'libs/' + cpuType
def nativeBuildRule = 'buildNativeBazel'
def demoLibPath = '../../../bazel-bin/tensorflow/examples/android/libtensorflow_demo.so'
def inferenceLibPath = '../../../bazel-bin/tensorflow/contrib/android/libtensorflow_inference.so'

// Override for Makefile builds.
if (nativeBuildSystem == 'makefile') {
nativeBuildRule = 'buildNativeMake'
demoLibPath = '../../../tensorflow/contrib/makefile/gen/lib/libtensorflow_demo.so'
inferenceLibPath = '../../../tensorflow/contrib/makefile/gen/lib/libtensorflow_inference.so'
demoLibPath = '../../../tensorflow/contrib/makefile/gen/lib/android_' + cpuType + '/libtensorflow_demo.so'
inferenceLibPath = '../../../tensorflow/contrib/makefile/gen/lib/android_' + cpuType + '/libtensorflow_inference.so'
}

// If building with Bazel, this is the location of the bazel binary.
Expand Down Expand Up @@ -154,7 +156,8 @@ task buildNativeMake(type: Exec) {
'-s', \
'tensorflow/contrib/makefile/sub_makefiles/android/Makefile.in', \
'-t', \
'libtensorflow_inference.so libtensorflow_demo.so' \
'libtensorflow_inference.so libtensorflow_demo.so all' \
, '-a', cpuType \
//, '-T' // Uncomment to skip protobuf and speed up subsequent builds.
}

Expand Down

0 comments on commit 9e7ce91

Please sign in to comment.