Guest User

Untitled

a guest
Nov 22nd, 2017
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.71 KB | None | 0 0
  1. diff --git a/WORKSPACE b/WORKSPACE
  2. old mode 100644
  3. new mode 100755
  4. index b40913801b..f3ac32a956
  5. --- a/WORKSPACE
  6. +++ b/WORKSPACE
  7. @@ -17,25 +17,25 @@ closure_repositories()
  8. load("//tensorflow:workspace.bzl", "tf_workspace")
  9.  
  10. # Uncomment and update the paths in these entries to build the Android demo.
  11. -#android_sdk_repository(
  12. -# name = "androidsdk",
  13. -# api_level = 23,
  14. -# # Ensure that you have the build_tools_version below installed in the
  15. -# # SDK manager as it updates periodically.
  16. -# build_tools_version = "26.0.1",
  17. -# # Replace with path to Android SDK on your system
  18. -# path = "<PATH_TO_SDK>",
  19. -#)
  20. +android_sdk_repository(
  21. + name = "androidsdk",
  22. + api_level = 23,
  23. + # Ensure that you have the build_tools_version below installed in the
  24. + # SDK manager as it updates periodically.
  25. + build_tools_version = "26.0.1",
  26. + # Replace with path to Android SDK on your system
  27. + path = "/home/shaurya/AndroidSDK/",
  28. +)
  29. #
  30. -#android_ndk_repository(
  31. -# name="androidndk",
  32. -# path="<PATH_TO_NDK>",
  33. -# # This needs to be 14 or higher to compile TensorFlow.
  34. -# # Please specify API level to >= 21 to build for 64-bit
  35. -# # archtectures or the Android NDK will automatically select biggest
  36. -# # API level that it supports without notice.
  37. -# # Note that the NDK version is not the API level.
  38. -# api_level=14)
  39. +android_ndk_repository(
  40. + name="androidndk",
  41. + path="/home/shaurya/android-ndk-r14b",
  42. + # This needs to be 14 or higher to compile TensorFlow.
  43. + # Please specify API level to >= 21 to build for 64-bit
  44. + # archtectures or the Android NDK will automatically select biggest
  45. + # API level that it supports without notice.
  46. + # Note that the NDK version is not the API level.
  47. + api_level=21)
  48.  
  49. # Please add all new TensorFlow dependencies in workspace.bzl.
  50. tf_workspace()
  51. diff --git a/tensorflow/contrib/lite/Makefile b/tensorflow/contrib/lite/Makefile
  52. old mode 100644
  53. new mode 100755
  54. index 78402727ab..531ff2499d
  55. --- a/tensorflow/contrib/lite/Makefile
  56. +++ b/tensorflow/contrib/lite/Makefile
  57. @@ -4,6 +4,7 @@ ifeq ($(origin MAKEFILE_DIR), undefined)
  58. MAKEFILE_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
  59. endif
  60.  
  61. +
  62. # Try to figure out the host system
  63. HOST_OS :=
  64. ifeq ($(OS),Windows_NT)
  65. @@ -18,7 +19,9 @@ else
  66. endif
  67. endif
  68.  
  69. -ARCH := $(shell if [[ $(shell uname -m) =~ i[345678]86 ]]; then echo x86_32; else echo $(shell uname -m); fi)
  70. +# ARCH := $(shell if [[ $(shell uname -m) =~ i[345678]86 ]]; then echo x86_32; else echo $(shell uname -m); fi)
  71. +ARCH := $(shell uname -p)
  72. +HOST_ARCH := $(ARCH)
  73.  
  74. # Where compiled objects are stored.
  75. OBJDIR := $(MAKEFILE_DIR)/gen/obj/
  76. @@ -26,6 +29,8 @@ BINDIR := $(MAKEFILE_DIR)/gen/bin/
  77. LIBDIR := $(MAKEFILE_DIR)/gen/lib/
  78. GENDIR := $(MAKEFILE_DIR)/gen/obj/
  79.  
  80. +
  81. +$(warning CC_PREFIX is $(CC_PREFIX))
  82. # Settings for the host compiler.
  83. CXX := $(CC_PREFIX) gcc
  84. CXXFLAGS := --std=c++11 -O3 -DNDEBUG
  85. @@ -53,13 +58,14 @@ LIBS := \
  86. -lstdc++ \
  87. -lpthread \
  88. -lm \
  89. --lz
  90. +-lz \
  91.  
  92. # If we're on Linux, also link in the dl library.
  93. -ifeq ($(OS),LINUX)
  94. +ifeq ($(HOST_OS),LINUX)
  95. LIBS += -ldl -lpthread
  96. endif
  97.  
  98. +include $(MAKEFILE_DIR)/android_makefile.inc
  99. include $(MAKEFILE_DIR)/ios_makefile.inc
  100.  
  101. # This library is the main target for this makefile. It will contain a minimal
  102. @@ -75,6 +81,7 @@ tensorflow/contrib/lite/tools/benchmark_model.cc
  103. BENCHMARK_OBJS := $(addprefix $(OBJDIR), \
  104. $(patsubst %.cc,%.o,$(patsubst %.c,%.o,$(BENCHMARK_SRCS))))
  105.  
  106. +
  107. # What sources we want to compile, must be kept in sync with the main Bazel
  108. # build files.
  109.  
  110. @@ -98,7 +105,9 @@ $(wildcard tensorflow/contrib/lite/*/*test.cc) \
  111. $(wildcard tensorflow/contrib/lite/*/*/*test.cc) \
  112. $(wildcard tensorflow/contrib/lite/*/*/*/*test.cc) \
  113. $(wildcard tensorflow/contrib/lite/kernels/test_util.cc) \
  114. -$(BENCHMARK_SRCS)
  115. +$(BENCHMARK_SRCS) \
  116. +$(TESTAPP_SRCS)
  117. +
  118. # Filter out all the excluded files.
  119. TF_LITE_CC_SRCS := $(filter-out $(CORE_CC_EXCLUDE_SRCS), $(CORE_CC_ALL_SRCS))
  120. # File names of the intermediate files target compilation generates.
  121. diff --git a/tensorflow/contrib/lite/android_makefile.inc b/tensorflow/contrib/lite/android_makefile.inc
  122. index e69de29bb2..98e3347b8b 100755
  123. --- a/tensorflow/contrib/lite/android_makefile.inc
  124. +++ b/tensorflow/contrib/lite/android_makefile.inc
  125. @@ -0,0 +1,124 @@
  126. +ifeq ($(TARGET),ANDROID)
  127. +# Override NDK_ROOT on the command line with your own NDK location, e.g.
  128. +# make -f tensorflow/contrib/makefile/Makefile TARGET=ANDROID \
  129. +# NDK_ROOT=/path/to/your/ndk
  130. +# You need to have an Android version of the protobuf libraries compiled to link
  131. +# in. The compile_android_protobuf.sh script may help.
  132. +
  133. + ANDROID_HOST_OS_ARCH :=
  134. + ifeq ($(HOST_OS),LINUX)
  135. + ANDROID_HOST_OS_ARCH=linux
  136. + endif
  137. + ifeq ($(HOST_OS),OSX)
  138. + ANDROID_HOST_OS_ARCH=darwin
  139. + endif
  140. + ifeq ($(HOST_OS),WINDOWS)
  141. + $(error "windows is not supported.")
  142. + endif
  143. +
  144. + ifeq ($(HOST_ARCH),x86_32)
  145. + ANDROID_HOST_OS_ARCH := $(ANDROID_HOST_OS_ARCH)-x86
  146. + else
  147. + ANDROID_HOST_OS_ARCH := $(ANDROID_HOST_OS_ARCH)-$(HOST_ARCH)
  148. + endif
  149. +
  150. + ifndef ANDROID_ARCH
  151. + ANDROID_ARCH := armeabi-v7a
  152. + endif
  153. +
  154. + ifeq ($(ANDROID_ARCH),arm64-v8a)
  155. + TOOLCHAIN := aarch64-linux-android-4.9
  156. + SYSROOT_ARCH := arm64
  157. + BIN_PREFIX := aarch64-linux-android
  158. + MARCH_OPTION :=
  159. + endif
  160. + ifeq ($(ANDROID_ARCH),armeabi)
  161. + TOOLCHAIN := arm-linux-androideabi-4.9
  162. + SYSROOT_ARCH := arm
  163. + BIN_PREFIX := arm-linux-androideabi
  164. + MARCH_OPTION :=
  165. + endif
  166. + ifeq ($(ANDROID_ARCH),armeabi-v7a)
  167. + TOOLCHAIN := arm-linux-androideabi-4.9
  168. + SYSROOT_ARCH := arm
  169. + BIN_PREFIX := arm-linux-androideabi
  170. + MARCH_OPTION := -march=armv7-a -mfloat-abi=softfp -mfpu=neon
  171. + endif
  172. + ifeq ($(ANDROID_ARCH),mips)
  173. + TOOLCHAIN := mipsel-linux-android-4.9
  174. + SYSROOT_ARCH := mips
  175. + BIN_PREFIX := mipsel-linux-android
  176. + MARCH_OPTION :=
  177. + endif
  178. + ifeq ($(ANDROID_ARCH),mips64)
  179. + TOOLCHAIN := mips64el-linux-android-4.9
  180. + SYSROOT_ARCH := mips64
  181. + BIN_PREFIX := mips64el-linux-android
  182. + MARCH_OPTION :=
  183. + endif
  184. + ifeq ($(ANDROID_ARCH),x86)
  185. + TOOLCHAIN := x86-4.9
  186. + SYSROOT_ARCH := x86
  187. + BIN_PREFIX := i686-linux-android
  188. + MARCH_OPTION :=
  189. + endif
  190. + ifeq ($(ANDROID_ARCH),x86_64)
  191. + TOOLCHAIN := x86_64-4.9
  192. + SYSROOT_ARCH := x86_64
  193. + BIN_PREFIX := x86-64-linux-android
  194. + MARCH_OPTION :=
  195. + endif
  196. +
  197. + ifndef NDK_ROOT
  198. + $(error "NDK_ROOT is not defined.")
  199. + endif
  200. +
  201. + CXX := $(CC_PREFIX) $(NDK_ROOT)/toolchains/$(TOOLCHAIN)/prebuilt/$(ANDROID_HOST_OS_ARCH)/bin/$(BIN_PREFIX)-g++
  202. + CC := $(CC_PREFIX) $(NDK_ROOT)/toolchains/$(TOOLCHAIN)/prebuilt/$(ANDROID_HOST_OS_ARCH)/bin/$(BIN_PREFIX)-gcc
  203. + CXXFLAGS +=\
  204. +--sysroot=$(NDK_ROOT)/platforms/android-21/arch-$(SYSROOT_ARCH) \
  205. +-Wno-narrowing \
  206. +-fomit-frame-pointer \
  207. +$(MARCH_OPTION) \
  208. +-fPIE \
  209. +-fPIC
  210. + INCLUDES += \
  211. +-I$(NDK_ROOT)/sources/android/support/include \
  212. +-I$(NDK_ROOT)/sources/android/cpufeatures/ \
  213. +-I$(NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.9/include \
  214. +-I$(NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.9/libs/$(ANDROID_ARCH)/include \
  215. +-I$(NDK_ROOT)/platforms/android-21/arch-arm/usr/include \
  216. +-I$(NDK_ROOT)/platforms/android-21/arch-arm/usr/include/machine \
  217. +-I. \
  218. +
  219. + LIBS := \
  220. +-lgnustl_static \
  221. +-llog \
  222. +-lz \
  223. +-lm \
  224. +-ldl \
  225. +-latomic \
  226. +-lcpufeatures
  227. +
  228. + LD := $(NDK_ROOT)/toolchains/$(TOOLCHAIN)/prebuilt/$(ANDROID_HOST_OS_ARCH)/$(BIN_PREFIX)/bin/ld
  229. +
  230. + LDFLAGS := \
  231. +$(MARCH_OPTION) \
  232. +-L$(MAKEFILE_DIR)/gen/protobuf_android/$(ANDROID_ARCH)/lib \
  233. +-L$(NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.9/libs/$(ANDROID_ARCH) \
  234. +-L$(NDK_ROOT)/sources/android/cpufeatures/obj/local/$(ANDROID_ARCH) \
  235. +-fPIE \
  236. +-pie \
  237. +-v
  238. +
  239. + AR := $(NDK_ROOT)/toolchains/$(TOOLCHAIN)/prebuilt/$(ANDROID_HOST_OS_ARCH)/bin/$(BIN_PREFIX)-ar
  240. + ARFLAGS := r
  241. + LIBFLAGS += -Wl,--allow-multiple-definition -Wl,--whole-archive
  242. +
  243. +
  244. + OBJDIR := $(OBJDIR)android_$(ANDROID_ARCH)/
  245. + LIBDIR := $(LIBDIR)android_$(ANDROID_ARCH)/
  246. + BINDIR := $(BINDIR)android_$(ANDROID_ARCH)/
  247. + DEPDIR := $(DEPDIR)android_$(ANDROID_ARCH)/
  248. +
  249. +endif # ANDROID
  250. \ No newline at end of file
  251. diff --git a/tensorflow/contrib/lite/download_dependencies.sh b/tensorflow/contrib/lite/download_dependencies.sh
  252. index 41480c2007..5d77f4c049 100755
  253. --- a/tensorflow/contrib/lite/download_dependencies.sh
  254. +++ b/tensorflow/contrib/lite/download_dependencies.sh
  255. @@ -85,7 +85,7 @@ replace_by_sed 's#static uint32x2_t p2ui_CONJ_XOR = vld1_u32( conj_XOR_DATA );#s
  256. replace_by_sed 's#static uint64x2_t p2ul_CONJ_XOR = vld1q_u64( p2ul_conj_XOR_DATA );#static uint64x2_t p2ul_CONJ_XOR;// = vld1q_u64( p2ul_conj_XOR_DATA ); - Removed by script#' \
  257. "${DOWNLOADS_DIR}/eigen/Eigen/src/Core/arch/NEON/Complex.h"
  258.  
  259. -cp ${DOWNLOADS_DIR}/models/models/* tensorflow/contrib/lite/examples/ios/simple/data/
  260. -cp ${DOWNLOADS_DIR}/quantized_models/* tensorflow/contrib/lite/examples/ios/camera/data/
  261. +# cp ${DOWNLOADS_DIR}/models/* tensorflow/contrib/lite/examples/ios/simple/data/
  262. +# cp ${DOWNLOADS_DIR}/quantized_models/* tensorflow/contrib/lite/examples/ios/camera/data/
  263.  
  264. echo "download_dependencies.sh completed successfully." >&2
  265. diff --git a/tensorflow/contrib/lite/kernels/internal/optimized/cpu_check.h b/tensorflow/contrib/lite/kernels/internal/optimized/cpu_check.h
  266. old mode 100644
  267. new mode 100755
  268. index dea46cc120..e80be5ae76
  269. --- a/tensorflow/contrib/lite/kernels/internal/optimized/cpu_check.h
  270. +++ b/tensorflow/contrib/lite/kernels/internal/optimized/cpu_check.h
  271. @@ -18,7 +18,7 @@ limitations under the License.
  272. namespace tflite {
  273.  
  274. #ifdef __ANDROID__
  275. -#include "ndk/sources/android/cpufeatures/cpu-features.h"
  276. +#include "cpu-features.h"
  277.  
  278. // Runtime check for Neon support on Android.
  279. inline bool TestCPUFeatureNeon() {
Add Comment
Please, Sign In to add comment