tf_lite.patch 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. diff --git a/tensorflow/lite/tools/make/Makefile b/tensorflow/lite/tools/make/Makefile
  2. index c7ddff5844..17146868f7 100644
  3. --- a/tensorflow/lite/tools/make/Makefile
  4. +++ b/tensorflow/lite/tools/make/Makefile
  5. @@ -48,11 +48,7 @@ INCLUDES += -I/usr/local/include
  6. # These are the default libraries needed, but they can be added to or
  7. # overridden by the platform-specific settings in target makefiles.
  8. -LIBS := \
  9. --lstdc++ \
  10. --lpthread \
  11. --lm \
  12. --lz \
  13. +LIBS := -lm \
  14. -ldl
  15. # There are no rules for compiling objects for the host system (since we don't
  16. @@ -84,14 +80,24 @@ endif # ifeq ($(HOST_ARCH),$(TARGET_ARCH))
  17. endif # ifeq ($(HOST_OS),$(TARGET))
  18. endif
  19. +BUILD_WITH_SIMD ?= false
  20. +ifeq ($(BUILD_WITH_SIMD), true)
  21. +CFLAGS+=-msimd128
  22. +CXXFLAGS+=-msimd128
  23. +endif
  24. +
  25. +LIBFLAGS += -s TOTAL_STACK=1048576 \
  26. + -Wl,--export=__data_end -Wl,--export=__heap_base \
  27. + -s ERROR_ON_UNDEFINED_SYMBOLS=0
  28. +
  29. # This library is the main target for this makefile. It will contain a minimal
  30. # runtime that can be linked in to other programs.
  31. LIB_NAME := libtensorflow-lite.a
  32. # Benchmark static library and binary
  33. BENCHMARK_LIB_NAME := benchmark-lib.a
  34. -BENCHMARK_BINARY_NAME := benchmark_model
  35. -BENCHMARK_PERF_OPTIONS_BINARY_NAME := benchmark_model_performance_options
  36. +BENCHMARK_BINARY_NAME := benchmark_model.wasm
  37. +BENCHMARK_PERF_OPTIONS_BINARY_NAME := benchmark_model_performance_options.wasm
  38. # A small example program that shows how to link against the library.
  39. MINIMAL_SRCS := \
  40. @@ -277,12 +283,16 @@ LIB_PATH := $(LIBDIR)$(LIB_NAME)
  41. BENCHMARK_LIB := $(LIBDIR)$(BENCHMARK_LIB_NAME)
  42. BENCHMARK_BINARY := $(BINDIR)$(BENCHMARK_BINARY_NAME)
  43. BENCHMARK_PERF_OPTIONS_BINARY := $(BINDIR)$(BENCHMARK_PERF_OPTIONS_BINARY_NAME)
  44. -MINIMAL_BINARY := $(BINDIR)minimal
  45. +MINIMAL_BINARY := $(BINDIR)minimal.wasm
  46. LABEL_IMAGE_BINARY := $(BINDIR)label_image
  47. -CXX := $(CC_PREFIX)${TARGET_TOOLCHAIN_PREFIX}g++
  48. -CC := $(CC_PREFIX)${TARGET_TOOLCHAIN_PREFIX}gcc
  49. -AR := $(CC_PREFIX)${TARGET_TOOLCHAIN_PREFIX}ar
  50. +# CXX := $(CC_PREFIX)${TARGET_TOOLCHAIN_PREFIX}g++
  51. +# CC := $(CC_PREFIX)${TARGET_TOOLCHAIN_PREFIX}gcc
  52. +# AR := $(CC_PREFIX)${TARGET_TOOLCHAIN_PREFIX}ar
  53. +
  54. +CXX := em++
  55. +CC := emcc
  56. +AR := emar
  57. MINIMAL_OBJS := $(addprefix $(OBJDIR), \
  58. $(patsubst %.cc,%.o,$(patsubst %.c,%.o,$(MINIMAL_SRCS))))
  59. diff --git a/tensorflow/lite/tools/make/targets/linux_makefile.inc b/tensorflow/lite/tools/make/targets/linux_makefile.inc
  60. index 222cef9e5f..eea89a38f0 100644
  61. --- a/tensorflow/lite/tools/make/targets/linux_makefile.inc
  62. +++ b/tensorflow/lite/tools/make/targets/linux_makefile.inc
  63. @@ -2,12 +2,10 @@
  64. ifeq ($(TARGET), linux)
  65. CXXFLAGS += \
  66. -fPIC \
  67. - -DGEMMLOWP_ALLOW_SLOW_SCALAR_FALLBACK \
  68. - -pthread
  69. + -DGEMMLOWP_ALLOW_SLOW_SCALAR_FALLBACK
  70. CFLAGS += \
  71. -fPIC \
  72. - -DGEMMLOWP_ALLOW_SLOW_SCALAR_FALLBACK \
  73. - -pthread
  74. + -DGEMMLOWP_ALLOW_SLOW_SCALAR_FALLBACK
  75. # TODO(petewarden): In the future we may want to add architecture-specific
  76. # flags like -msse4.2
  77. LIBS += -ldl