diff --git a/CMakeLists.txt b/CMakeLists.txt
index 050da5434..619b16de8 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -18,19 +18,19 @@ include(cmake/msg_color.cmake)
include(cmake/utils.cmake)
include(cmake/statistic.cmake)
+set(CMAKE_EXPORT_COMPILE_COMMANDS YES)
+
# ----------------------------------------------------------------------------
# section: global anakin version and lib name
# ----------------------------------------------------------------------------
cmake_minimum_required(VERSION ${MIN_CMAKE_V} FATAL_ERROR)
-# global anakin version 1.0.0
+# global anakin version 1.1.0
set(VERSION_MAJOR "1")
-set(VERSION_MINOR "0")
+set(VERSION_MINOR "1")
set(VERSION_PATCH "0")
set(VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
-
-
# anakin lib name and global directories
set(anakin_lib_so "anakin")
set(anakin_lib_static "anakin_static")
@@ -48,6 +48,7 @@ set(ANAKIN_SABER ${ANAKIN_ROOT}/saber)
set(ANAKIN_LITE_SABER ${ANAKIN_SABER}/lite)
set(ANAKIN_UNIT_TEST ${ANAKIN_ROOT}/test)
set(ANAKIN_EXAMPLES ${ANAKIN_ROOT}/examples)
+set(ANAKIN_SGX ${ANAKIN_ROOT}/sgx)
# ----------------------------------------------------------------------------
@@ -59,27 +60,39 @@ anakin_option(ANAKIN_TYPE_FP32 "define the FP32 for data precision." YES)
anakin_option(ANAKIN_TYPE_FP16 "define the FP16 for data precision." NO)
anakin_option(ANAKIN_TYPE_INT8 "define the INT8 for data precision." NO)
-#select the plantform to build
+#select the platform to build
anakin_option(USE_GPU_PLACE "Select the build mode for GPU place." YES)
anakin_option(USE_X86_PLACE "Select the build mode for X86 place." YES)
anakin_option(USE_ARM_PLACE "Select the build mode for ARM place." NO)
anakin_option(USE_BM_PLACE "Select the build mode for BM place." NO)
-# plantfrom details
+anakin_option(USE_SGX "Enbale Anakin to run in Intel SGX secure enclave." NO)
+anakin_option(USE_MLU_PLACE "Select the build mode for MLU place." NO)
+
+if(USE_SGX)
+ if(NOT USE_X86_PLACE OR USE_GPU_PLACE)
+ set(USE_SGX NO)
+ endif()
+endif()
+
+# platform details
anakin_option(NVIDIA_GPU "Use NVIDIA GPU place." YES if USE_GPU_PLACE)
anakin_option(AMD_GPU "Use AMD GPU place." NO if USE_GPU_PLACE AND NOT NVIDIA_GPU)
anakin_option(TARGET_ANDROID "build for android" YES if USE_ARM_PLACE)
anakin_option(TARGET_IOS "not supported now" YES if USE_ARM_PLACE AND NOT TARGET_ANDROID)
+# compile options for Cambricon MLU place
+anakin_option(USE_MLU "Use MLU libs." YES if USE_MLU_PLACE)
+anakin_option(USE_BANG "Use Bang." NO)
+
# compile options for NVIDIA_GPU place
anakin_option(USE_CUDA "Use Cuda libs." YES if NVIDIA_GPU)
anakin_option(USE_CUBLAS "Use Cublas libs." YES if USE_CUDA)
anakin_option(USE_CURAND "Use Curand libs." YES if USE_CUDA)
anakin_option(USE_CUFFT "Use CuFFT libs." YES if USE_CUDA)
anakin_option(USE_CUDNN "Use Cudnn libs." YES if USE_CUDA)
-anakin_option(USE_TENSORRT "Use tensorrt for inference." NO)
-anakin_option(BUILD_CROSS_PLANTFORM "Build anakin lib for any nvidia device plantform." YES if USE_CUDA)
-anakin_option(BUILD_FAT_BIN "Build anakin cuda fat-bin lib for all device plantform" NO if BUILD_CROSS_PLANTFORM)
+anakin_option(BUILD_CROSS_PLANTFORM "Build anakin lib for any nvidia device platform." YES if USE_CUDA)
+anakin_option(BUILD_FAT_BIN "Build anakin cuda fat-bin lib for all device platform" YES if BUILD_CROSS_PLANTFORM)
if (NOT DEFINED AK_OUTPUT_PATH)
set(AK_OUTPUT_PATH "output")
@@ -91,7 +104,9 @@ if((NOT BUILD_FAT_BIN) AND (NOT BUILD_CROSS_PLANTFORM) AND USE_CUDA)
endif()
if(USE_X86_PLACE)
- if(NOT DEFINED BUILD_X86_TARGET)
+ if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
+ set(BUILD_X86_ARCH "clang_native")
+ elseif(NOT DEFINED BUILD_X86_TARGET)
set(BUILD_X86_ARCH "native")
anakin_get_cpu_arch(BUILD_X86_ARCH)
else()
@@ -105,27 +120,31 @@ anakin_option(BUILD_CUBIN "BUILD with the -cubin option in Device mode" NO if US
anakin_option(COMPILE_PTX "Returns a list of PTX files generated from src." NO if USE_CUDA)
# common build options
-anakin_option(ENABLE_DEBUG "Enable DEBUG(default) mode." YES)
+anakin_option(ENABLE_DEBUG "Enable DEBUG(default) mode." NO)
+anakin_option(RECORD_TENSOR_IN_NET "Enable Tensor Recored in DEBUG mode." NO)
anakin_option(ENABLE_VERBOSE_MSG "Enable verbose=1 : compile msg during make." NO)
anakin_option(DISABLE_ALL_WARNINGS "Disable all the warning msg during compile." YES)
anakin_option(ENABLE_NOISY_WARNINGS "Enable noisy warning msg during compile." NO if DISABLE_ALL_WARNINGS)
anakin_option(ENABLE_MIN_DEPENDENCY "Enable minimum dependency of third party library" NO)
-# using 3rd party libs
+# SGX options
+anakin_option(SGX_SIM_MODE "Build Anakin to run in software-emulated SGX mode." YES if ENABLE_DEBUG)
+
+# using 3rd party libs
anakin_option(USE_LOGGER "Build native logger components." YES)
anakin_option(USE_GLOG "Build Glog components." NO if NOT USE_LOGGER)
-anakin_option(USE_PROTOBUF "Build Google protobuf components." YES)
+anakin_option(USE_NANOPB "Use nanopb, a light-weight C implementation of protobuf" YES if USE_SGX)
+anakin_option(USE_PROTOBUF "Build Google protobuf components." YES if NOT USE_NANOPB)
anakin_option(USE_OPENCV "Use static opencv libs." NO)
anakin_option(USE_BOOST "Use static BOOST libs." NO)
-anakin_option(USE_OPENMP "Use Openmp when in android environment." YES if TARGET_ANDROID)
+anakin_option(USE_OPENMP "Use Openmp when in android environment." YES if TARGET_ANDROID OR (USE_X86_PLACE AND NOT USE_SGX))
anakin_option(USE_GTEST "Use googletest libs." NO if BUILD_WITH_UNIT_TEST)
anakin_option(USE_PYTHON "Generate py wrappers." NO)
anakin_option(USE_OPENCL "Use OpenCL ." YES if AMD_GPU)
anakin_option(USE_GFLAGS "Build Google gflags components." NO)
-anakin_option(USE_MKL "Use mkl libs." NO if USE_X86_PLACE)
-anakin_option(USE_MKLML "Use MKLML libs." YES if USE_X86_PLACE)
+anakin_option(USE_MKL "Use mkl libs." YES if USE_SGX)
+anakin_option(USE_MKLML "Use MKLML libs." YES if USE_X86_PLACE AND NOT USE_SGX)
anakin_option(USE_XBYAK "Use XBYAK libs." YES if USE_X86_PLACE)
-anakin_option(USE_OPENMP "Use Openmp when in android environment." YES if TARGET_ANDROID)
# build components
anakin_option(BUILD_WITH_UNIT_TEST "Build anakin unit test components." YES)
@@ -139,12 +158,12 @@ anakin_option(BUILD_LITE "Build anakin lite components." NO if BUILD_WITH_FRAMEW
anakin_option(BUILD_EXAMPLES "build detection and classification examples" NO)
# build target
-anakin_option(BUILD_SHARED "Build anakin shared lib." YES)
+anakin_option(BUILD_SHARED "Build anakin shared lib." YES if NOT (USE_SGX OR BUILD_WITH_STATIC))
anakin_option(BUILD_STATIC "Build anakin static lib." YES if NOT BUILD_SHARED)
-anakin_option(ENABLE_OP_TIMER "Enable op timer mode." NO)
-if(ENABLE_MIN_DEPENDENCY)
+anakin_option(ENABLE_OP_TIMER "Enable op timer mode." NO)
+if(CMAKE_CXX_COMPILER_ID MATCHES "GNU" AND ENABLE_MIN_DEPENDENCY)
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--version-script,${ANAKIN_ROOT}/cmake/ak_link.lds")
endif()
@@ -157,7 +176,7 @@ else()
set(CMAKE_BUILD_TYPE Release FORCE)
endif()
-if(USE_LOGGER)
+if(USE_LOGGER)
anakin_option(ENABLE_STACKTRACES "If enable local logger with stacktrace." YES if NOT USE_ARM_PLACE)
anakin_option(SUPPORT_PTHREADS "If enable local logger with supporting pthreads. " YES)
endif()
@@ -189,6 +208,11 @@ if(USE_CUDA)
include(cmake/external/sass.cmake)
endif()
+if(USE_MLU)
+ include(cmake/mlu.cmake)
+ include(cmake/external/cnrtml.cmake)
+endif()
+
if(USE_X86_PLACE)
if(USE_MKLML)
include(cmake/external/mklml.cmake)
@@ -196,7 +220,9 @@ if(USE_X86_PLACE)
if(USE_XBYAK)
include(cmake/external/xbyak.cmake)
endif()
- #include(cmake/external/mkldnn.cmake)
+ if(NOT USE_SGX)
+ include(cmake/external/mkldnn.cmake)
+ endif()
endif()
if(AMD_GPU)
@@ -208,19 +234,18 @@ include(cmake/gather.cmake)
# ----------------------------------------------------------------------------
-# section: build and install anakin
+# section: build and install anakin
# ----------------------------------------------------------------------------
# add source sub_directory whick holds the cmake build module
# fetch files of model_parser
add_subdirectory(${ANAKIN_SABER})
if(BUILD_WITH_FRAMEWORK)
- add_subdirectory(${ANAKIN_MODEL_PARSER})
add_subdirectory(${ANAKIN_FRAMEWORK})
- if(BUILD_RPC)
- add_subdirectory(${ANAKIN_SERVICE})
+ if(BUILD_RPC)
+ add_subdirectory(${ANAKIN_SERVICE})
endif()
- if(BUILD_LITE)
+ if(BUILD_LITE)
add_subdirectory(${ANAKIN_LITE_FRAMEWORK})
endif()
endif()
@@ -235,6 +260,9 @@ if (BUILD_EXAMPLES)
endif()
endif()
+if (USE_SGX)
+ add_subdirectory(${ANAKIN_SGX})
+endif()
anakin_print_statistic()
diff --git a/benchmark/README_GPU.md b/benchmark/README_GPU.md
index 96016c7cb..04326535a 100644
--- a/benchmark/README_GPU.md
+++ b/benchmark/README_GPU.md
@@ -9,11 +9,11 @@
## Counterpart of anakin :
-The counterpart of **`Anakin`** is the acknowledged high performance inference engine **`NVIDIA TensorRT 5`** , The models which TensorRT 5 doesn't support we use the custom plugins to support.
+The counterpart of **`Anakin`** is the acknowledged high performance inference engine **`NVIDIA TensorRT 3`** , The models which TensorRT 3 doesn't support we use the custom plugins to support.
## Benchmark Model
-The following convolutional neural networks are tested with both `Anakin` and `TenorRT5`.
+The following convolutional neural networks are tested with both `Anakin` and `TenorRT3`.
You can use pretrained caffe model or the model trained by youself.
> Please note that you should transform caffe model or others into anakin model with the help of [`external converter ->`](../docs/Manual/Converter_en.md)
@@ -35,19 +35,21 @@ We tested them on single-GPU with single-thread.
BatchSize | TensorRT | Anakin
:---: | :---: | :---: |
- 1 | 8.53945 | 8.18737
- 2 | 14.2269 | 13.8976
- 4 | 24.2803 | 21.7976
- 8 | 45.6003 | 40.319
+ 1 | 8.85176 | 8.15362
+ 2 | 15.6517 | 13.8716
+ 4 | 26.5303 | 21.8478
+ 8 | 48.2286 | 40.496
+ 32 | 183.994 | 163.035
- GPU Memory Used (`MB`)
BatchSize | TensorRT | Anakin
:---: | :---: | :---: |
- 1 | 1053.88 | 762.73
- 2 | 1055.71 | 762.41
- 4 | 1003.22 | 832.75
- 8 | 1108.77 | 926.9
+ 1 | 887 | 648
+ 2 | 965 | 733
+ 4 | 991 | 810
+ 8 | 1067 | 911
+ 32 | 1715 | 1325
### Yolo
@@ -56,40 +58,44 @@ We tested them on single-GPU with single-thread.
BatchSize | TensorRT | Anakin
:---: | :---: | :---: |
- 1 | 8.41606| 7.07977
- 2 | 16.6588| 15.2216
- 4 | 31.9955| 30.5102
- 8 | 66.1107 | 64.3658
+ 1 | 16.4623| 15.3214
+ 2 | 26.7082| 25.0305
+ 4 | 43.2129| 43.4758
+ 8 | 80.0053 | 80.7645
+ 32 | 283.352| 311.152
- GPU Memory Used (`MB`)
BatchSize | TensorRT | Anakin
- :---: | :---: | :---: |
- 1 | 1054.71 | 299.8
- 2 | 951.51 | 347.47
- 4 | 846.9 | 438.47
- 8 | 1042.31 | 515.15
+ :---: | :---: | :---: |
+ 1 | 1226 | 1192
+ 2 | 1326 | 1269
+ 4 | 1435 | 1356
+ 8 | 1563 | 1434
+ 32 | 2150 | 1633
### Resnet50
- Latency (`ms`) of different batch
BatchSize | TensorRT | Anakin
- :---: | :---: | :---: |
- 1 | 4.10063 | 3.33845
- 2 | 6.10941 | 5.54814
- 4 | 9.90233 | 10.2763
- 8 | 17.3287 | 20.0783
+ :---: | :---: | :---: |
+ 1 | 4.26834 | 3.25853
+ 2 | 6.2811 | 6.12156
+ 4 | 10.1183 | 10.9219
+ 8 | 18.1395 | 20.323
+ 32 | 66.4728 | 83.9934
- GPU Memory Used (`MB`)
BatchSize | TensorRT | Anakin
:---: | :---: | :---: |
- 1 | 1059.15 | 299.86
- 2 | 1077.8 | 340.78
- 4 | 903.04 | 395
- 8 | 832.53 | 508.86
+ 1 | 932 | 272
+ 2 | 936 | 318
+ 4 | 720 | 376
+ 8 | 697 | 480
+ 32 | 842 | 835
### Resnet101
@@ -97,19 +103,21 @@ We tested them on single-GPU with single-thread.
BatchSize | TensorRT | Anakin
:---: | :---: | :---: |
- 1 | 7.29828 | 5.672
- 2 | 11.2037 | 9.42352
- 4 | 17.9306 | 18.0936
- 8 | 31.4804 | 35.7439
+ 1 | 7.58234 | 5.66457
+ 2 | 11.6014 | 10.9213
+ 4 | 18.3298 | 19.3987
+ 8 | 32.6523 | 37.5575
+ 32 | 123.114 | 149.089
- GPU Memory Used (`MB)`
BatchSize | TensorRT | Anakin
:---: | :---: | :---: |
- 1 | 1161.94 | 429.22
- 2 | 1190.92 | 531.92
- 4 | 994.11 | 549.7
- 8 | 945.47 | 653.06
+ 1 | 1020 | 420
+ 2 | 961 | 467
+ 4 | 943 | 503
+ 8 | 885 | 606
+ 32 | 1048 | 1077
### MobileNet V1
@@ -117,19 +125,21 @@ We tested them on single-GPU with single-thread.
BatchSize | TensorRT | Anakin
:---: | :---: | :---: |
- 1 | 1.52692 | 1.39282
- 2 | 1.98091 | 2.05788
- 4 | 3.2705 | 4.03476
- 8 | 5.15652 | 7.06651
+ 1 | 45.2189 | 1.39566
+ 2 | 46.4538 | 2.50698
+ 4 | 47.8918 | 4.38727
+ 8 | 52.3636 | 8.21416
+ 32 | 83.0503 | 31.33
- GPU Memory Used (`MB`)
BatchSize | TensorRT | Anakin
:---: | :---: | :---: |
- 1 | 1144.35 | 99.6
- 2 | 1160.03 | 199.75
- 4 | 1098 | 184.33
- 8 | 990.71 | 232.11
+ 1 | 516 | 176
+ 2 | 524 | 166
+ 4 | 497 | 165
+ 8 | 508 | 239
+ 32 | 628 | 388
### MobileNet V2
@@ -137,19 +147,21 @@ We tested them on single-GPU with single-thread.
BatchSize | TensorRT | Anakin
:---: | :---: | :---: |
- 1 | 1.95961 | 1.78249
- 2 | 2.8709 | 3.01144
- 4 | 4.46131 | 5.43946
- 8 | 7.161 | 10.2081
+ 1 | 65.4277 | 1.80542
+ 2 | 66.2048 | 3.85568
+ 4 | 68.8045 | 6.80921
+ 8 | 75.64 | 12.6038
+ 32 | 124.09 | 47.6079
- GPU Memory Used (`MB`)
BatchSize | TensorRT | Anakin
:---: | :---: | :---: |
- 1 | 1154.69 | 195.25
- 2 | 1187.25 | 227.6
- 4 | 1053 | 241.75
- 8 | 1062.48 | 352.18
+ 1 | 341 | 293
+ 2 | 353 | 301
+ 4 | 385 | 319
+ 8 | 421 | 351
+ 32 | 637 | 551
## How to run those Benchmark models?
diff --git a/benchmark/RNN/prepare.sh b/benchmark/RNN/prepare.sh
index 7762fff96..6fc9032e5 100755
--- a/benchmark/RNN/prepare.sh
+++ b/benchmark/RNN/prepare.sh
@@ -1,14 +1,14 @@
#!/bin/bash
sdir=$(cd `dirname $0`; pwd)
-if [ ! -e $sdir/data/ptb.valid.txt ]; then
-echo "can not find language_data download now"
-wget -P $sdir/data/ http://ojf1xbmzo.bkt.clouddn.com/ptb.valid.txt
-fi
+#if [ ! -e $sdir/data/ptb.valid.txt ]; then
+#echo "can not find language_data download now"
+#wget -P $sdir/data/ http://ojf1xbmzo.bkt.clouddn.com/ptb.valid.txt
+#fi
if [ ! -e $sdir/data/ner_data.txt ]; then
echo "can not find language_data download now"
-wget -P $sdir/data/ https://raw.githubusercontent.com/PaddlePaddle/models/develop/fluid/chinese_ner/data/test_files/test_part_1
+wget -P $sdir/data/ https://raw.githubusercontent.com/PaddlePaddle/models/v0.15.0-rc0/fluid/chinese_ner/data/test_files/test_part_1
for n in $(seq 30); do cat $sdir/data/test_part_1 >> $sdir/data/ner_data.txt; done
rm $sdir/data/test_part_1
fi
diff --git a/benchmark/RNN/tensorflow_c_benchmark/example_model.cc b/benchmark/RNN/tensorflow_c_benchmark/example_model.cc
index 291f89e33..deac2f127 100644
--- a/benchmark/RNN/tensorflow_c_benchmark/example_model.cc
+++ b/benchmark/RNN/tensorflow_c_benchmark/example_model.cc
@@ -56,9 +56,9 @@ void SplitString(const std::string& s,
int split_word_from_file(
std::vector >& word_idx,
- const std::string input_file_path,
- const std::string split_token,
- const std::string inner_split_token,
+ const std::string& input_file_path,
+ const std::string& split_token,
+ const std::string& inner_split_token,
const int col_select) {
std::ifstream infile(input_file_path.c_str());
diff --git a/cmake/compiler_options.cmake b/cmake/compiler_options.cmake
index 1b41b047e..f6fab8781 100644
--- a/cmake/compiler_options.cmake
+++ b/cmake/compiler_options.cmake
@@ -13,22 +13,34 @@
# limitations under the License.
# ----------------------------------------------------------------------------
-# section: set the compiler and linker options
+# section: set the compiler and linker options
# ----------------------------------------------------------------------------
set(ANAKIN_EXTRA_CXX_FLAGS "")
set(ANAKIN_NVCC_FLAG "")
-
+set(CMAKE_CXX_STANDARD 11)
+set(CMAKE_CXX_STANDARD_REQUIRED ON)
anakin_add_compile_option(-std=c++11)
anakin_add_compile_option(-fPIC)
-anakin_add_compile_option(-ldl)
-if(USE_ARM_PLACE )
-elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
-else()
- anakin_add_compile_option(-lrt)
+
+if(NOT USE_SGX)
+ anakin_add_compile_option(-ldl)
+ anakin_add_compile_option(-pthread)
+ if(USE_ARM_PLACE)
+ elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
+ else()
+ anakin_add_compile_option(-lrt)
+ endif()
endif()
+
+if(USE_X86_PLACE)
+ if (BUILD_X86_TARGET MATCHES "knl" OR ${BUILD_X86_ARCH} MATCHES "knl")
+ anakin_add_compile_option(-mavx512bw)
+ anakin_add_compile_option(-mavx512f)
+ endif ()
+endif()
+
anakin_add_compile_option(-W)
anakin_add_compile_option(-Wall)
-anakin_add_compile_option(-pthread)
anakin_add_compile_option(-Werror=return-type)
anakin_add_compile_option(-Werror=address)
anakin_add_compile_option(-Werror=sequence-point)
@@ -41,6 +53,8 @@ anakin_add_compile_option(-Wshadow)
anakin_add_compile_option(-fpermissive)
anakin_add_compile_option(-Wsign-promo)
anakin_add_compile_option(-fdiagnostics-show-option)
+anakin_add_compile_option(-Wno-missing-field-initializers)
+anakin_add_compile_option(-Wno-extra)
if(ENABLE_NOISY_WARNINGS)
anakin_add_compile_option(-Wcast-align)
@@ -54,8 +68,8 @@ else()
anakin_add_compile_option(-Wno-delete-non-virtual-dtor)
anakin_add_compile_option(-Wno-comment)
anakin_add_compile_option(-Wno-sign-compare)
- anakin_add_compile_option(-Wno-write-strings)
- anakin_add_compile_option(-Wno-ignored-qualifiers)
+ anakin_add_compile_option(-Wno-write-strings)
+ anakin_add_compile_option(-Wno-ignored-qualifiers)
anakin_add_compile_option(-Wno-enum-compare)
anakin_add_compile_option(-Wno-missing-field-initializers)
endif()
@@ -63,26 +77,41 @@ endif()
if(CMAKE_BUILD_TYPE MATCHES Debug)
anakin_add_compile_option(-O0)
anakin_add_compile_option(-g)
- anakin_add_compile_option(-gdwarf-2) # for old version gcc and gdb. see: http://stackoverflow.com/a/15051109/673852
+ anakin_add_compile_option(-gdwarf-2) # for old version gcc and gdb. see: http://stackoverflow.com/a/15051109/673852
else()
- anakin_add_compile_option(-O3)
- #anakin_add_compile_option(-g)
- anakin_add_compile_option(-DNDEBUG)
+ if(USE_SGX)
+ anakin_add_compile_option(-Os)
+ else()
+ anakin_add_compile_option(-Ofast)
+ endif()
+
+ if(USE_ARM_PLACE)
+ add_compile_options(-Ofast)
+ add_compile_options(-ffast-math)
+ add_compile_options(-Os)
+ endif()
+
+ anakin_add_compile_option(-DNDEBUG)
endif()
if(TARGET_ANDROID)
anakin_add_compile_option(-pie)
- anakin_add_compile_option(-mfloat-abi=softfp)
- anakin_add_compile_option(-mfpu=neon)
- anakin_add_compile_option(-ffast-math)
+ add_compile_options(-ldl)
anakin_add_compile_option(-lc)
- set(ANAKIN_EXTRA_CXX_FLAGS "${ANAKIN_EXTRA_CXX_FLAGS} ${ANDROID_CXX_FLAGS}")
+ set(ANAKIN_EXTRA_CXX_FLAGS "${ANAKIN_EXTRA_CXX_FLAGS} ${ANDROID_CXX_FLAGS}")
+ set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--gc-sections")
+ set(MAKE_STATIC_LINKER_FLAGS "${MAKE_STATIC_LINKER_FLAGS} -Wl,--gc-sections")
endif()
if(TARGET_IOS)
# none temp
endif()
+if(BUILD_STATIC OR X86_COMPILE_482)
+ anakin_add_compile_option(-static-libstdc++)
+endif()
+
+
if(USE_X86_PLACE)
if(X86_COMPILE_482)
set(CMAKE_SYSROOT /opt/compiler/gcc-4.8.2/)
@@ -92,14 +121,19 @@ if(X86_COMPILE_482)
set(CMAKE_EXE_LINKER_FLAGS "-Wl,-dynamic-linker,/opt/compiler/gcc-4.8.2/lib64/ld-linux-x86-64.so.2")
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
- anakin_add_compile_option(-static-libstdc++)
+ anakin_add_compile_option(-D_GLIBCXX_USE_CXX11_ABI=0) #use std namespace for string and list rather than std::__CXX11::
+# anakin_add_compile_option(-static-libstdc++)
# anakin_add_compile_option(-static-libgcc)
endif()
+if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
anakin_add_compile_option(-fabi-version=6)
- anakin_add_compile_option(-march=${BUILD_X86_ARCH})
- anakin_add_compile_option(-Ofast)
- anakin_add_compile_option(-ffast-math)
+ anakin_add_compile_option(-fabi-compat-version=2) #add compat
+ anakin_add_compile_option(-march=${BUILD_X86_ARCH})
+endif()
+if(USE_OPENMP)
+ anakin_add_compile_option(-fopenmp)
+endif()
anakin_add_compile_option(-Wall)
anakin_add_compile_option(-Wno-comment)
anakin_add_compile_option(-Wno-unused-local-typedefs)
@@ -110,9 +144,9 @@ if(X86_64)
anakin_add_compile_option(-Wno-long-long)
endif()
-set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} ${ANAKIN_EXTRA_CXX_FLAGS})
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ANAKIN_EXTRA_CXX_FLAGS}")
-#if(WIN32)
+#if(WIN32)
# if(MSVC)
# message(STATUS "Using msvc compiler")
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D_SCL_SECURE_NO_WARNINGS")
@@ -134,6 +168,4 @@ if(USE_CUDA)
anakin_add_compile_option("--default-stream per-thread" NVCC)
anakin_add_compile_option(-Wno-deprecated-gpu-targets NVCC)
endif()
- # set default nvidia gpu arch
- set(ANAKIN_ARCH_LIST "3.5;5.0;6.0;6.1")
endif()
diff --git a/cmake/config/anakin_config.h.in b/cmake/config/anakin_config.h.in
index d96e231bf..ccbfca14e 100644
--- a/cmake/config/anakin_config.h.in
+++ b/cmake/config/anakin_config.h.in
@@ -39,8 +39,6 @@
#cmakedefine USE_CUDNN
-#cmakedefine USE_TENSORRT
-
#cmakedefine USE_PYTHON
#cmakedefine USE_OPENCL
@@ -56,6 +54,7 @@
#cmakedefine USE_GFLAGS
+
// plantform to use
#cmakedefine USE_GPU_PLACE
@@ -65,6 +64,10 @@
#cmakedefine USE_ARM_PLACE
#cmakedefine USE_BM_PLACE
+#cmakedefine USE_MLU_PLACE
+#cmakedefine USE_MLU
+
+#cmakedefine USE_SGX
#cmakedefine TARGET_ANDROID
@@ -80,11 +83,13 @@
#cmakedefine SUPPORT_PTHREADS
+#cmakedefine USE_NANOPB
+
// build arm lite
#cmakedefine BUILD_LITE
+#cmakedefine LINUX_ARM_OS
-
-#if defined(ANDROID) || defined(__ANDROID__)
+#if defined(ANDROID) || defined(__ANDROID__) || defined(LINUX_ARM_OS)
#define PLATFORM_ANDROID
#define IS_MOBILE_PLATFORM
#elif defined(__APPLE__)
diff --git a/cmake/cuda.cmake b/cmake/cuda.cmake
index 60b10e298..0e96e7e68 100644
--- a/cmake/cuda.cmake
+++ b/cmake/cuda.cmake
@@ -77,19 +77,32 @@ endmacro()
# section: Find cudnn.
# ----------------------------------------------------------------------------
macro(anakin_find_cudnn)
+
set(CUDNN_ROOT "" CACHE PATH "CUDNN root dir.")
find_path(CUDNN_INCLUDE_DIR cudnn.h PATHS ${CUDNN_ROOT}
$ENV{CUDNN_ROOT}
$ENV{CUDNN_ROOT}/include
${ANAKIN_ROOT}/third-party/cudnn/include NO_DEFAULT_PATH)
if(BUILD_SHARED)
- find_library(CUDNN_LIBRARY NAMES libcudnn.so
+ if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
+ find_library(CUDNN_LIBRARY NAMES libcudnn.dylib
+ PATHS ${CUDNN_INCLUDE_DIR}/../lib/ ${CUDNN_INCLUDE_DIR}/
+ DOC "library path for cudnn.")
+ else()
+ find_library(CUDNN_LIBRARY NAMES libcudnn.so
PATHS ${CUDNN_INCLUDE_DIR}/../lib64/ ${CUDNN_INCLUDE_DIR}/
- DOC "library path for cudnn.")
- else()
- find_library(CUDNN_LIBRARY NAMES libcudnn_static.a
- PATHS ${CUDNN_INCLUDE_DIR}/../lib64/
DOC "library path for cudnn.")
+ endif()
+ else()
+ if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
+ find_library(CUDNN_LIBRARY NAMES libcudnn_static.a
+ PATHS ${CUDNN_INCLUDE_DIR}/../lib/
+ DOC "library path for cudnn.")
+ else()
+ find_library(CUDNN_LIBRARY NAMES libcudnn_static.a
+ PATHS ${CUDNN_INCLUDE_DIR}/../lib64/
+ DOC "library path for cudnn.")
+ endif()
endif()
if(CUDNN_INCLUDE_DIR AND CUDNN_LIBRARY)
@@ -177,6 +190,17 @@ macro(anakin_find_cuda)
# build cuda part for local machine.
if(BUILD_CROSS_PLANTFORM)
+ #set nvida gpu arch
+ set(ANAKIN_ARCH_LIST "3.5;5.0;6.0;6.1")
+ if("${CUDA_VERSION}" GREATER 9.0 OR "${CUDA_VERSION}" EQUAL 9.0)
+ message("${CUDA_VERSION}")
+ set(ANAKIN_ARCH_LIST "3.5;5.0;6.0;6.1;7.0")#>=9.0
+ endif()
+ if("${CUDA_VERSION}" GREATER 10.0 OR "${CUDA_VERSION}" EQUAL 10.0)
+ set(ANAKIN_ARCH_LIST "3.5;5.0;6.0;6.1;7.0;7.5")#>=10.0
+ message("${CUDA_VERSION}")
+ endif()
+
if(BUILD_FAT_BIN)
message(STATUS "Building fat-bin for cuda code !")
anakin_set_nvcc_archs_info(ANAKIN_ARCH_LIST)
diff --git a/cmake/external/cnrtml.cmake b/cmake/external/cnrtml.cmake
new file mode 100644
index 000000000..8f92f04c0
--- /dev/null
+++ b/cmake/external/cnrtml.cmake
@@ -0,0 +1,54 @@
+#===============================================================================
+# Copyright 2016-2018 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#===============================================================================
+
+anakin_find_mlulib()
+if (${MLU_FOUND})
+ return()
+endif()
+
+include(ExternalProject)
+
+set(MLU_PROJECT "extern_mlu")
+set(MLU_SOURCE_DIR "${ANAKIN_TEMP_THIRD_PARTY_PATH}/mlu")
+set(REL_MLU_LIB "${MLU_SOURCE_DIR}/src/${MLU_PROJECT}/mlu")
+set(MLU_INC "${ANAKIN_THIRD_PARTY_PATH}/mlu/include")
+set(MLU_LIB "${ANAKIN_THIRD_PARTY_PATH}/mlu/lib")
+set(MLU_INSTALL_ROOT ${ANAKIN_THIRD_PARTY_PATH}/mlu)
+
+
+file(WRITE ${MLU_SOURCE_DIR}/src/install.sh
+ "mkdir -p ${MLU_INSTALL_ROOT}/include \n"
+ "mkdir -p ${MLU_INSTALL_ROOT}/lib \n"
+ "cp ${REL_MLU_LIB}/include/*.h ${MLU_INSTALL_ROOT}/include/ \n"
+ "cp ${REL_MLU_LIB}/lib/*.so ${MLU_INSTALL_ROOT}/lib \n")
+
+
+
+ExternalProject_Add(
+ ${MLU_PROJECT}
+ GIT_REPOSITORY "xxx"
+ GIT_TAG master
+ PREFIX ${MLU_SOURCE_DIR}
+ INSTALL_COMMAND sh ${MLU_SOURCE_DIR}/src/install.sh
+)
+
+include_directories(${MLU_INC})
+add_library(mlu_lib SHARED IMPORTED GLOBAL)
+SET_PROPERTY(TARGET mlu_lib PROPERTY IMPORTED_LOCATION ${MLU_LIB}/libcnrt.so ${MLU_LIB}/libcnml.so)
+add_dependencies(mlu_lib ${MLU_PROJECT})
+message("mlu lib: ${MLU_LIB}")
+list(APPEND ANAKIN_SABER_DEPENDENCIES mlu_lib)
+list(APPEND ANAKIN_LINKER_LIBS ${MLU_LIB}/libcnrt.so ${MLU_LIB}/libcnml.so)
diff --git a/cmake/external/miopen.cmake b/cmake/external/miopen.cmake
index e76acb428..f8dc418ef 100644
--- a/cmake/external/miopen.cmake
+++ b/cmake/external/miopen.cmake
@@ -28,8 +28,8 @@ message(STATUS "Scanning external modules ${Green}MIOPEN${ColourReset} ...")
ExternalProject_Add(
${MIOPEN_PROJECT}_customize
- GIT_REPOSITORY "ssh://git@icode.baidu.com:8235/baidu/third-party/miopen"
- GIT_TAG "cbd4e7dbad0599c7327cb43888476ab8d966f285"
+ GIT_REPOSITORY "xxx"
+ GIT_TAG "xxx"
PREFIX ${ANAKIN_TEMP_THIRD_PARTY_PATH}/miopen/customize_miopen_file
SOURCE_DIR ${ANAKIN_THIRD_PARTY_PATH}/miopen/customize_miopen_file
CONFIGURE_COMMAND ""
@@ -40,8 +40,8 @@ ExternalProject_Add(
ExternalProject_Add(
${MIOPEN_PROJECT}
DEPENDS ${MIOPEN_PROJECT}_customize
- GIT_REPOSITORY "ssh://git@icode.baidu.com:8235/baidu/third-party/miopen"
- GIT_TAG 1.4.2
+ GIT_REPOSITORY "xxx"
+ GIT_TAG xxx
PREFIX ${MIOPEN_PREFIX_DIR}
CMAKE_ARGS -DMIOPEN_BACKEND=OpenCL -DCMAKE_INSTALL_PREFIX=${MIOPEN_INSTALL_ROOT} -DCMAKE_INSTALL_LIBDIR=lib -DBOOST_ROOT=${BOOST_ROOT}
#LOG_DOWNLOAD 1
diff --git a/cmake/external/mkldnn.cmake b/cmake/external/mkldnn.cmake
index 05befe0f0..4bb7ac174 100644
--- a/cmake/external/mkldnn.cmake
+++ b/cmake/external/mkldnn.cmake
@@ -20,8 +20,8 @@ set(MKLDNN_PROJECT "extern_mkldnn")
set(MKLDNN_SOURCES_DIR ${ANAKIN_TEMP_THIRD_PARTY_PATH}/mkldnn)
set(MKLDNN_INSTALL_DIR ${ANAKIN_THIRD_PARTY_PATH}/mkldnn)
set(MKLDNN_INC_DIR "${MKLDNN_INSTALL_DIR}/include" CACHE PATH "mkldnn include directory." FORCE)
-set(MKLDNN_LIB "${MKLDNN_INSTALL_DIR}/lib/libmkldnn.so" CACHE FILEPATH "mkldnn library." FORCE)
-set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_RPATH}" "${MKLDNN_INSTALL_DIR}/lib")
+set(MKLDNN_LIB "${MKLDNN_INSTALL_DIR}/lib64/libmkldnn.so" CACHE FILEPATH "mkldnn library." FORCE)
+set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_RPATH}" "${MKLDNN_INSTALL_DIR}/lib64")
include_directories(${MKLDNN_INC_DIR})
@@ -29,38 +29,33 @@ set(MKLDNN_DEPENDS ${MKLML_PROJECT})
message(STATUS "Scanning external modules ${Green}MKLDNNN${ColourReset}...")
-
-if(${CMAKE_C_COMPILER_VERSION} VERSION_LESS "5.4")
- set(MKLDNN_CFLAG)
+if(X86_COMPILE_482)
+ set(MKLDNN_SYS_ROOT "/opt/compiler/gcc-4.8.2/")
+ message(STATUS ${MKLDNN_SYS_ROOT})
else()
- set(MKLDNN_CFLAG "${CMAKE_C_FLAGS} -Wno-error=strict-overflow \
- -Wno-unused-but-set-variable -Wno-unused-variable -Wno-format-truncation")
+ set(MKLDNN_SYS_ROOT "")
endif()
-
-if(${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS "5.4")
- set(MKLDNN_CXXFLAG)
-else()
- set(MKLDNN_CXXFLAG "${CMAKE_CXX_FLAGS} -Wno-error=strict-overflow \
- -Wno-unused-but-set-variable -Wno-unused-variable -Wno-format-truncation")
-endif()
-
set(MKLDNN_C_COMPILER ${CMAKE_C_COMPILER})
set(MKLDNN_CXX_COMPILER ${CMAKE_CXX_COMPILER})
ExternalProject_Add(
${MKLDNN_PROJECT}
${EXTERNAL_PROJECT_LOG_ARGS}
DEPENDS ${MKLDNN_DEPENDS}
- GIT_REPOSITORY "https://github.com/01org/mkl-dnn.git"
- GIT_TAG "db3424ad44901513c03a1ea31ccaacdf633fbe9f"
+ GIT_REPOSITORY "https://github.com/intel/mkl-dnn.git"
+# GIT_TAG "v0.17.1" ##v0.17.1
+ GIT_TAG "863ff6e7042cec7d2e29897fe9f0872e0888b0fc" ##v0.17.1
PREFIX ${MKLDNN_SOURCES_DIR}
UPDATE_COMMAND ""
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${MKLDNN_INSTALL_DIR}
CMAKE_ARGS -DMKLROOT=${MKLML_ROOT}
- CMAKE_ARGS -DCMAKE_C_COMPILER=${MKLDNN_C_COMPILER}
- CMAKE_ARGS -DCMAKE_CXX_COMPILER=${MKLDNN_CXX_COMPILER}
- CMAKE_ARGS -DCMAKE_C_FLAGS=${MKLDNN_CFLAG}
- CMAKE_ARGS -DCMAKE_CXX_FLAGS=${MKLDNN_CXXFLAG}
- CMAKE_ARGS -DWITH_TEST=OFF -DWITH_EXAMPLE=OFF
+ CMAKE_ARGS -DCMAKE_INSTALL_LIBDIR=lib64
+# CMAKE_ARGS -DCMAKE_C_COMPILER=${MKLDNN_C_COMPILER}
+# CMAKE_ARGS -DCMAKE_CXX_COMPILER=${MKLDNN_CXX_COMPILER}
+# CMAKE_ARGS -DCMAKE_C_FLAGS=${MKLDNN_CFLAG}
+# CMAKE_ARGS -DCMAKE_CXX_FLAGS=${MKLDNN_CXXFLAG}
+# CMAKE_ARGS -DCMAKE_SYSROOT=${MKLDNN_SYS_ROOT}
+ #CMAKE_ARGS -DWITH_TEST=OFF -DWITH_EXAMPLE=OFF
+# CMAKE_ARGS -DCMAKE_CXX_FLAGS="-Wno-deprecated-declarations"
)
add_library(mkldnn SHARED IMPORTED GLOBAL)
@@ -71,4 +66,8 @@ list(APPEND ANAKIN_SABER_DEPENDENCIES mkldnn)
list(APPEND ANAKIN_LINKER_LIBS ${MKLDNN_LIB})
+install(FILES ${MKLDNN_INSTALL_DIR}/lib64/libmkldnn.so.0 ${MKLDNN_INSTALL_DIR}/lib64/libmkldnn.so.0.18.0.0 ${MKLDNN_LIB} DESTINATION ${PROJECT_SOURCE_DIR}/${AK_OUTPUT_PATH}/)
+install(DIRECTORY ${MKLDNN_INC_DIR}
+ DESTINATION ${PROJECT_SOURCE_DIR}/${AK_OUTPUT_PATH}/mkldnn_include)
+message(STATUS ${MKLML_INSTALL_ROOT}/include)
diff --git a/cmake/external/mklml.cmake b/cmake/external/mklml.cmake
index 8e4b3df32..50f1fc2d8 100644
--- a/cmake/external/mklml.cmake
+++ b/cmake/external/mklml.cmake
@@ -22,10 +22,10 @@ endif()
# download mklml package is only for iomp so far
include(ExternalProject)
-set(MKLML_PROJECT "extern_mklml")
-set(MKLML_VER "mklml_lnx_2019.0.20180710")
-#set(MKLML_URL "https://github.com/01org/mkl-dnn/releases/download/v0.13/${MKLML_VER}.tgz") // original site
-set(MKLML_URL "http://paddlepaddledeps.cdn.bcebos.com/${MKLML_VER}.tgz") # use paddle mirror site instead
+set(MKLML_PROJECT "extern_mklml")#
+set(MKLML_VER "mklml_lnx_2019.0.3.20190220")# for vnni mklml_lnx_2019.0.3.20190125
+set(MKLML_URL "https://github.com/intel/mkl-dnn/releases/download/v0.18/${MKLML_VER}.tgz") # original site
+#set(MKLML_URL "http://paddlepaddledeps.cdn.bcebos.com/${MKLML_VER}.tgz") # use paddle mirror site instead
set(MKLML_SOURCE_DIR "${ANAKIN_TEMP_THIRD_PARTY_PATH}/mklml")
set(MKLML_DOWNLOAD_DIR "${MKLML_SOURCE_DIR}/src/${MKLML_PROJECT}")
set(MKLML_DST_DIR ".")
@@ -56,6 +56,7 @@ ExternalProject_Add(
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${MKLML_INSTALL_ROOT}
)
+
add_library(mklml SHARED IMPORTED GLOBAL)
SET_PROPERTY(TARGET mklml PROPERTY IMPORTED_LOCATION ${MKLML_IOMP_LIB})
add_dependencies(mklml ${MKLML_PROJECT})
diff --git a/cmake/external/sass.cmake b/cmake/external/sass.cmake
index d10200cbb..c970a6a26 100644
--- a/cmake/external/sass.cmake
+++ b/cmake/external/sass.cmake
@@ -16,8 +16,8 @@
if (EXISTS ${ANAKIN_THIRD_PARTY_PATH}/sass/lib/)
include_directories(${ANAKIN_THIRD_PARTY_PATH}/sass/include)
- return()
-endif()
+ return()
+endif()
include(ExternalProject)
@@ -30,26 +30,16 @@ set(SASS_INSTALL_ROOT ${ANAKIN_THIRD_PARTY_PATH}/sass)
include_directories(${SASS_INC})
-file(WRITE ${SASS_SOURCE_DIR}/src/build.sh
- "cmake ../${SASS_PROJECT} -DSELECT_ARCH=61,50;make -j$(nproc) \n")
+file(WRITE ${SASS_SOURCE_DIR}/src/build.sh
+ "cmake ../${SASS_PROJECT} -DSELECT_ARCH=61,50;make -j$(nproc) \n")
file(WRITE ${SASS_SOURCE_DIR}/src/install.sh
- "mkdir -p ${SASS_INSTALL_ROOT}/include \n"
- "mkdir -p ${SASS_INSTALL_ROOT}/lib \n"
- "cp ${REAL_SASS_SRC}/nv/*.h ${SASS_INSTALL_ROOT}/include/ \n"
- "cp *.a ${SASS_INSTALL_ROOT}/lib \n")
+ "mkdir -p ${SASS_INSTALL_ROOT}/include \n"
+ "mkdir -p ${SASS_INSTALL_ROOT}/lib \n"
+ "cp ${REAL_SASS_SRC}/nv/*.h ${SASS_INSTALL_ROOT}/include/ \n"
+ "cp *.a ${SASS_INSTALL_ROOT}/lib \n")
-
-ExternalProject_Add(
- ${SASS_PROJECT}
- GIT_REPOSITORY "ssh://git@icode.baidu.com:8235/baidu/sys-hic-gpu/anakin_saber_lib"
- GIT_TAG batch_gemm
- PREFIX ${SASS_SOURCE_DIR}
- BUILD_COMMAND sh ${SASS_SOURCE_DIR}/src/build.sh
- INSTALL_COMMAND sh ${SASS_SOURCE_DIR}/src/install.sh
-)
-
add_library(sass_lib SHARED IMPORTED GLOBAL)
SET_PROPERTY(TARGET sass_lib PROPERTY IMPORTED_LOCATION ${SASS_LIB})
add_dependencies(sass_lib ${SASS_PROJECT})
diff --git a/cmake/external/xbyak.cmake b/cmake/external/xbyak.cmake
index 04d1cd953..408aedb29 100644
--- a/cmake/external/xbyak.cmake
+++ b/cmake/external/xbyak.cmake
@@ -18,8 +18,8 @@ include(ExternalProject)
set(XBYAK_PROJECT extern_xbyak)
set(XBYAK_PREFIX_DIR ${ANAKIN_TEMP_THIRD_PARTY_PATH}/xbyak)
-set(XBYAK_CLONE_DIR ${XBYAK_PREFIX_DIR}/src/${XBYAK_PROJECT})
-set(XBYAK_INSTALL_ROOT ${ANAKIN_THIRD_PARTY_PATH}/xbyak)
+set(XBYAK_CLONE_DIR ${XBYAK_PREFIX_DIR}/src/${XBYAK_PROJECT})
+set(XBYAK_INSTALL_ROOT ${ANAKIN_TEMP_THIRD_PARTY_PATH}/xbyak)
set(XBYAK_INC_DIR ${XBYAK_INSTALL_ROOT}/include)
message(STATUS "Scanning external modules ${Green}xbyak${ColourReset} ...")
@@ -27,23 +27,28 @@ message(STATUS "Scanning external modules ${Green}xbyak${ColourReset} ...")
include_directories(${XBYAK_INC_DIR})
-file(WRITE ${XBYAK_CLONE_DIR}/CMakeLists.txt
- "PROJECT(MKLML)\n"
- "cmake_minimum_required(VERSION 2.8)\n"
- "install(DIRECTORY ${XBYAK_CLONE_DIR}/include \n"
- " DESTINATION ${XBYAK_INSTALL_ROOT})\n")
+if(USE_SGX)
+ set(SGX_PATCH_CMD "cd ${ANAKIN_TEMP_THIRD_PARTY_PATH} && patch -p0 <${ANAKIN_THIRD_PARTY_PATH}/xbyak.patch")
+else()
+ # use a whitespace as nop so that sh won't complain about missing argument
+ set(SGX_PATCH_CMD " ")
+endif()
ExternalProject_Add(
${XBYAK_PROJECT}
${EXTERNAL_PROJECT_LOG_ARGS}
DEPENDS ""
GIT_REPOSITORY "https://github.com/herumi/xbyak.git"
- GIT_TAG "fe083912c8ac7b7e2b0081cbd6213997bc8b56e6" # mar 6, 2018
+ GIT_TAG "v5.661" # Jul 26th
PREFIX ${XBYAK_PREFIX_DIR}/src
UPDATE_COMMAND ""
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${XBYAK_INSTALL_ROOT}
+ INSTALL_COMMAND make install
+ COMMAND sh -c "${SGX_PATCH_CMD}"
+ VERBATIM
)
add_library(xbyak SHARED IMPORTED GLOBAL)
add_dependencies(xbyak ${XBYAK_PROJECT})
+
list(APPEND ANAKIN_SABER_DEPENDENCIES xbyak)
diff --git a/cmake/find_modules.cmake b/cmake/find_modules.cmake
index 2f0790b5b..5200f1e88 100644
--- a/cmake/find_modules.cmake
+++ b/cmake/find_modules.cmake
@@ -38,25 +38,25 @@ if(UNIX)
endif()
# whole archive for static lib
-if(NOT MSVC AND NOT APPLE)
- set(WHOLE_ARCHIVE_START -Wl,--whole-archive)
- set(WHOLE_ARCHIVE_END -Wl,--no-whole-archive)
-elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
- # using regular Clang or AppleClang
- set(WHOLE_ARCHIVE_START -Wl,-force_load)
- set(WHOLE_ARCHIVE_END)
+if(NOT MSVC AND NOT APPLE)
+ set(WHOLE_ARCHIVE_START -Wl,--whole-archive)
+ set(WHOLE_ARCHIVE_END -Wl,--no-whole-archive)
+elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
+ # using regular Clang or AppleClang
+ set(WHOLE_ARCHIVE_START -Wl,-force_load)
+ set(WHOLE_ARCHIVE_END)
endif()
#find opencv version >= 2.4.3
macro(anakin_find_opencv)
-
if(USE_ARM_PLACE AND TARGET_ANDROID)
- include_directories(${CMAKE_SOURCE_DIR}/third-party/arm-android/opencv/sdk/native/jni/include/)
- LINK_DIRECTORIES(${CMAKE_SOURCE_DIR}/third-party/arm-android/opencv/sdk/native/libs/armeabi-v7a/)
-
+ #include_directories(${CMAKE_SOURCE_DIR}/third-party/arm-android/opencv/sdk/native/jni/include/)
+ #LINK_DIRECTORIES(${CMAKE_SOURCE_DIR}/third-party/arm-android/opencv/sdk/native/libs/armeabi-v7a/)
+ include_directories(${CMAKE_SOURCE_DIR}/third-party/arm-android/opencv/include/)
+ LINK_DIRECTORIES(${CMAKE_SOURCE_DIR}/third-party/arm-android/opencv/lib/armeabi-v7a/)
+ message(ERROR "opencv=${CMAKE_SOURCE_DIR}/third-party/arm-android/opencv/lib/armeabi-v7a/")
else()
-
- if(BUILD_SHARED) # temporary not support static link opencv.
+ if(BUILD_SHARED AND NOT ENABLE_MIN_DEPENDENCY) # temporary not support static link opencv.
find_package(OpenCV QUIET COMPONENTS core highgui imgproc imgcodecs)
if(NOT OpenCV_FOUND)
find_package(OpenCV QUIET COMPONENTS core highgui imgproc)
@@ -70,21 +70,30 @@ macro(anakin_find_opencv)
message(SEND_ERROR "Could not found opencv !")
endif()
else() # BUILD_STATIC
- set(OPENCV_LIB_PATH "" CACHE "Path to oopen cv library")
- list(APPEND OPENCV_STATIC_LIBS ${OPENCV_LIB_PATH}/libopencv_core.a
- ${OPENCV_LIB_PATH}libopencv_highgui.a
- ${OPENCV_LIB_PATH}libopencv_imgproc.a
- ${OPENCV_LIB_PATH}libopencv_contrib.a)
- foreach(CV_LIB ${OPENCV_STATIC_LIBS})
- list(APPEND ANAKIN_LINKER_LIBS ${CV_LIB})
- endforeach()
- unset(__CV_LIB_FULL_PATH)
+ find_package(OpenCV QUIET COMPONENTS core highgui imgproc imgcodecs)
+ if(NOT OpenCV_FOUND)
+ find_package(OpenCV QUIET COMPONENTS core highgui imgproc)
+ endif()
+ if(OpenCV_FOUND)
+ message(STATUS "Found opencv: ${OpenCV_INCLUDE_DIRS}")
+ include_directories(SYSTEM ${OpenCV_INCLUDE_DIRS})
+ list(APPEND OPENCV_STATIC_LIBS ${OPENCV_LIB_PATH}/libopencv_core.a
+ ${OPENCV_LIB_PATH}libopencv_highgui.a
+ ${OPENCV_LIB_PATH}libopencv_imgproc.a
+ ${OPENCV_LIB_PATH}libopencv_contrib.a)
+ foreach(CV_LIB ${OPENCV_STATIC_LIBS})
+ list(APPEND ANAKIN_LINKER_LIBS ${CV_LIB})
+ endforeach()
+ unset(__CV_LIB_FULL_PATH)
+ else()
+ message(SEND_ERROR "Could not found opencv !")
+ endif()
endif()
endif()
endmacro()
-#find opencl
+#find opencl
macro(anakin_find_opencl)
set(OCL_ROOT "" CACHE PATH "openCL root dir.")
@@ -114,14 +123,14 @@ macro(anakin_find_boost)
find_package(Boost 1.59.0 QUIET COMPONENTS thread variant)
if(Boost_FOUND)
include_directories(SYSTEM ${Boost_INCLUDE_DIRS})
- list(APPEND ANAKIN_LINKER_LIBS ${Boost_LIBRARIES})
- endif()
+ list(APPEND ANAKIN_LINKER_LIBS ${Boost_LIBRARIES})
+ endif()
endmacro()
#find intel mkl lib.
macro(anakin_find_mkl)
set(INTEL_ROOT "/opt/intel" CACHE PATH "Folder contains intel libs.")
- set(MKL_ROOT "" CACHE PATH "Folder contains intel(R) mkl libs.")
+ set(MKL_ROOT "" CACHE PATH "Folder contains intel(R) mkl libs.")
# options for mkl
set(MKL_USE_SINGLE_DYNAMIC_LIBRARY YES)
set(MKL_USE_STATIC_LIBS NO)
@@ -144,7 +153,7 @@ macro(anakin_find_mkl)
set(__mkl_libs "")
if(MKL_USE_SINGLE_DYNAMIC_LIBRARY)
list(APPEND __mkl_libs rt)
- else()
+ else()
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
if(WIN32)
list(APPEND __mkl_libs intel_c)
@@ -153,7 +162,7 @@ macro(anakin_find_mkl)
endif()
else()
list(APPEND __mkl_libs intel_lp64 gf_lp64)
- endif()
+ endif()
if(MKL_MULTI_THREADED)
list(APPEND __mkl_libs intel_thread)
@@ -180,7 +189,7 @@ macro(anakin_find_mkl)
set(__trigger_mkllib TRUE)
endif()
endforeach()
-
+
if(NOT MKL_USE_SINGLE_DYNAMIC_LIBRARY)
if (MKL_USE_STATIC_LIBS)
set(__iomp5_libs iomp5 libiomp5mt.lib)
@@ -206,7 +215,7 @@ macro(anakin_find_mkl)
else()
message(FATAL_ERROR "Could not found mkl !")
endif()
-
+
endmacro()
# find glog and config it
@@ -247,12 +256,12 @@ endmacro()
macro(anakin_find_gflags)
set(GFLAGS_ROOT "~/.jumbo/" CACHE PATH "google flags root dir." )
- find_path(GFLAGS_INCLUDE_DIR gflags/gflags.h
- PATHS ${GFLAGS_ROOT}/include
+ find_path(GFLAGS_INCLUDE_DIR gflags/gflags.h
+ PATHS ${GFLAGS_ROOT}/include
$ENV{GFLAGS_ROOT}/include)
find_library(GFLAGS_LIBRARY NAMES libgflags.so
PATHS ${GFLAGS_ROOT}/lib
- $ENV{GFLAGS_ROOT}/lib
+ $ENV{GFLAGS_ROOT}/lib
DOC "library path for gflags.")
if(GFLAGS_INCLUDE_DIR AND GFLAGS_LIBRARY)
set(GFLAGS_FOUND TRUE)
@@ -301,13 +310,27 @@ endmacro()
macro(anakin_find_protobuf)
if(USE_ARM_PLACE)
+ set(PROTOBUF_PROTOC_EXECUTABLE "/usr/local/bin/protoc")
set(ARM_RPOTO_ROOT "${CMAKE_SOURCE_DIR}/third-party/arm-android/protobuf")
- include_directories(${ARM_RPOTO_ROOT}/include)
- set(PROTOBUF_LIBRARIES "")
+ message(STATUS "ANDROID_ABI=${ANDROID_ABI}")
+ if(${ANDROID_ABI} STREQUAL "arm64-v8a")
+ #set(PROTOBUF_PROTOC_EXECUTABLE "${ARM_RPOTO_ROOT}/arm64-v8a/bin/protoc")
+ include_directories(${ARM_RPOTO_ROOT}/arm64-v8a/include)
+ set(PROTOBUF_LIBRARIES "")
+ list(APPEND ANAKIN_LINKER_LIBS ${ARM_RPOTO_ROOT}/arm64-v8a/lib/libprotobuf.a)
+ else()
+ #set(PROTOBUF_PROTOC_EXECUTABLE "${ARM_RPOTO_ROOT}/armeabi-v7a/bin/protoc")
+ include_directories(${ARM_RPOTO_ROOT}/armeabi-v7a/include)
+ set(PROTOBUF_LIBRARIES "")
+ list(APPEND ANAKIN_LINKER_LIBS ${ARM_RPOTO_ROOT}/armeabi-v7a/lib/libprotobuf.a)
+ endif()
+ #include_directories(${ARM_RPOTO_ROOT}/include)
+ #set(PROTOBUF_LIBRARIES "")
+ #list(APPEND ANAKIN_LINKER_LIBS ${ARM_RPOTO_ROOT}/lib/libprotobuf.a)
#if(BUILD_SHARED)
# list(APPEND ANAKIN_LINKER_LIBS ${ARM_RPOTO_ROOT}/lib/libprotobuf.so)
#else()
- list(APPEND ANAKIN_LINKER_LIBS ${ARM_RPOTO_ROOT}/lib/libprotobuf.a)
+ # list(APPEND ANAKIN_LINKER_LIBS ${ARM_RPOTO_ROOT}/lib/libprotobuf.a)
#endif()
find_library( # Sets the name of the path variable.
log-lib
@@ -316,8 +339,9 @@ macro(anakin_find_protobuf)
# you want CMake to locate.
log )
list(APPEND ANAKIN_LINKER_LIBS ${log-lib})
+ find_program(PROTOBUF_PROTOC_EXECUTABLE protoc)
else()
- if(NOT ENABLE_MIN_DEPENDENCY)
+ if(NOT ENABLE_MIN_DEPENDENCY)
find_program(PROTOBUF_PROTOC_EXECUTABLE protoc)
if(PROTOBUF_PROTOC_EXECUTABLE)
find_package(Protobuf REQUIRED)
@@ -343,16 +367,16 @@ macro(anakin_find_protobuf)
endif()
endif()
else()
- set(PROTOBUF_ROOT "/usr/local" CACHE PATH "Folder contains protobuf")
- find_path(PROTOBUF_INCLUDE_DIR google/protobuf/stubs/common.h PATHS
+ set(PROTOBUF_ROOT "/usr/local" CACHE PATH "Folder contains protobuf")
+ find_path(PROTOBUF_INCLUDE_DIR google/protobuf/stubs/common.h PATHS
${PROTOBUF_ROOT}/include $ENV{PROTOBUF_ROOT}/include NO_DEFAULT_PATH)
- find_library(PROTOBUF_LIBRARY libprotobuf.a PATHS ${PROTOBUF_ROOT}/lib
+ find_library(PROTOBUF_LIBRARY libprotobuf.a PATHS ${PROTOBUF_ROOT}/lib
$ENV{PROTOBUF_ROOT}/lib NO_DEFAULT_PATH)
- find_program(PROTOBUF_PROTOC_EXECUTABLE protoc PATHS ${PROTOBUF_ROOT}/bin
+ find_program(PROTOBUF_PROTOC_EXECUTABLE protoc PATHS ${PROTOBUF_ROOT}/bin
$ENV{PROTOBUF_ROOT}/bin NO_DEFAULT_PATH)
- if(PROTOBUF_INCLUDE_DIR AND PROTOBUF_LIBRARY)
+ if(PROTOBUF_INCLUDE_DIR AND PROTOBUF_LIBRARY)
list(APPEND ANAKIN_LINKER_LIBS ${PROTOBUF_LIBRARY})
include_directories(${PROTOBUF_INCLUDE_DIR})
else()
@@ -362,6 +386,13 @@ macro(anakin_find_protobuf)
endif()
endmacro()
+macro(anakin_find_nanopb)
+ set(NANOPB_VERSION "0.3.9.1")
+ set(NANOPB_DOWNLOAD_URL "https://jpa.kapsi.fi/nanopb/download/nanopb-${NANOPB_VERSION}-linux-x86.tar.gz")
+ set(NANOPB_DIR ${ANAKIN_THIRD_PARTY_PATH}/nanopb)
+ set(PROTOBUF_PROTOC_EXECUTABLE ${NANOPB_DIR}/generator-bin/protoc)
+endmacro()
+
macro(anakin_find_baidu_rpc)
if(NOT ENABLE_MIN_DEPENDENCY)
set(BAIDU_RPC_ROOT "/opt/brpc" CACHE PATH "baidu rpc root dir")
@@ -422,69 +453,48 @@ macro(anakin_find_openmp)
endmacro()
macro(anakin_find_bmlib)
- find_path(BM_ROOT include/bmdnn/bmdnn_api.h ${CMAKE_SOURCE_DIR}/third-party/bm_lib/ $ENV{BM_ROOT}/)
- find_path(BM_ROOT_INCLUDE_DNN bmdnn_api.h ${BM_ROOT}/include/bmdnn)
- find_path(BM_ROOT_INCLUDE_RT bmruntime.h ${BM_ROOT}/include/bmruntime)
- find_path(BM_ROOT_INCLUDE_LIB bmlib_runtime.h ${BM_ROOT}/include/bmlib)
- if(BM_ROOT_INCLUDE_DNN AND BM_ROOT_INCLUDE_RT AND BM_ROOT_INCLUDE_LIB)
- set(BM_FOUND TRUE)
- endif()
- if(BM_FOUND)
+ find_path(BM_ROOT include/bmdnn/bmdnn_api.h ${CMAKE_SOURCE_DIR}/third-party/bm_lib/ $ENV{BM_ROOT}/)
+ find_path(BM_ROOT_INCLUDE_DNN bmdnn_api.h ${BM_ROOT}/include/bmdnn)
+ find_path(BM_ROOT_INCLUDE_RT bmruntime.h ${BM_ROOT}/include/bmruntime)
+ find_path(BM_ROOT_INCLUDE_LIB bmlib_runtime.h ${BM_ROOT}/include/bmlib)
+ if(BM_ROOT_INCLUDE_DNN AND BM_ROOT_INCLUDE_RT AND BM_ROOT_INCLUDE_LIB)
+ set(BM_FOUND TRUE)
+ endif()
+ if(BM_FOUND)
message(STATUS " Found bm_lib in ${BM_ROOT} ${BM_ROOT_INCLUDE_DNN} ${BM_ROOT_INCLUDE_RT} ${BM_ROOT_INCLUDE_LIB}")
include_directories(${BM_ROOT_INCLUDE_DNN})
- include_directories(${BM_ROOT_INCLUDE_RT})
- include_directories(${BM_ROOT_INCLUDE_LIB})
- set(BM_LIBRARIES "")
- list(APPEND BM_LIBRARIES ${BM_ROOT}/lib/app/libbmdnn_device.so)
+ include_directories(${BM_ROOT_INCLUDE_RT})
+ include_directories(${BM_ROOT_INCLUDE_LIB})
+ set(BM_LIBRARIES "")
+ list(APPEND BM_LIBRARIES ${BM_ROOT}/lib/app/libbmdnn_device.so)
list(APPEND BM_LIBRARIES ${BM_ROOT}/lib/app/libbmlib_device.so)
- list(APPEND BM_LIBRARIES ${BM_ROOT}/lib/app/libbmrt.so)
- list(APPEND ANAKIN_LINKER_LIBS ${BM_LIBRARIES})
- else()
- message(FATAL_ERROR "Could not found bm_lib")
+ list(APPEND BM_LIBRARIES ${BM_ROOT}/lib/app/libbmrt.so)
+ list(APPEND ANAKIN_LINKER_LIBS ${BM_LIBRARIES})
+ else()
+ message(FATAL_ERROR "Could not found bm_lib")
endif()
endmacro()
-
-macro(anakin_find_nvinfer)
- find_path(NVINFER_INCLUDE_DIR NvInfer.h PATHS ${ANAKIN_ROOT}/third-party/tensorrt5/include
- $ENV{NVINFER_ROOT})
- if (BUILD_SHARED)
- find_library(NVINFER_LIBRARY NAMES libnvinfer.so
- PATHS ${NVINFER_INCLUDE_DIR}/../lib64/
- PATHS ${NVINFER_INCLUDE_DIR}/../lib/
- DOC "library path for tensorrt.")
- find_library(NVINFER_PLUGIN_LIBRARY NAMES libnvinfer_plugin.so
- PATHS ${NVINFER_INCLUDE_DIR}/../lib64/
- PATHS ${NVINFER_INCLUDE_DIR}/../lib/
- DOC "library path for tensorrt.")
- find_library(NVPARSERS_LIBRARY NAMES libnvparsers.so
- PATHS ${NVINFER_INCLUDE_DIR}/../lib64/
- PATHS ${NVINFER_INCLUDE_DIR}/../lib/
- DOC "library path for tensorrt.")
- else()
- find_library(NVINFER_LIBRARY NAMES libnvinfer.a
- PATHS ${NVINFER_INCLUDE_DIR}/../lib64/
- DOC "library path for tensorrt.")
- find_library(NVINFER_PLUGIN_LIBRARY NAMES libnvinfer_plugin.a
- PATHS ${NVINFER_INCLUDE_DIR}/../lib64/
- DOC "library path for tensorrt.")
- find_library(NVPARSERS_LIBRARY NAMES libnvparsers.a
- PATHS ${NVINFER_INCLUDE_DIR}/../lib64/
- DOC "library path for tensorrt.")
- endif()
- if(NVINFER_INCLUDE_DIR AND NVINFER_LIBRARY AND NVINFER_PLUGIN_LIBRARY AND NVPARSERS_LIBRARY)
- set(NVINFER_FOUND TRUE)
- endif()
- if(NVINFER_FOUND)
- message(STATUS "Found NvInfer in ${NVINFER_INCLUDE_DIR}")
- include_directories(SYSTEM ${NVINFER_INCLUDE_DIR})
- #include_directories(${NVINFER_INCLUDE_DIR})
- list(APPEND ANAKIN_LINKER_LIBS ${NVINFER_LIBRARY})
- list(APPEND ANAKIN_LINKER_LIBS ${NVINFER_PLUGIN_LIBRARY})
- list(APPEND ANAKIN_LINKER_LIBS ${NVPARSERS_LIBRARY})
- message(STATUS "${ANAKIN_LINKER_LIBS}")
- else()
- message(FATAL_ERROR "Couldn't found NvInfer ! in path: ${NVINFER_INCLUDE_DIR}")
- endif()
+macro(anakin_find_sgx)
+ set(SGX_SDK $ENV{SGX_SDK})
+ if(SGX_SDK)
+ add_library(anakin_sgx_config INTERFACE)
+ set(SGX_CONFIG_INTERFACE anakin_sgx_config)
+ target_compile_options(${SGX_CONFIG_INTERFACE} INTERFACE
+ -fPIC -fno-builtin -nostdlib -nostdinc $<$:-nostdinc++>)
+ set(PROBE_CMD "echo \"#include \" | ${CMAKE_C_COMPILER} -E -xc - | grep immintrin.h | sed 's:^.*\"\\(.*\\)\".*$:\\1:g' | head -1")
+ execute_process(COMMAND sh -c "${PROBE_CMD}" OUTPUT_VARIABLE IMMINTRIN_H)
+ get_filename_component(IMMINTRIN_PATH ${IMMINTRIN_H} DIRECTORY)
+ target_include_directories(${SGX_CONFIG_INTERFACE} BEFORE INTERFACE
+ "${ANAKIN_ROOT}/sgx/enclave/include"
+ "${SGX_SDK}/include"
+ "${SGX_SDK}/include/tlibc"
+ "${SGX_SDK}/include/libcxx"
+ )
+ target_include_directories(${SGX_CONFIG_INTERFACE} INTERFACE ${IMMINTRIN_PATH})
+ list(APPEND ANAKIN_LINKER_LIBS "sgx_tstdc" "sgx_tcxx")
+ message(STATUS "Found SGX SDK in ${SGX_SDK}")
+ else()
+ message(FATAL_ERROR "SGX SDK not found or not properly configured!")
+ endif()
endmacro()
-
diff --git a/cmake/gather.cmake b/cmake/gather.cmake
index 32b03c05f..bdcdce97f 100644
--- a/cmake/gather.cmake
+++ b/cmake/gather.cmake
@@ -28,6 +28,11 @@ if(USE_BM_PLACE)
anakin_find_bmlib()
endif()
+# find cnml and cnrt
+#if(USE_MLU)
+## anakin_find_mlulib()
+#endif()
+
# set amd opencl path
if(AMD_GPU)
amd_build_cl_file("${CMAKE_SOURCE_DIR}/saber/funcs/impl/amd/cl" "${CMAKE_BINARY_DIR}/cl/amd")
@@ -59,7 +64,10 @@ endif()
if(USE_PROTOBUF)
anakin_find_protobuf()
- anakin_protos_processing()
+endif()
+
+if(USE_NANOPB)
+ anakin_find_nanopb()
endif()
if(BUILD_RPC)
@@ -88,9 +96,11 @@ endif()
if(DISABLE_ALL_WARNINGS)
anakin_disable_warnings(CMAKE_CXX_FLAGS)
endif()
-if(USE_OPENMP)
+
+if(USE_OPENMP AND NOT APPLE)
anakin_find_openmp()
endif()
+
if(USE_ARM_PLACE)
if(TARGET_ANDROID)
if(USE_OPENMP)
@@ -102,6 +112,7 @@ if(USE_ARM_PLACE)
message(FATAL_ERROR " ARM TARGET unknown !")
endif()
endif()
-if(USE_TENSORRT)
- anakin_find_nvinfer()
+
+if(USE_SGX)
+ anakin_find_sgx()
endif()
diff --git a/cmake/ios/ios.toolchain.cmake b/cmake/ios/ios.toolchain.cmake
old mode 100755
new mode 100644
index e6b56c7a5..ec1c98ecb
--- a/cmake/ios/ios.toolchain.cmake
+++ b/cmake/ios/ios.toolchain.cmake
@@ -1,202 +1,492 @@
-# This file is based off of the Platform/Darwin.cmake and Platform/UnixPaths.cmake
-# files which are included with CMake 2.8.4
-# It has been altered for iOS development
-
-# Options:
+# This file is part of the ios-cmake project. It was retrieved from
+# https://github.com/cristeab/ios-cmake.git, which is a fork of
+# https://code.google.com/p/ios-cmake/. Which in turn is based off of
+# the Platform/Darwin.cmake and Platform/UnixPaths.cmake files which
+# are included with CMake 2.8.4
#
-# IOS_PLATFORM = iPhoneOS (default) or iPhoneSimulator
-# This decides if SDKS will be selected from the iPhoneOS.platform or iPhoneSimulator.platform folders
-# iPhoneOS - the default, used to build for iPhone and iPad physical devices, which have an arm arch.
-# iPhoneSimulator - used to build for the Simulator platforms, which have an x86 arch.
+# The ios-cmake project is licensed under the new BSD license.
#
-# CMAKE_IOS_DEVELOPER_ROOT = automatic(default) or /path/to/platform/Developer folder
-# By default this location is automatcially chosen based on the IOS_PLATFORM value above.
-# If set manually, it will override the default location and force the user of a particular Developer Platform
+# Copyright (c) 2014, Bogdan Cristea and LTE Engineering Software,
+# Kitware, Inc., Insight Software Consortium. All rights reserved.
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
#
-# CMAKE_IOS_SDK_ROOT = automatic(default) or /path/to/platform/Developer/SDKs/SDK folder
-# By default this location is automatcially chosen based on the CMAKE_IOS_DEVELOPER_ROOT value.
-# In this case it will always be the most up-to-date SDK found in the CMAKE_IOS_DEVELOPER_ROOT path.
-# If set manually, this will force the use of a specific SDK version
-
-# Macros:
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# 3. Neither the name of the copyright holder nor the names of its
+# contributors may be used to endorse or promote products derived from
+# this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+# COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+# This file is based off of the Platform/Darwin.cmake and
+# Platform/UnixPaths.cmake files which are included with CMake 2.8.4
+# It has been altered for iOS development.
+#
+# Updated by Alex Stewart (alexs.mac@gmail.com)
+#
+# *****************************************************************************
+# Now maintained by Alexander Widerberg (widerbergaren [at] gmail.com)
+# under the BSD-3-Clause license
+# https://github.com/leetal/ios-cmake
+# *****************************************************************************
+#
+# INFORMATION / HELP
+#
+# The following variables control the behaviour of this toolchain:
+#
+# IOS_PLATFORM: OS (default) or SIMULATOR or SIMULATOR64 or TVOS or SIMULATOR_TVOS or WATCHOS or SIMULATOR_WATCHOS
+# OS = Build for iPhoneOS.
+# OS64 = Build for arm64 arm64e iPhoneOS.
+# SIMULATOR = Build for x86 i386 iPhone Simulator.
+# SIMULATOR64 = Build for x86_64 iPhone Simulator.
+# TVOS = Build for AppleTVOS.
+# SIMULATOR_TVOS = Build for x86_64 AppleTV Simulator.
+# WATCHOS = Build for armv7k arm64_32 for WatchOS.
+# SIMULATOR_WATCHOS = Build for x86_64 for Watch Simulator.
+# CMAKE_OSX_SYSROOT: Path to the iOS SDK to use. By default this is
+# automatically determined from IOS_PLATFORM and xcodebuild, but
+# can also be manually specified (although this should not be required).
+# CMAKE_IOS_DEVELOPER_ROOT: Path to the Developer directory for the iOS platform
+# being compiled for. By default this is automatically determined from
+# CMAKE_OSX_SYSROOT, but can also be manually specified (although this should
+# not be required).
+# ENABLE_BITCODE: (1|0) Enables or disables bitcode support. Default 1 (true)
+# ENABLE_ARC: (1|0) Enables or disables ARC support. Default 1 (true, ARC enabled by default)
+# ENABLE_VISIBILITY: (1|0) Enables or disables symbol visibility support. Default 0 (false, visibility hidden by default)
+# IOS_ARCH: (armv7 armv7s armv7k arm64 arm64e arm64_32 i386 x86_64) If specified, will override the default architectures for the given IOS_PLATFORM
+# OS = armv7 armv7s arm64 arm64e (if applicable)
+# OS64 = arm64 arm64e (if applicable)
+# SIMULATOR = i386
+# SIMULATOR64 = x86_64
+# TVOS = arm64
+# SIMULATOR_TVOS = x86_64 (i386 has since long been deprecated)
+# WATCHOS = armv7k arm64_32 (if applicable)
+# SIMULATOR_WATCHOS = x86_64 (i386 has since long been deprecated)
+#
+# This toolchain defines the following variables for use externally:
+#
+# XCODE_VERSION: Version number (not including Build version) of Xcode detected.
+# IOS_SDK_VERSION: Version of iOS SDK being used.
+# CMAKE_OSX_ARCHITECTURES: Architectures being compiled for (generated from
+# IOS_PLATFORM).
#
-# set_xcode_property (TARGET XCODE_PROPERTY XCODE_VALUE)
-# A convenience macro for setting xcode specific properties on targets
-# example: set_xcode_property (myioslib IPHONEOS_DEPLOYMENT_TARGET "3.1")
+# This toolchain defines the following macros for use externally:
+#
+# set_xcode_property (TARGET XCODE_PROPERTY XCODE_VALUE XCODE_VARIANT)
+# A convenience macro for setting xcode specific properties on targets.
+# Available variants are: All, Release, RelWithDebInfo, Debug, MinSizeRel
+# example: set_xcode_property (myioslib IPHONEOS_DEPLOYMENT_TARGET "3.1" "all").
#
# find_host_package (PROGRAM ARGS)
-# A macro used to find executable programs on the host system, not within the iOS environment.
-# Thanks to the android-cmake project for providing the command
-
-# Standard settings
-set (CMAKE_SYSTEM_NAME Darwin)
-set (CMAKE_SYSTEM_VERSION 1)
-set (UNIX True)
-set (APPLE True)
-set (IOS True)
-
-# Required as of cmake 2.8.10
-set (CMAKE_OSX_DEPLOYMENT_TARGET "" CACHE STRING "Force unset of the deployment target for iOS" FORCE)
-
-# Determine the cmake host system version so we know where to find the iOS SDKs
-find_program (CMAKE_UNAME uname /bin /usr/bin /usr/local/bin)
-if (CMAKE_UNAME)
- exec_program(uname ARGS -r OUTPUT_VARIABLE CMAKE_HOST_SYSTEM_VERSION)
- string (REGEX REPLACE "^([0-9]+)\\.([0-9]+).*$" "\\1" DARWIN_MAJOR_VERSION "${CMAKE_HOST_SYSTEM_VERSION}")
-endif (CMAKE_UNAME)
-
-# Force the compilers to gcc for iOS
-include (CMakeForceCompiler)
-set(CMAKE_C_COMPILER /usr/bin/clang)
-set(CMAKE_CXX_COMPILER /usr/bin/clang++)
-#CMAKE_FORCE_C_COMPILER (/usr/bin/clang Apple)
-#CMAKE_FORCE_CXX_COMPILER (/usr/bin/clang++ Apple)
+# A macro used to find executable programs on the host system, not within the
+# iOS environment. Thanks to the android-cmake project for providing the
+# command.
+
+# Fix for PThread library not in path
+set(CMAKE_THREAD_LIBS_INIT "-lpthread")
+set(CMAKE_HAVE_THREADS_LIBRARY 1)
+set(CMAKE_USE_WIN32_THREADS_INIT 0)
+set(CMAKE_USE_PTHREADS_INIT 1)
+
+# Cache what generator is used
+set(USED_CMAKE_GENERATOR "${CMAKE_GENERATOR}" CACHE STRING "Expose CMAKE_GENERATOR" FORCE)
+
+# Get the Xcode version being used.
+execute_process(COMMAND xcodebuild -version
+ OUTPUT_VARIABLE XCODE_VERSION
+ ERROR_QUIET
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+string(REGEX MATCH "Xcode [0-9\\.]+" XCODE_VERSION "${XCODE_VERSION}")
+string(REGEX REPLACE "Xcode ([0-9\\.]+)" "\\1" XCODE_VERSION "${XCODE_VERSION}")
+message(STATUS "Building with Xcode version: ${XCODE_VERSION}")
+# Default to building for iPhoneOS if not specified otherwise, and we cannot
+# determine the platform from the CMAKE_OSX_ARCHITECTURES variable. The use
+# of CMAKE_OSX_ARCHITECTURES is such that try_compile() projects can correctly
+# determine the value of IOS_PLATFORM from the root project, as
+# CMAKE_OSX_ARCHITECTURES is propagated to them by CMake.
+if (NOT DEFINED IOS_PLATFORM)
+ if (CMAKE_OSX_ARCHITECTURES)
+ if (CMAKE_OSX_ARCHITECTURES MATCHES ".*arm.*")
+ set(IOS_PLATFORM "OS")
+ elseif (CMAKE_OSX_ARCHITECTURES MATCHES "i386")
+ set(IOS_PLATFORM "SIMULATOR")
+ elseif (CMAKE_OSX_ARCHITECTURES MATCHES "x86_64")
+ set(IOS_PLATFORM "SIMULATOR64")
+ elseif (CMAKE_OSX_ARCHITECTURES MATCHES "armv7k")
+ set(IOS_PLATFORM "WATCHOS")
+ endif()
+ endif()
+ if (NOT IOS_PLATFORM)
+ set(IOS_PLATFORM "OS")
+ endif()
+endif()
+set(IOS_PLATFORM ${IOS_PLATFORM} CACHE STRING
+ "Type of iOS platform for which to build.")
+# Determine the platform name and architectures for use in xcodebuild commands
+# from the specified IOS_PLATFORM name.
+if (IOS_PLATFORM STREQUAL "OS")
+ set(XCODE_IOS_PLATFORM iphoneos)
+ if(NOT IOS_ARCH)
+ if (XCODE_VERSION VERSION_GREATER 10.0)
+ set(IOS_ARCH armv7 armv7s arm64 arm64e)
+ else()
+ set(IOS_ARCH armv7 armv7s arm64)
+ endif()
+ endif()
+ elseif (IOS_PLATFORM STREQUAL "OS64")
+ set(XCODE_IOS_PLATFORM iphoneos)
+ if(NOT IOS_ARCH)
+ if (XCODE_VERSION VERSION_GREATER 10.0)
+ set(IOS_ARCH arm64 arm64e)
+ else()
+ set(IOS_ARCH arm64)
+ endif()
+ endif()
+elseif (IOS_PLATFORM STREQUAL "SIMULATOR")
+ set(XCODE_IOS_PLATFORM iphonesimulator)
+ if(NOT IOS_ARCH)
+ set(IOS_ARCH i386)
+ endif()
+ message(WARNING "SIMULATOR IS DEPRECATED. Consider using SIMULATOR64 instead.")
+elseif(IOS_PLATFORM STREQUAL "SIMULATOR64")
+ set(XCODE_IOS_PLATFORM iphonesimulator)
+ if(NOT IOS_ARCH)
+ set(IOS_ARCH x86_64)
+ endif()
+elseif (IOS_PLATFORM STREQUAL "TVOS")
+ set(XCODE_IOS_PLATFORM appletvos)
+ if(NOT IOS_ARCH)
+ set(IOS_ARCH arm64)
+ endif()
+elseif (IOS_PLATFORM STREQUAL "SIMULATOR_TVOS")
+ set(XCODE_IOS_PLATFORM appletvsimulator)
+ if(NOT IOS_ARCH)
+ set(IOS_ARCH x86_64)
+ endif()
+elseif (IOS_PLATFORM STREQUAL "WATCHOS")
+ set(XCODE_IOS_PLATFORM watchos)
+ if(NOT IOS_ARCH)
+ if (XCODE_VERSION VERSION_GREATER 10.0)
+ set(IOS_ARCH armv7k arm64_32)
+ else()
+ set(IOS_ARCH armv7k)
+ endif()
+ endif()
+elseif (IOS_PLATFORM STREQUAL "SIMULATOR_WATCHOS")
+ set(XCODE_IOS_PLATFORM watchsimulator)
+ if(NOT IOS_ARCH)
+ set(IOS_ARCH x86_64)
+ endif()
+else()
+ message(FATAL_ERROR "Invalid IOS_PLATFORM: ${IOS_PLATFORM}")
+endif()
+message(STATUS "Configuring iOS build for platform: ${IOS_PLATFORM}, "
+ "architecture(s): ${IOS_ARCH}")
+# If user did not specify the SDK root to use, then query xcodebuild for it.
+execute_process(COMMAND xcodebuild -version -sdk ${XCODE_IOS_PLATFORM} Path
+ OUTPUT_VARIABLE CMAKE_OSX_SYSROOT_INT
+ OUTPUT_QUIET ERROR_QUIET
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+# If user did not specify the SDK root to use, then query xcodebuild for it.
+if (NOT DEFINED CMAKE_OSX_SYSROOT OR (NOT CMAKE_OSX_SYSROOT STREQUAL CMAKE_OSX_SYSROOT_INT))
+ execute_process(COMMAND xcodebuild -version -sdk ${XCODE_IOS_PLATFORM} Path
+ OUTPUT_VARIABLE CMAKE_OSX_SYSROOT
+ ERROR_QUIET
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+endif()
+if (NOT EXISTS ${CMAKE_OSX_SYSROOT})
+ message(SEND_ERROR "Please make sure that Xcode is installed and that the toolchain"
+ "is pointing to the correct path. Please run:"
+ "sudo xcode-select -s /Applications/Xcode.app/Contents/Developer"
+ " and see if that fixes the problem for you.")
+ message(FATAL_ERROR "Invalid CMAKE_OSX_SYSROOT: ${CMAKE_OSX_SYSROOT} "
+ "does not exist.")
+elseif(DEFINED CMAKE_OSX_SYSROOT)
+ message(STATUS "Using manually set SDK path: ${CMAKE_OSX_SYSROOT} for platform: ${IOS_PLATFORM}")
+else()
+ message(STATUS "Using SDK: ${CMAKE_OSX_SYSROOT} for platform: ${IOS_PLATFORM}")
+endif()
+# Specify minimum version of deployment target.
+if (NOT DEFINED IOS_DEPLOYMENT_TARGET)
+ if (IOS_PLATFORM STREQUAL "WATCHOS" OR IOS_PLATFORM STREQUAL "SIMULATOR_WATCHOS")
+ # Unless specified, SDK version 2.0 is used by default as minimum target version (watchOS).
+ set(IOS_DEPLOYMENT_TARGET "2.0"
+ CACHE STRING "Minimum iOS version to build for." )
+ else()
+ # Unless specified, SDK version 8.0 is used by default as minimum target version (iOS, tvOS).
+ set(IOS_DEPLOYMENT_TARGET "8.0"
+ CACHE STRING "Minimum iOS version to build for." )
+ endif()
+ message(STATUS "Using the default min-version since IOS_DEPLOYMENT_TARGET not provided!")
+endif()
+# Use bitcode or not
+if (NOT DEFINED ENABLE_BITCODE AND NOT IOS_ARCH MATCHES "((^|, )(i386|x86_64))+")
+ # Unless specified, enable bitcode support by default
+ set(ENABLE_BITCODE TRUE CACHE BOOL "Whether or not to enable bitcode")
+ message(STATUS "Enabling bitcode support by default. ENABLE_BITCODE not provided!")
+endif()
+if (NOT DEFINED ENABLE_BITCODE)
+ message(STATUS "Disabling bitcode support by default on simulators. ENABLE_BITCODE not provided for override!")
+endif()
+# Use ARC or not
+if (NOT DEFINED ENABLE_ARC)
+ # Unless specified, enable ARC support by default
+ set(ENABLE_ARC TRUE CACHE BOOL "Whether or not to enable ARC")
+ message(STATUS "Enabling ARC support by default. ENABLE_ARC not provided!")
+endif()
+# Use hidden visibility or not
+if (NOT DEFINED ENABLE_VISIBILITY)
+ # Unless specified, disable symbols visibility by default
+ set(ENABLE_VISIBILITY FALSE CACHE BOOL "Whether or not to hide symbols (-fvisibility=hidden)")
+ message(STATUS "Hiding symbols visibility by default. ENABLE_VISIBILITY not provided!")
+endif()
+# Get the SDK version information.
+execute_process(COMMAND xcodebuild -sdk ${CMAKE_OSX_SYSROOT} -version SDKVersion
+ OUTPUT_VARIABLE IOS_SDK_VERSION
+ ERROR_QUIET
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+# Find the Developer root for the specific iOS platform being compiled for
+# from CMAKE_OSX_SYSROOT. Should be ../../ from SDK specified in
+# CMAKE_OSX_SYSROOT. There does not appear to be a direct way to obtain
+# this information from xcrun or xcodebuild.
+if (NOT CMAKE_IOS_DEVELOPER_ROOT)
+ get_filename_component(IOS_PLATFORM_SDK_DIR ${CMAKE_OSX_SYSROOT} PATH)
+ get_filename_component(CMAKE_IOS_DEVELOPER_ROOT ${IOS_PLATFORM_SDK_DIR} PATH)
+endif()
+if (NOT EXISTS ${CMAKE_IOS_DEVELOPER_ROOT})
+ message(FATAL_ERROR "Invalid CMAKE_IOS_DEVELOPER_ROOT: "
+ "${CMAKE_IOS_DEVELOPER_ROOT} does not exist.")
+endif()
+# Find the C & C++ compilers for the specified SDK.
+if (NOT CMAKE_C_COMPILER)
+ execute_process(COMMAND xcrun -sdk ${CMAKE_OSX_SYSROOT} -find clang
+ OUTPUT_VARIABLE CMAKE_C_COMPILER
+ ERROR_QUIET
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ message(STATUS "Using C compiler: ${CMAKE_C_COMPILER}")
+endif()
+if (NOT CMAKE_CXX_COMPILER)
+ execute_process(COMMAND xcrun -sdk ${CMAKE_OSX_SYSROOT} -find clang++
+ OUTPUT_VARIABLE CMAKE_CXX_COMPILER
+ ERROR_QUIET
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ message(STATUS "Using CXX compiler: ${CMAKE_CXX_COMPILER}")
+endif()
+# Find (Apple's) libtool.
+execute_process(COMMAND xcrun -sdk ${CMAKE_OSX_SYSROOT} -find libtool
+ OUTPUT_VARIABLE IOS_LIBTOOL
+ ERROR_QUIET
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+message(STATUS "Using libtool: ${IOS_LIBTOOL}")
+# Configure libtool to be used instead of ar + ranlib to build static libraries.
+# This is required on Xcode 7+, but should also work on previous versions of
+# Xcode.
+set(CMAKE_C_CREATE_STATIC_LIBRARY
+ "${IOS_LIBTOOL} -static -o ")
+set(CMAKE_CXX_CREATE_STATIC_LIBRARY
+ "${IOS_LIBTOOL} -static -o ")
+# Get the version of Darwin (OS X) of the host.
+execute_process(COMMAND uname -r
+ OUTPUT_VARIABLE CMAKE_HOST_SYSTEM_VERSION
+ ERROR_QUIET
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+# Standard settings.
+set(CMAKE_SYSTEM_NAME Darwin CACHE INTERNAL "")
+set(CMAKE_SYSTEM_VERSION ${IOS_SDK_VERSION} CACHE INTERNAL "")
+set(UNIX TRUE CACHE BOOL "")
+set(APPLE TRUE CACHE BOOL "")
+set(. TRUE CACHE BOOL "")
set(CMAKE_AR ar CACHE FILEPATH "" FORCE)
-
-# Skip the platform compiler checks for cross compiling
-set (CMAKE_CXX_COMPILER_WORKS TRUE)
-set (CMAKE_C_COMPILER_WORKS TRUE)
-
-# All iOS/Darwin specific settings - some may be redundant
-set (CMAKE_SHARED_LIBRARY_PREFIX "lib")
-set (CMAKE_SHARED_LIBRARY_SUFFIX ".dylib")
-set (CMAKE_SHARED_MODULE_PREFIX "lib")
-set (CMAKE_SHARED_MODULE_SUFFIX ".so")
-set (CMAKE_MODULE_EXISTS 1)
-set (CMAKE_DL_LIBS "")
-
-set (CMAKE_C_OSX_COMPATIBILITY_VERSION_FLAG "-compatibility_version ")
-set (CMAKE_C_OSX_CURRENT_VERSION_FLAG "-current_version ")
-set (CMAKE_CXX_OSX_COMPATIBILITY_VERSION_FLAG "${CMAKE_C_OSX_COMPATIBILITY_VERSION_FLAG}")
-set (CMAKE_CXX_OSX_CURRENT_VERSION_FLAG "${CMAKE_C_OSX_CURRENT_VERSION_FLAG}")
-
-# Hidden visibilty is required for cxx on iOS
-set (CMAKE_C_FLAGS_INIT "-isysroot ${CMAKE_OSX_SYSROOT} -miphoneos-version-min=6.0")
-set (CMAKE_CXX_FLAGS_INIT "-stdlib=libc++ -fvisibility=hidden -fvisibility-inlines-hidden -isysroot ${CMAKE_OSX_SYSROOT} -miphoneos-version-min=6.0")
-
-set (CMAKE_C_LINK_FLAGS "-Wl,-search_paths_first ${CMAKE_C_LINK_FLAGS}")
-set (CMAKE_CXX_LINK_FLAGS "-Wl,-search_paths_first ${CMAKE_CXX_LINK_FLAGS}")
-
-set (CMAKE_PLATFORM_HAS_INSTALLNAME 1)
-set (CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-dynamiclib -headerpad_max_install_names")
-set (CMAKE_SHARED_MODULE_CREATE_C_FLAGS "-bundle -headerpad_max_install_names")
-set (CMAKE_SHARED_MODULE_LOADER_C_FLAG "-Wl,-bundle_loader,")
-set (CMAKE_SHARED_MODULE_LOADER_CXX_FLAG "-Wl,-bundle_loader,")
-set (CMAKE_FIND_LIBRARY_SUFFIXES ".dylib" ".so" ".a")
-
-# hack: if a new cmake (which uses CMAKE_INSTALL_NAME_TOOL) runs on an old build tree
-# (where install_name_tool was hardcoded) and where CMAKE_INSTALL_NAME_TOOL isn't in the cache
-# and still cmake didn't fail in CMakeFindBinUtils.cmake (because it isn't rerun)
-# hardcode CMAKE_INSTALL_NAME_TOOL here to install_name_tool, so it behaves as it did before, Alex
+set(CMAKE_RANLIB ranlib CACHE FILEPATH "" FORCE)
+# Force unset of OS X-specific deployment target (otherwise autopopulated),
+# required as of cmake 2.8.10.
+set(CMAKE_OSX_DEPLOYMENT_TARGET "" CACHE STRING
+ "Must be empty for iOS builds." FORCE)
+# Set the architectures for which to build.
+set(CMAKE_OSX_ARCHITECTURES ${IOS_ARCH} CACHE STRING "Build architecture for iOS")
+# Change the type of target generated for try_compile() so it'll work when cross-compiling
+set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
+# All iOS/Darwin specific settings - some may be redundant.
+set(CMAKE_SHARED_LIBRARY_PREFIX "lib")
+set(CMAKE_SHARED_LIBRARY_SUFFIX ".dylib")
+set(CMAKE_SHARED_MODULE_PREFIX "lib")
+set(CMAKE_SHARED_MODULE_SUFFIX ".so")
+set(CMAKE_C_COMPILER_ABI ELF)
+set(CMAKE_CXX_COMPILER_ABI ELF)
+set(CMAKE_C_HAS_ISYSROOT 1)
+set(CMAKE_CXX_HAS_ISYSROOT 1)
+set(CMAKE_MODULE_EXISTS 1)
+set(CMAKE_DL_LIBS "")
+set(CMAKE_C_OSX_COMPATIBILITY_VERSION_FLAG "-compatibility_version ")
+set(CMAKE_C_OSX_CURRENT_VERSION_FLAG "-current_version ")
+set(CMAKE_CXX_OSX_COMPATIBILITY_VERSION_FLAG "${CMAKE_C_OSX_COMPATIBILITY_VERSION_FLAG}")
+set(CMAKE_CXX_OSX_CURRENT_VERSION_FLAG "${CMAKE_C_OSX_CURRENT_VERSION_FLAG}")
+
+if(IOS_ARCH MATCHES "((^|, )(arm64|arm64e|x86_64))+")
+ set(CMAKE_C_SIZEOF_DATA_PTR 8)
+ set(CMAKE_CXX_SIZEOF_DATA_PTR 8)
+ message(STATUS "Using a data_ptr size of 8")
+else()
+ set(CMAKE_C_SIZEOF_DATA_PTR 4)
+ set(CMAKE_CXX_SIZEOF_DATA_PTR 4)
+ message(STATUS "Using a data_ptr size of 4")
+endif()
+
+message(STATUS "Building for minimum iOS version: ${IOS_DEPLOYMENT_TARGET}"
+ " (SDK version: ${IOS_SDK_VERSION})")
+# Note that only Xcode 7+ supports the newer more specific:
+# -m${XCODE_IOS_PLATFORM}-version-min flags, older versions of Xcode use:
+# -m(ios/ios-simulator)-version-min instead.
+if (IOS_PLATFORM STREQUAL "OS" OR IOS_PLATFORM STREQUAL "OS64")
+ if (XCODE_VERSION VERSION_LESS 7.0)
+ set(XCODE_IOS_PLATFORM_VERSION_FLAGS
+ "-mios-version-min=${IOS_DEPLOYMENT_TARGET}")
+ else()
+ # Xcode 7.0+ uses flags we can build directly from XCODE_IOS_PLATFORM.
+ set(XCODE_IOS_PLATFORM_VERSION_FLAGS
+ "-m${XCODE_IOS_PLATFORM}-version-min=${IOS_DEPLOYMENT_TARGET}")
+ endif()
+elseif (IOS_PLATFORM STREQUAL "TVOS")
+ set(XCODE_IOS_PLATFORM_VERSION_FLAGS
+ "-mtvos-version-min=${IOS_DEPLOYMENT_TARGET}")
+elseif (IOS_PLATFORM STREQUAL "SIMULATOR_TVOS")
+ set(XCODE_IOS_PLATFORM_VERSION_FLAGS
+ "-mtvos-simulator-version-min=${IOS_DEPLOYMENT_TARGET}")
+elseif (IOS_PLATFORM STREQUAL "WATCHOS")
+ set(XCODE_IOS_PLATFORM_VERSION_FLAGS
+ "-mwatchos-version-min=${IOS_DEPLOYMENT_TARGET}")
+elseif (IOS_PLATFORM STREQUAL "SIMULATOR_WATCHOS")
+ set(XCODE_IOS_PLATFORM_VERSION_FLAGS
+ "-mwatchos-simulator-version-min=${IOS_DEPLOYMENT_TARGET}")
+else()
+ # SIMULATOR or SIMULATOR64 both use -mios-simulator-version-min.
+ set(XCODE_IOS_PLATFORM_VERSION_FLAGS
+ "-mios-simulator-version-min=${IOS_DEPLOYMENT_TARGET}")
+endif()
+message(STATUS "Version flags set to: ${XCODE_IOS_PLATFORM_VERSION_FLAGS}")
+
+if (ENABLE_BITCODE)
+ set(BITCODE "-fembed-bitcode")
+ set(HEADER_PAD "")
+ message(STATUS "Enabling bitcode support.")
+else()
+ set(BITCODE "")
+ set(HEADER_PAD "-headerpad_max_install_names")
+ message(STATUS "Disabling bitcode support.")
+endif()
+
+if (ENABLE_ARC)
+ set(FOBJC_ARC "-fobjc-arc")
+ message(STATUS "Enabling ARC support.")
+else()
+ set(FOBJC_ARC "-fno-objc-arc")
+ message(STATUS "Disabling ARC support.")
+endif()
+
+if (NOT ENABLE_VISIBILITY)
+ set(VISIBILITY "-fvisibility=hidden")
+ message(STATUS "Hiding symbols (-fvisibility=hidden).")
+else()
+ set(VISIBILITY "")
+endif()
+
+set(CMAKE_C_FLAGS
+"${XCODE_IOS_PLATFORM_VERSION_FLAGS} ${BITCODE} -fobjc-abi-version=2 ${FOBJC_ARC} ${CMAKE_C_FLAGS}")
+# Hidden visibilty is required for C++ on iOS.
+set(CMAKE_CXX_FLAGS
+"${XCODE_IOS_PLATFORM_VERSION_FLAGS} ${BITCODE} ${VISIBILITY} -fvisibility-inlines-hidden -fobjc-abi-version=2 ${FOBJC_ARC} ${CMAKE_CXX_FLAGS}")
+set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} -O0 -g ${BITCODE} ${CMAKE_CXX_FLAGS_DEBUG}")
+set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS} -DNDEBUG -Os -ffast-math ${BITCODE} ${CMAKE_CXX_FLAGS_MINSIZEREL}")
+set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS} -DNDEBUG -O2 -g -ffast-math ${BITCODE} ${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
+set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} -DNDEBUG -O3 -ffast-math ${BITCODE} ${CMAKE_CXX_FLAGS_RELEASE}")
+set(CMAKE_C_LINK_FLAGS "${XCODE_IOS_PLATFORM_VERSION_FLAGS} -Wl,-search_paths_first ${CMAKE_C_LINK_FLAGS}")
+set(CMAKE_CXX_LINK_FLAGS "${XCODE_IOS_PLATFORM_VERSION_FLAGS} -Wl,-search_paths_first ${CMAKE_CXX_LINK_FLAGS}")
+
+# In order to ensure that the updated compiler flags are used in try_compile()
+# tests, we have to forcibly set them in the CMake cache, not merely set them
+# in the local scope.
+list(APPEND VARS_TO_FORCE_IN_CACHE
+ CMAKE_C_FLAGS
+ CMAKE_CXX_FLAGS
+ CMAKE_CXX_FLAGS_DEBUG
+ CMAKE_CXX_FLAGS_RELWITHDEBINFO
+ CMAKE_CXX_FLAGS_MINSIZEREL
+ CMAKE_CXX_FLAGS_RELEASE
+ CMAKE_C_LINK_FLAGS
+ CMAKE_CXX_LINK_FLAGS)
+foreach(VAR_TO_FORCE ${VARS_TO_FORCE_IN_CACHE})
+ set(${VAR_TO_FORCE} "${${VAR_TO_FORCE}}" CACHE STRING "")
+endforeach()
+
+set(CMAKE_PLATFORM_HAS_INSTALLNAME 1)
+set (CMAKE_SHARED_LINKER_FLAGS "-rpath @executable_path/Frameworks -rpath @loader_path/Frameworks")
+set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-dynamiclib ${HEADER_PAD}")
+set(CMAKE_SHARED_MODULE_CREATE_C_FLAGS "-bundle ${HEADER_PAD}")
+set(CMAKE_SHARED_MODULE_LOADER_C_FLAG "-Wl,-bundle_loader,")
+set(CMAKE_SHARED_MODULE_LOADER_CXX_FLAG "-Wl,-bundle_loader,")
+set(CMAKE_FIND_LIBRARY_SUFFIXES ".dylib" ".so" ".a")
+
+# Hack: if a new cmake (which uses CMAKE_INSTALL_NAME_TOOL) runs on an old
+# build tree (where install_name_tool was hardcoded) and where
+# CMAKE_INSTALL_NAME_TOOL isn't in the cache and still cmake didn't fail in
+# CMakeFindBinUtils.cmake (because it isn't rerun) hardcode
+# CMAKE_INSTALL_NAME_TOOL here to install_name_tool, so it behaves as it did
+# before, Alex.
if (NOT DEFINED CMAKE_INSTALL_NAME_TOOL)
- find_program(CMAKE_INSTALL_NAME_TOOL install_name_tool)
+ find_program(CMAKE_INSTALL_NAME_TOOL install_name_tool)
endif (NOT DEFINED CMAKE_INSTALL_NAME_TOOL)
-# Setup iOS platform unless specified manually with IOS_PLATFORM
-if (NOT DEFINED IOS_PLATFORM)
- set (IOS_PLATFORM "iPhoneOS")
-endif (NOT DEFINED IOS_PLATFORM)
-set (IOS_PLATFORM ${IOS_PLATFORM} CACHE STRING "Type of iOS Platform")
-
-# Add Bitcode
-if (${IOS_PLATFORM} STREQUAL "iPhoneOS")
- set(CMAKE_XCODE_ATTRIBUTE_BITCODE_GENERATION_MODE "bitcode")
- set(CMAKE_C_FLAGS "-fembed-bitcode ${CMAKE_C_FLAGS}")
- set(CMAKE_CXX_FLAGS "-fembed-bitcode ${CMAKE_CXX_FLAGS}")
-endif (${IOS_PLATFORM} STREQUAL "iPhoneOS")
-
-# Check the platform selection and setup for developer root
-if (${IOS_PLATFORM} STREQUAL "iPhoneOS")
- set (IOS_PLATFORM_LOCATION "iPhoneOS.platform")
-
- # This causes the installers to properly locate the output libraries
- set (CMAKE_XCODE_EFFECTIVE_PLATFORMS "-iphoneos")
-elseif (${IOS_PLATFORM} STREQUAL "iPhoneSimulator")
- set (IOS_PLATFORM_LOCATION "iPhoneSimulator.platform")
-
- # This causes the installers to properly locate the output libraries
- set (CMAKE_XCODE_EFFECTIVE_PLATFORMS "-iphonesimulator")
-else (${IOS_PLATFORM} STREQUAL "iPhoneOS")
- message (FATAL_ERROR "Unsupported IOS_PLATFORM value selected. Please choose iPhoneOS or iPhoneSimulator")
-endif (${IOS_PLATFORM} STREQUAL "iPhoneOS")
-
-# Setup iOS developer location unless specified manually with CMAKE_IOS_DEVELOPER_ROOT
-# Note Xcode 4.3 changed the installation location, choose the most recent one available
-set (XCODE_POST_43_ROOT "/Applications/Xcode.app/Contents/Developer/Platforms/${IOS_PLATFORM_LOCATION}/Developer")
-set (XCODE_PRE_43_ROOT "/Developer/Platforms/${IOS_PLATFORM_LOCATION}/Developer")
-if (NOT DEFINED CMAKE_IOS_DEVELOPER_ROOT)
- if (EXISTS ${XCODE_POST_43_ROOT})
- set (CMAKE_IOS_DEVELOPER_ROOT ${XCODE_POST_43_ROOT})
- elseif(EXISTS ${XCODE_PRE_43_ROOT})
- set (CMAKE_IOS_DEVELOPER_ROOT ${XCODE_PRE_43_ROOT})
- endif (EXISTS ${XCODE_POST_43_ROOT})
-endif (NOT DEFINED CMAKE_IOS_DEVELOPER_ROOT)
-set (CMAKE_IOS_DEVELOPER_ROOT ${CMAKE_IOS_DEVELOPER_ROOT} CACHE PATH "Location of iOS Platform")
-
-# Find and use the most recent iOS sdk unless specified manually with CMAKE_IOS_SDK_ROOT
-if (NOT DEFINED CMAKE_IOS_SDK_ROOT)
- file (GLOB _CMAKE_IOS_SDKS "${CMAKE_IOS_DEVELOPER_ROOT}/SDKs/*")
- if (_CMAKE_IOS_SDKS)
- list (SORT _CMAKE_IOS_SDKS)
- list (REVERSE _CMAKE_IOS_SDKS)
- list (GET _CMAKE_IOS_SDKS 0 CMAKE_IOS_SDK_ROOT)
- else (_CMAKE_IOS_SDKS)
- message (FATAL_ERROR "No iOS SDK's found in default search path ${CMAKE_IOS_DEVELOPER_ROOT}. Manually set CMAKE_IOS_SDK_ROOT or install the iOS SDK.")
- endif (_CMAKE_IOS_SDKS)
- message (STATUS "Toolchain using default iOS SDK: ${CMAKE_IOS_SDK_ROOT}")
-endif (NOT DEFINED CMAKE_IOS_SDK_ROOT)
-set (CMAKE_IOS_SDK_ROOT ${CMAKE_IOS_SDK_ROOT} CACHE PATH "Location of the selected iOS SDK")
-
-# Set the sysroot default to the most recent SDK
-set (CMAKE_OSX_SYSROOT ${CMAKE_IOS_SDK_ROOT} CACHE PATH "Sysroot used for iOS support")
-
-# set the architecture for iOS
-# NOTE: Currently both ARCHS_STANDARD_32_BIT and ARCHS_UNIVERSAL_IPHONE_OS set armv7 only, so set both manually
-if (${IOS_PLATFORM} STREQUAL "iPhoneOS")
- set (IOS_ARCH armv7)
-else (${IOS_PLATFORM} STREQUAL "iPhoneOS")
- set (IOS_ARCH i386)
-endif (${IOS_PLATFORM} STREQUAL "iPhoneOS")
-
-set (CMAKE_OSX_ARCHITECTURES ${IOS_ARCH} CACHE string "Build architecture for iOS")
-
-# Set the find root to the iOS developer roots and to user defined paths
-set (CMAKE_FIND_ROOT_PATH ${CMAKE_IOS_DEVELOPER_ROOT} ${CMAKE_IOS_SDK_ROOT} ${CMAKE_PREFIX_PATH} CACHE string "iOS find search path root")
-
-# default to searching for frameworks first
-set (CMAKE_FIND_FRAMEWORK FIRST)
-
-# set up the default search directories for frameworks
-set (CMAKE_SYSTEM_FRAMEWORK_PATH
- ${CMAKE_IOS_SDK_ROOT}/System/Library/Frameworks
- ${CMAKE_IOS_SDK_ROOT}/System/Library/PrivateFrameworks
- ${CMAKE_IOS_SDK_ROOT}/Developer/Library/Frameworks
-)
-
-# only search the iOS sdks, not the remainder of the host filesystem
-set (CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY)
-set (CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
-set (CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
-
-
-# This little macro lets you set any XCode specific property
-macro (set_xcode_property TARGET XCODE_PROPERTY XCODE_VALUE)
- set_property (TARGET ${TARGET} PROPERTY XCODE_ATTRIBUTE_${XCODE_PROPERTY} ${XCODE_VALUE})
-endmacro (set_xcode_property)
-
-
-# This macro lets you find executable programs on the host system
-macro (find_host_package)
- set (CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
- set (CMAKE_FIND_ROOT_PATH_MODE_LIBRARY NEVER)
- set (CMAKE_FIND_ROOT_PATH_MODE_INCLUDE NEVER)
- set (IOS FALSE)
-
- find_package(${ARGN})
-
- set (IOS TRUE)
- set (CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY)
- set (CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
- set (CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
-endmacro (find_host_package)
-
+# Set the find root to the iOS developer roots and to user defined paths.
+set(CMAKE_FIND_ROOT_PATH ${CMAKE_IOS_DEVELOPER_ROOT} ${CMAKE_OSX_SYSROOT}
+ ${CMAKE_PREFIX_PATH} CACHE string "iOS find search path root" FORCE)
+# Default to searching for frameworks first.
+set(CMAKE_FIND_FRAMEWORK FIRST)
+# Set up the default search directories for frameworks.
+set(CMAKE_SYSTEM_FRAMEWORK_PATH
+ ${CMAKE_OSX_SYSROOT}/System/Library/Frameworks
+ ${CMAKE_OSX_SYSROOT}/System/Library/PrivateFrameworks
+ ${CMAKE_OSX_SYSROOT}/Developer/Library/Frameworks)
+# Only search the specified iOS SDK, not the remainder of the host filesystem.
+set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY)
+set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
+set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
+# This little macro lets you set any XCode specific property.
+macro(set_xcode_property TARGET XCODE_PROPERTY XCODE_VALUE XCODE_RELVERSION)
+ set(XCODE_RELVERSION_I "${XCODE_RELVERSION}")
+ if (XCODE_RELVERSION_I STREQUAL "All")
+ set_property(TARGET ${TARGET} PROPERTY
+ XCODE_ATTRIBUTE_${XCODE_PROPERTY} "${XCODE_VALUE}")
+ else()
+ set_property(TARGET ${TARGET} PROPERTY
+ XCODE_ATTRIBUTE_${XCODE_PROPERTY}[variant=${XCODE_RELVERSION_I}] "${XCODE_VALUE}")
+ endif()
+endmacro(set_xcode_property)
+# This macro lets you find executable programs on the host system.
+macro(find_host_package)
+ set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
+ set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY NEVER)
+ set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE NEVER)
+ set(. FALSE)
+ find_package(${ARGN})
+ set(. TRUE)
+ set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY)
+ set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
+ set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
+endmacro(find_host_package)
diff --git a/cmake/linux_arm/linux_arm.toolchain.cmake b/cmake/linux_arm/linux_arm.toolchain.cmake
new file mode 100644
index 000000000..92e894e17
--- /dev/null
+++ b/cmake/linux_arm/linux_arm.toolchain.cmake
@@ -0,0 +1,25 @@
+# this one is important
+SET(CMAKE_SYSTEM_NAME Linux)
+SET(CMAKE_SYSTEM_PROCESSOR arm)
+#this one not so much
+#SET(CMAKE_SYSTEM_VERSION 1)
+
+# specify the cross compiler
+SET(CMAKE_C_COMPILER ${LINUX_ARM_TOOL_ROOT}/bin/arm-linux-gnueabihf-gcc)
+SET(CMAKE_CXX_COMPILER ${LINUX_ARM_TOOL_ROOT}/bin/arm-linux-gnueabihf-g++)
+#SET(CMAKE_LINKER /home/xuhailong/dev-tool/arm-linux/64hf/bin/arm-linux-gnueabihf-g++)
+#SET(CMAKE_AR /home/xuhailong/dev-tool/arm-linux/64hf/bin/arm-linux-gnueabihf-g++)
+
+# where is the target environment
+SET(CMAKE_FIND_ROOT_PATH ${LINUX_ARM_TOOL_ROOT})
+
+# search for programs in the build host directories
+SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
+# for libraries and headers in the target directories
+SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
+SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
+
+# float-abi: hard, softfp
+add_compile_options(-mfloat-abi=softfp)
+add_compile_options(-mfpu=neon)
+add_compile_options(-march=armv7-a)
diff --git a/cmake/linux_arm/linux_arm_hf.toolchain.cmake b/cmake/linux_arm/linux_arm_hf.toolchain.cmake
new file mode 100644
index 000000000..941906b78
--- /dev/null
+++ b/cmake/linux_arm/linux_arm_hf.toolchain.cmake
@@ -0,0 +1,25 @@
+# this one is important
+SET(CMAKE_SYSTEM_NAME Linux)
+SET(CMAKE_SYSTEM_PROCESSOR arm)
+#this one not so much
+#SET(CMAKE_SYSTEM_VERSION 1)
+
+# specify the cross compiler
+SET(CMAKE_C_COMPILER ${LINUX_ARM_TOOL_ROOT}/bin/arm-linux-gnueabihf-gcc)
+SET(CMAKE_CXX_COMPILER ${LINUX_ARM_TOOL_ROOT}/bin/arm-linux-gnueabihf-g++)
+#SET(CMAKE_LINKER /home/xuhailong/dev-tool/arm-linux/64hf/bin/arm-linux-gnueabihf-g++)
+#SET(CMAKE_AR /home/xuhailong/dev-tool/arm-linux/64hf/bin/arm-linux-gnueabihf-g++)
+
+# where is the target environment
+SET(CMAKE_FIND_ROOT_PATH ${LINUX_ARM_TOOL_ROOT})
+
+# search for programs in the build host directories
+SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
+# for libraries and headers in the target directories
+SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
+SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
+
+# float-abi: hard, softfp
+add_compile_options(-mfloat-abi=hard)
+add_compile_options(-mfpu=neon)
+add_compile_options(-march=armv7-a)
diff --git a/cmake/mlu.cmake b/cmake/mlu.cmake
new file mode 100644
index 000000000..80669e1ab
--- /dev/null
+++ b/cmake/mlu.cmake
@@ -0,0 +1,42 @@
+# ----------------------------------------------------------------------------
+# section: Find mlu and config compile options.
+# ----------------------------------------------------------------------------
+macro(anakin_find_mlulib)
+ SET(CNRTML_ROOT ${ANAKIN_THIRD_PARTY_PATH}/mlu)
+ SET(CNML_INCLUDE_SEARCH_PATHS ${CNRTML_ROOT}/include)
+ SET(CNML_LIB_SEARCH_PATHS ${CNRTML_ROOT}/lib)
+
+ SET(CNRT_INCLUDE_SEARCH_PATHS ${CNRTML_ROOT}/include)
+ SET(CNRT_LIB_SEARCH_PATHS ${CNRTML_ROOT}/lib)
+
+ find_path(CNML_INCLUDE_DIR cnml.h PATHS ${CNML_INCLUDE_SEARCH_PATHS} NO_DEFAULT_PATH)
+
+ find_path(CNRT_INCLUDE_DIR cnrt.h PATHS ${CNRT_INCLUDE_SEARCH_PATHS} NO_DEFAULT_PATH)
+
+ find_library(CNML_LIBRARY NAMES libcnml.so
+ PATHS ${CNML_LIB_SEARCH_PATHS}
+ DOC "library path for cnml.")
+
+ find_library(CNRT_LIBRARY NAMES libcnrt.so
+ PATHS ${CNRT_LIB_SEARCH_PATHS}
+ DOC "library path for cnrt.")
+
+ if(CNML_INCLUDE_DIR AND CNML_LIBRARY AND CNRT_INCLUDE_DIR AND CNRT_LIBRARY)
+ set(MLU_FOUND YES)
+ endif()
+ if(MLU_FOUND)
+ include_directories(SYSTEM ${CNML_INCLUDE_DIR})
+ list(APPEND ANAKIN_LINKER_LIBS ${CNML_LIBRARY})
+ message(STATUS "Found CNML (include: ${CNML_INCLUDE_DIR}, library: ${CNML_LIBRARY})")
+
+ include_directories(SYSTEM ${CNRT_INCLUDE_DIR})
+ list(APPEND ANAKIN_LINKER_LIBS ${CNRT_LIBRARY})
+ message(STATUS "Found CNRT (include: ${CNRT_INCLUDE_DIR}, library: ${CNRT_LIBRARY})")
+
+ else()
+# message(SEND_ERROR "Could not find cnml library in: ${CNML_ROOT}")
+# message(SEND_ERROR "Could not find cnrt library in: ${CNRT_ROOT}")
+ message(STATUS "Could not find cnml library in: ${CNML_ROOT}")
+ message(STATUS "Could not find cnrt library in: ${CNRT_ROOT}")
+ endif()
+endmacro()
diff --git a/cmake/statistic.cmake b/cmake/statistic.cmake
index d316968dc..34b23c1ce 100644
--- a/cmake/statistic.cmake
+++ b/cmake/statistic.cmake
@@ -27,6 +27,7 @@ function(anakin_print_statistic)
message(STATUS " CXX flags : ${CMAKE_CXX_FLAGS}")
message(STATUS " Link flags : ${CMAKE_EXE_LINKER_FLAGS}")
message(STATUS " Shared Link flags : ${CMAKE_SHARED_LINKER_FLAGS}")
+ message(STATUS " Anakin Link Libs : ${ANAKIN_LINKER_LIBS}")
message(STATUS " Build type : ${BoldWhite}${CMAKE_BUILD_TYPE}${ColourReset}")
message(STATUS " Build cross plantform : ${BUILD_CROSS_PLANTFORM}")
if(ANAKIN_TYPE_FP64)
@@ -61,7 +62,9 @@ function(anakin_print_statistic)
if(USE_PROTOBUF)
message(STATUS " Use google protobuf : ${USE_PROTOBUF}")
endif()
-
+ if(USE_NANOPB)
+ message(STATUS " USE nanopb : ${USE_NANOPB}")
+ endif()
if(USE_GTEST)
message(STATUS " USE_GTEST : ${USE_GTEST}")
else()
@@ -92,7 +95,13 @@ function(anakin_print_statistic)
message(STATUS " USE_X86 : ${USE_X86_PLACE}")
message(STATUS " X86 Target Arch : ${BUILD_X86_ARCH}")
endif()
-
+
+ if(USE_MLU)
+ message(STATUS "")
+ message(STATUS "${Green}Mlu:${ColourReset}")
+ message(STATUS " USE_MLU : ${USE_MLU}")
+ endif()
+
if(USE_CUDA)
message(STATUS "")
message(STATUS "${Green}Cuda:${ColourReset}")
@@ -116,13 +125,14 @@ function(anakin_print_statistic)
message(STATUS " `--OpenCL version : ${OpenCL_VERSION}")
endif()
endif()
-
message(STATUS "")
if(USE_GPU_PLACE)
message(STATUS " SELECT_GPU_PLACE : ${USE_GPU_PLACE}")
+ elseif(USE_MLU_PLACE)
+ message(STATUS " SELECT_MLU_PLACE : ${USE_MLU_PLACE}")
elseif(USE_X86_PLACE)
- message(STATUS " SELECT_X86_PLACE : ${USE_X86_PLACE}")
+ message(STATUS " SELECT_X86_PLACE : ${USE_X86_PLACE}")
elseif(USE_ARM_PLACE)
message(STATUS " USE_ARM_PLACE : ${USE_ARM_PLACE}")
if(TARGET_ANDROID)
diff --git a/cmake/utils.cmake b/cmake/utils.cmake
index ee4c54170..8b46f91bf 100644
--- a/cmake/utils.cmake
+++ b/cmake/utils.cmake
@@ -15,7 +15,7 @@
# ----------------------------------------------------------------------------
# section: help to search src and include files
# ----------------------------------------------------------------------------
-# fetch files(.cc .cpp .cu .c or .h .hpp etc.) in dir(search_dir)
+# fetch files(.cc .cpp .cu .c or .h .hpp etc.) in dir(search_dir)
# and save to parent scope var outputs
function(anakin_fetch_files_with_suffix search_dir suffix outputs)
exec_program(ls ${search_dir}
@@ -39,11 +39,11 @@ endfunction()
# recursively fetch files
function(anakin_fetch_files_with_suffix_recursively search_dir suffix outputs)
- file(GLOB_RECURSE ${outputs} ${search_dir} "*.${suffix}")
+ file(GLOB_RECURSE ${outputs} ${search_dir} "*.${suffix}")
set(${outputs} ${${outputs}} PARENT_SCOPE)
endfunction()
-# recursively fetch include dir
+# recursively fetch include dir
function(anakin_fetch_include_recursively root_dir)
if (IS_DIRECTORY ${root_dir})
#message(STATUS "include dir: " ${Magenta}${root_dir}${ColourReset})
@@ -52,7 +52,7 @@ function(anakin_fetch_include_recursively root_dir)
file(GLOB ALL_SUB RELATIVE ${root_dir} ${root_dir}/*)
foreach(sub ${ALL_SUB})
- if (IS_DIRECTORY ${root_dir}/${sub})
+ if (IS_DIRECTORY ${root_dir}/${sub})
anakin_fetch_include_recursively(${root_dir}/${sub})
endif()
endforeach()
@@ -95,11 +95,11 @@ macro(anakin_check_compiler_flag LANG FLAG RESULT)
set(_fname "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.cu")
if("${CMAKE_CXX_FLAGS} ${FLAG} " MATCHES "-Werror " OR "${CMAKE_CXX_FLAGS} ${FLAG} " MATCHES "-Werror=unknown-pragmas ")
FILE(WRITE "${_fname}" ""
- "extern \"C\" __global__ void test() {}\n"
+ "extern \"C\" __global__ void test() {}\n"
"int main() { return 0; }\n")
else()
FILE(WRITE "${_fname}" "#pragma\n"
- "extern \"C\" __global__ void test() {}\n"
+ "extern \"C\" __global__ void test() {}\n"
"int main() { return 0; }\n")
endif()
else()
@@ -132,8 +132,8 @@ macro(anakin_check_compiler_flag LANG FLAG RESULT)
MESSAGE(STATUS "Testing ${RESULT}")
EXEC_PROGRAM(nvcc
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/
- ARGS "${FLAG}" "${_fname}"
- OUTPUT_VARIABLE OUTPUT
+ ARGS "${FLAG}" "${_fname}"
+ OUTPUT_VARIABLE OUTPUT
RETURN_VALUE RET_VALUE)
if(NOT ${RET_VALUE})
SET(${RESULT} 1 CACHE INTERNAL "Test ${RESULT}")
@@ -163,7 +163,7 @@ macro(anakin_check_flag_support lang flag varname)
else()
set(_lang ${lang})
endif()
-
+
string(TOUPPER "${flag}" ${varname})
string(REGEX REPLACE "^(/|-)" "HAVE_${_lang}_" ${varname} "${${varname}}")
string(REGEX REPLACE " --|-|=| |\\." "_" ${varname} "${${varname}}")
@@ -207,7 +207,7 @@ macro(anakin_option variable description value)
if(__condition STREQUAL "")
set(__condition 2 GREATER 1)
endif()
-
+
if(${__condition})
if(__value MATCHES ";")
if(${__value})
@@ -240,74 +240,13 @@ function(anakin_generate_kernel anakin_root_dir)
ARGS " ${anakin_root_dir}"
OUTPUT_VARIABLE OUTPUT
RETURN_VALUE VALUE)
- if(NOT VALUE)
+ if(NOT VALUE)
message(STATUS "generate kernel files ${Green}${OUTPUT}${ColourReset} successfully.")
else()
message(FATAL_ERROR "anakin_generate_kernel\npath: ${kerel_generate_script_path}\nscript: generate.sh ")
endif()
endfunction()
-
-# ----------------------------------------------------------------------------
-# section: generate the protobuf .h and .cpp files.
-# ----------------------------------------------------------------------------
-function(anakin_gen_pb proto_src_path)
- set(__working_dir ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/PROTO_TEMP/)
- foreach(__proto_file ${ARGN})
- exec_program(${PROTOBUF_PROTOC_EXECUTABLE} ${__working_dir} ARGS " -I=${proto_src_path} --cpp_out=. ${__proto_file}"
- OUTPUT_VARIABLE OUTPUT RETURN_VALUE VALUE)
- if(NOT VALUE)
- anakin_fetch_files_with_suffix(${__working_dir} "h" PROTO_GENERATE_H)
- # get *.cpp or *.cc
- anakin_fetch_files_with_suffix(${__working_dir} "c*" PROTO_GENERATE_C)
- foreach(__include_file ${PROTO_GENERATE_H})
- exec_program(mv ARGS ${__include_file} ${proto_src_path}
- OUTPUT_VARIABLE __out RETURN_VALUE __value)
- endforeach()
- foreach(__src_file ${PROTO_GENERATE_C})
- if(POLICY CMP0007)
- cmake_policy(PUSH)
- cmake_policy(SET CMP0007 NEW)
- endif()
- string(REPLACE "." ";" SRC_LIST ${__src_file})
- list(GET SRC_LIST -1 __src_file_name_suffix)
- list(GET SRC_LIST -3 __src_file_name)
-
- string(REPLACE "/" ";" SRC_LIST_PATH ${__src_file_name})
- list(GET SRC_LIST_PATH -1 __pure_src_file_name)
-
- if(__src_file_name_suffix EQUAL "cpp")
- set(__full_src_filename "${__pure_src_file_name}.pb.cpp")
- else()
- set(__full_src_filename "${__pure_src_file_name}.pb.cc")
- endif()
- exec_program(mv ARGS " ${__working_dir}${__full_src_filename} ${proto_src_path}/${__pure_src_file_name}.pb.cpp"
- OUTPUT_VARIABLE __out
- RETURN_VALUE __value)
- if(POLICY CMP0007)
- cmake_policy(POP)
- endif()
- endforeach()
- else()
- message(FATAL_ERROR "anakin_gen_bp: ${__file} \n error msg: ${OUTPUT}")
- endif()
- endforeach()
-endfunction()
-
-function(anakin_protos_processing)
- set(PROTO_SRC_PATH ${ANAKIN_MODEL_PARSER}/proto)
- set(SERVICE_API_SRC_PATH ${ANAKIN_SERVICE}/api)
-
- set(__working_dir ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/PROTO_TEMP/)
-
- anakin_fetch_files_with_suffix(${PROTO_SRC_PATH} "proto" PROTO_SRC_FILES)
- anakin_fetch_files_with_suffix(${SERVICE_API_SRC_PATH} "proto" SERVICE_API_PROTO_SRC_FILES)
- anakin_gen_pb(${PROTO_SRC_PATH} ${PROTO_SRC_FILES})
- if(BUILD_RPC)
- anakin_gen_pb(${SERVICE_API_SRC_PATH} ${SERVICE_API_PROTO_SRC_FILES})
- endif()
-endfunction()
-
# ----------------------------------------------------------------------------
# section: Provides macro for an anakin warning diasable
# ----------------------------------------------------------------------------
@@ -326,7 +265,7 @@ macro(anakin_disable_warnings)
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANGXX)
foreach(var ${__flag_vars})
- string(REPLACE " " ";" __list_flag ${${var}})
+ string(REPLACE " " ";" __list_flag ${${var}})
foreach(warning ${__list_flag})
if(NOT warning MATCHES "^-Wno-")
if((warning MATCHES "^-W") AND (NOT warning STREQUAL "-W"))
@@ -349,7 +288,7 @@ endmacro()
# ----------------------------------------------------------------------------
macro(anakin_get_file_name path file_name)
string(REPLACE "/" ";" split_code_list ${${path}})
- list(GET split_code_list -1 real_code_with_suffix)
+ list(GET split_code_list -1 real_code_with_suffix)
string(REPLACE "." ";" split_code_list ${real_code_with_suffix})
list(GET split_code_list 0 real_code_name)
set(${file_name} ${real_code_name})
diff --git a/examples/anakin/anakin_helper.h b/examples/anakin/anakin_helper.h
index 2dd791956..a60289e12 100644
--- a/examples/anakin/anakin_helper.h
+++ b/examples/anakin/anakin_helper.h
@@ -27,10 +27,10 @@ class AKAutoChoose {
AKAutoChoose(std::string ak_so_dir,std::string ak_so_path): _ak_so_dir(ak_so_dir),_ak_so_path(ak_so_path) {
}
- AnakinRunerInterface* get_ak_instance_static(std::string device_type, int device_num){
+ AnakinRunerInterface* get_ak_instance_static(const std::string& device_type, int device_num){
return get_anakinrun_instance(device_type.c_str(),device_num);
}
- AnakinRunerInterface* get_ak_instance(std::string device_type, int device_num) {
+ AnakinRunerInterface* get_ak_instance(const std::string& device_type, int device_num) {
if (device_type == "X86") {
std::string this_cpu_arch = _cpu_helper.get_cpu_arch();
//FIXME:choose real path
diff --git a/examples/anakin/build.sh b/examples/anakin/build.sh
index 41763133c..ee7812ce1 100644
--- a/examples/anakin/build.sh
+++ b/examples/anakin/build.sh
@@ -2,6 +2,6 @@
DEBUG_FLAG="-std=c++11 -g -I../../framework/c_api/ -I./ -I../../build/ -ldl -Wno-narrowing "
ORI_FAST_FLAG="-std=c++11 -Ofast -ffast-math -I../../framework/c_api/ -I./ -ldl -Wno-narrowing "
STATIC_FAST_FLAG="-std=c++11 -Ofast -ffast-math -I../../output -I./ -ldl -Wno-narrowing -I../../output/framework/c_api/"
-FAST_FLAG="-std=c++11 -g -static-libstdc++ --sysroot=/opt/compiler/gcc-4.8.2/ -Wl,-rpath,/opt/compiler/gcc-4.8.2/lib64/ -Wl,-dynamic-linker,/opt/compiler/gcc-4.8.2/lib64/ld-linux-x86-64.so.2 -Ofast -ffast-math -I../../output/framework/c_api/ -I./ -ldl -Wno-narrowing"
+FAST_FLAG="-std=c++11 -g -static-libstdc++ --sysroot=/opt/compiler/gcc-4.8.2/ -Wl,-rpath,/opt/compiler/gcc-4.8.2/lib64/ -Wl,-dynamic-linker,/opt/compiler/gcc-4.8.2/lib64/ld-linux-x86-64.so.2 -Ofast -ffast-math -I../../output/framework/c_api/ -I./ -I../../framework/c_api/ -ldl -Wno-narrowing "
g++ example.cpp -o example $FAST_FLAG
-g++ map_rnn.cpp -o map_rnn $FAST_FLAG
\ No newline at end of file
+g++ map_rnn.cpp -o map_rnn ${FAST_FLAG}
\ No newline at end of file
diff --git a/examples/anakin/map_rnn.cpp b/examples/anakin/map_rnn.cpp
index cd1e46c36..1a269170e 100644
--- a/examples/anakin/map_rnn.cpp
+++ b/examples/anakin/map_rnn.cpp
@@ -1,5 +1,6 @@
#include "anakin_helper.h"
#include
+bool g_print_data=false;
class Data {
public:
Data(std::string file_name, int batch_size) :
@@ -197,19 +198,21 @@ class AKRNNExampleX86 {
input_fea->set_dev_lod_offset(lod);
_anakin_obj->prediction();
-#ifdef PRINT_RESULT
- AnakinRunerTensorInterface* output_0 = _anakin_obj->get_output_tensor(0);
- for (int seq_id = 0; seq_id < seq_offset.size() - 1; seq_id++) {
- int seq_len = seq_offset[seq_id + 1] - seq_offset[seq_id];
- int seq_start = seq_offset[seq_id];
- for (int i = 0; i < seq_len - 1; i++) {
- printf("%f|", static_cast(output_0->get_host_data())[seq_start + i]);
- }
+ if(g_print_data){
+ AnakinRunerTensorInterface* output_0 = _anakin_obj->get_output_tensor(0);
+ for (int seq_id = 0; seq_id < seq_offset.size() - 1; seq_id++) {
+ int seq_len = seq_offset[seq_id + 1] - seq_offset[seq_id];
+ int seq_start = seq_offset[seq_id];
+
+ for (int i = 0; i < seq_len - 1; i++) {
+ printf("%f|", static_cast(output_0->get_host_data())[seq_start + i]);
+ }
- printf("%f\n", static_cast(output_0->get_host_data())[seq_start + seq_len - 1]);
+ printf("%f\n", static_cast(output_0->get_host_data())[seq_start + seq_len - 1]);
+ }
}
-#endif
+
// output_0->copy_data_dev_2_host();
// float* out_ptr = static_cast(output_0->get_host_data());
@@ -249,9 +252,23 @@ int main(int argc, const char** argv) {
}
if (argc > 5) {
- so_path = argv[5];
+ g_print_data=atoi(argv[5]);
+ }
+
+ if (argc > 6) {
+ so_dir=argv[6];
+ }
+
+ if(argc > 7){
+ so_path = argv[7];
+ }
+
+ if(argc<=7){
+ AKRNNExampleX86 ak_run(so_dir, model_path, max_batch);
+ ak_run.run(data_path,batch_size);
+ }else {
+ AKRNNExampleX86 ak_run(so_dir, so_path, model_path, max_batch);
+ ak_run.run(data_path,batch_size);
}
- AKRNNExampleX86 ak_run(so_dir, so_path,model_path,max_batch);
- ak_run.run(data_path,batch_size);
}
\ No newline at end of file
diff --git a/examples/arm/classification.cpp b/examples/arm/classification.cpp
deleted file mode 100644
index 27c3ce45d..000000000
--- a/examples/arm/classification.cpp
+++ /dev/null
@@ -1,234 +0,0 @@
-#include "graph_base.h"
-#include "graph.h"
-#include "scheduler.h"
-#include "net.h"
-#include "worker.h"
-#include "tensor_op.h"
-#include "timer.h"
-
-using namespace anakin::saber;
-using namespace anakin::graph;
-using namespace anakin;
-typedef Tensor Tensor4hf;
-
-
-void load_labels(std::string path, std::vector& labels) {
-
- FILE* fp = fopen(path.c_str(), "r");
- if (fp == nullptr) {
- LOG(FATAL) << "load label file failed";
- }
- while (!feof(fp)) {
- char str[1024];
- fgets(str, 1024, fp);
- std::string str_s(str);
-
- if (str_s.length() > 0) {
- for (int i = 0; i < str_s.length(); i++) {
- if (str_s[i] == ' ') {
- std::string strr = str_s.substr(i, str_s.length() - i - 1);
- labels.push_back(strr);
- i = str_s.length();
- }
- }
- }
- }
- fclose(fp);
-}
-
-void print_topk(const float* scores, const int size, const int topk, \
- const std::vector& labels) {
-
- std::vector< std::pair > vec;
- vec.resize(size);
- for (int i = 0; i < size; i++) {
- vec[i] = std::make_pair(scores[i], i);
- }
-
- std::partial_sort(vec.begin(), vec.begin() + topk, vec.end(),
- std::greater< std::pair >());
-
- // print topk and score
- for (int i = 0; i < topk; i++) {
- float score = vec[i].first;
- int index = vec[i].second;
- LOG(INFO) << i <<": " << index << " " << labels[index] << " " << score;
- }
-}
-
-#ifdef USE_OPENCV
-#include "opencv2/opencv.hpp"
-
-using namespace cv;
-
-void fill_tensor_with_cvmat(const Mat& img_in, Tensor4hf& tout, const int num, \
- const int width, const int height, const float* mean, const float* scale) {
- cv::Mat im;
- cv::resize(img_in, im, cv::Size(width, height), 0.f, 0.f);
- float* ptr_data_in = tout.mutable_data();
- int stride = width * height;
- for (int i = 0; i < num; i++) {
- float* ptr_in = ptr_data_in + i * tout.channel() * tout.height() * tout.width();
- for (int r = 0; r < height; r++) {
- for (int c = 0; c < width; c++) {
- ptr_in[r * width + c] = (im.at(r, c)[0] - mean[0]) * scale[0];
- ptr_in[stride + r * width + c] = (im.at(r, c)[1] - mean[1]) * scale[1];
- ptr_in[2 * stride + r * width + c] = (im.at(r, c)[2] - mean[2]) * scale[2];
- }
- }
- }
-}
-#endif
-
-void test_net(const std::string model_file_name, const std::string image_file_name, \
- const std::vector& labels, const int topk, const int threads, \
- const int test_iter) {
-
- int batch_size = 1;
-
- //! create runtime context
- LOG(INFO) << "create runtime context";
- std::shared_ptr> ctx1 = std::make_shared>();
- ctx1->set_run_mode(SABER_POWER_HIGH, threads);
- LOG(INFO) << omp_get_num_threads() << " threads is activated";
-
- //! load model
- LOG(WARNING) << "load anakin model file from " << model_file_name << " ...";
- Graph graph;
- auto status = graph.load(model_file_name);
- if (!status) {
- LOG(FATAL) << " [ERROR] " << status.info();
- }
-
- //! set batch size
- graph.ResetBatchSize("input_0", batch_size);
-
- //! optimize the graph
- LOG(INFO) << "optimize the graph";
- graph.Optimize();
-
- //! get output name
- std::vector& vout_name = graph.get_outs();
- LOG(INFO) << "output size: " << vout_name.size();
-
- //! constructs the executer net
- LOG(INFO) << "create net to execute";
- Net net_executer(graph, ctx1, true);
-
- //! get in
- LOG(INFO) << "get input";
- auto d_tensor_in_p = net_executer.get_in("input_0");
- auto valid_shape_in = d_tensor_in_p->valid_shape();
- for (int i = 0; i < valid_shape_in.size(); i++) {
- LOG(INFO) << "detect input dims[" << i << "]" << valid_shape_in[i];
- }
- Tensor4hf thin(valid_shape_in);
-
- //! feed input image to input tensor
-#ifdef USE_OPENCV
- LOG(INFO) << "loading image " << image_file_name << " ...";
- Mat img = imread(image_file_name, CV_LOAD_IMAGE_COLOR);
- if (img.empty()) {
- LOG(FATAL) << "opencv read image " << image_file_name << " failed";
- }
- //! set your mean value and scale value here
- float mean_mb[3] = {103.94f, 116.78f, 123.68f};
- float scale_mb[3] = {0.017f, 0.017f, 0.017f};
- fill_tensor_with_cvmat(img, thin, batch_size, thin.width(), thin.height(), mean_mb, scale_mb);
-
-#else
- fill_tensor_host_const(thin, 1.f);
-#endif
-
- //! do inference
- Context ctx(0, 0, 0);
- anakin::saber::SaberTimer my_time;
- LOG(INFO) << "run prediction ";
-
- double to = 0;
- double tmin = 1000000;
- double tmax = 0;
- my_time.start(ctx);
- saber::SaberTimer t1;
- for (int i = 0; i < test_iter; i++) {
- d_tensor_in_p->copy_from(thin);
- t1.clear();
- t1.start(ctx);
- net_executer.prediction();
- t1.end(ctx);
- double tdiff = t1.get_average_ms();
- if (tdiff > tmax) {
- tmax = tdiff;
- }
- if (tdiff < tmin) {
- tmin = tdiff;
- }
- to += tdiff;
- }
- my_time.end(ctx);
-
-
- LOG(INFO) << model_file_name << " batch_size " << batch_size << \
- " average time " << to / test_iter << \
- ", min time: " << tmin << "ms, max time: " << tmax << " ms";
-
- //! get output
- //! fixme get output
- //std::vector vout = net_executer.get_out_list();
- std::vector vout;
- for (auto& it : vout_name) {
- vout.push_back(net_executer.get_out(it));
- }
- Tensor4hf* tensor_out = vout[0];
- LOG(INFO) << "output size: " << vout.size();
-
-#if 0 //print output tensor data
- LOG(INFO) << "extract data: size: " << tensor_out->valid_size() << \
- ", width=" << tensor_out->width() << ", height=" << tensor_out->height();
- const float* ptr_out = tensor_out->data();
- for (int i = 0; i < tensor_out->valid_size(); i++) {
- printf("%0.4f ", ptr_out[i]);
- if ((i + 1) % 7 == 0) {
- printf("\n");
- }
- }
- printf("\n");
-#endif
- print_topk(tensor_out->data(), tensor_out->valid_size(), topk, labels);
-}
-
-int main(int argc, char** argv){
-
- LOG(INFO) << "initialized the device";
- Env::env_init();
-
- if (argc < 4) {
- LOG(ERROR) << "usage: " << argv[0] << ": model_file label_file image_name [topk] [test_iter] [threads]";
- return -1;
- }
- char* model_file = argv[1];
- char* label_file = argv[2];
- char* image_path = argv[3];
-
- std::vector labels;
- load_labels(label_file, labels);
-
- int topk = 5;
- if (argc > 4) {
- topk = atoi(argv[4]);
- }
-
- int test_iter = 10;
- if (argc > 5) {
- test_iter = atoi(argv[5]);
- }
-
- int threads = 1;
- if (argc > 6) {
- threads = atoi(argv[6]);
- }
-
- test_net(model_file, image_path, labels, topk, threads, test_iter);
- return 0;
-}
-
diff --git a/examples/arm/ssd_detection.cpp b/examples/arm/ssd_detection.cpp
deleted file mode 100644
index 50b02b396..000000000
--- a/examples/arm/ssd_detection.cpp
+++ /dev/null
@@ -1,233 +0,0 @@
-#include "graph_base.h"
-#include "graph.h"
-#include "scheduler.h"
-#include "net.h"
-#include "worker.h"
-#include "tensor_op.h"
-#include "timer.h"
-
-using namespace anakin::saber;
-using namespace anakin::graph;
-using namespace anakin;
-typedef Tensor Tensor4hf;
-
-#ifdef USE_OPENCV
-#include "opencv2/opencv.hpp"
-
-using namespace cv;
-
-struct Object{
- int batch_id;
- cv::Rect rec;
- int class_id;
- float prob;
-};
-
-const char* class_names[] = {"background",
- "aeroplane", "bicycle", "bird", "boat",
- "bottle", "bus", "car", "cat", "chair",
- "cow", "diningtable", "dog", "horse",
- "motorbike", "person", "pottedplant",
- "sheep", "sofa", "train", "tvmonitor"};
-
-void fill_tensor_with_cvmat(const Mat& img_in, Tensor4hf& tout, const int num, \
- const int width, const int height, const float* mean, const float* scale) {
- cv::Mat im;
- cv::resize(img_in, im, cv::Size(width, height), 0.f, 0.f);
- float* ptr_data_in = tout.mutable_data();
- int stride = width * height;
- for (int i = 0; i < num; i++) {
- float* ptr_in = ptr_data_in + i * tout.channel() * tout.height() * tout.width();
- for (int r = 0; r < height; r++) {
- for (int c = 0; c < width; c++) {
- ptr_in[r * width + c] = (im.at(r, c)[0] - mean[0]) * scale[0];
- ptr_in[stride + r * width + c] = (im.at(r, c)[1] - mean[1]) * scale[1];
- ptr_in[2 * stride + r * width + c] = (im.at(r, c)[2] - mean[2]) * scale[2];
- }
- }
- }
-}
-
-void detect_object(Tensor4hf& tout, const float thresh, Mat& image) {
- std::vector