Skip to content

Commit

Permalink
Merge branch 'v1.3.0_beta'
Browse files Browse the repository at this point in the history
  • Loading branch information
jianfeifeng committed Apr 15, 2022
2 parents 2c022c5 + a9fb901 commit c3eb7a2
Show file tree
Hide file tree
Showing 1,740 changed files with 202,072 additions and 24,795 deletions.
7 changes: 5 additions & 2 deletions .Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -771,8 +771,11 @@ WARN_LOGFILE =
# spaces. See also FILE_PATTERNS and EXTENSION_MAPPING
# Note: If this tag is empty the current directory is searched.

INPUT = ./inference/engine/api ./inference/flow/include/flow.h \
./common/uni/include/task.h ./inference/flow/src/flow.proto
INPUT = ./inference/engine/api/c \
./inference/engine/api/java \
./inference/flow/include/flow.h ./common/uni/include/task.h ./inference/flow/src/flow.proto \
./training/api/training/api/API.h \
./training/demos/common/training.h

# This tag can be used to specify the character encoding of the source files
# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ kit/Android/SimpleImageClassification/app/src/main/java
kit/iOS/SimpleImgClassfication/libbolt
kit/Android/Semantics/app/src/main/java
kit/Android/Semantics/app/src/main/assets/
kit/Android
kit/iOS


final_combinations.txt
Expand Down
33 changes: 31 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ if (NOT "$ENV{JNI_ROOT}" STREQUAL "")
set(USE_JNI ON)
endif(JNI_FOUND)
endif ()
if (USE_SECURE_C)
find_package(SecureC)
endif ()
if (BUILD_TEST)
find_package(jpeg)
if (EXISTS ${OpenCV_CMAKE_PATH})
Expand All @@ -33,7 +36,7 @@ if (BUILD_TEST)
endif (BUILD_TEST)

add_subdirectory(common)
if (USE_CAFFE OR USE_ONNX OR USE_TFLITE OR USE_TENSORFLOW)
if (USE_CAFFE OR USE_ONNX OR USE_TFLITE OR USE_TENSORFLOW OR USE_MINDSPORE)
add_subdirectory(model_tools)
endif()
add_subdirectory(compute)
Expand All @@ -45,6 +48,13 @@ message(STATUS "CXXFLAGS: ${CMAKE_CXX_FLAGS}")
add_custom_target(bolt_library ALL
COMMAND bash ./scripts/build_light_bolt.sh ${CMAKE_SYSTEM_NAME} ${CMAKE_CXX_COMPILER} ${CMAKE_AR} ${CMAKE_STRIP} ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_OUTPUT_EXTENSION} ${CMAKE_SHARED_LIBRARY_PREFIX} ${CMAKE_SHARED_LIBRARY_SUFFIX} ${CMAKE_STATIC_LIBRARY_PREFIX} ${CMAKE_STATIC_LIBRARY_SUFFIX} ${CMAKE_BINARY_DIR}
WORKING_DIRECTORY ${BOLT_ROOT})
if (USE_TRAINING)
set(TRAINING_BUILD_C_API ON)
set(TRAINING_BUILD_DEMO ON)
add_subdirectory(training)
add_dependencies(Raul blas_enhance uni)
add_dependencies(Raul blas_enhance_static uni_static)
endif (USE_TRAINING)
add_dependencies(bolt_library engine model_spec tensor image blas_enhance uni)
add_dependencies(bolt_library engine_static model_spec_static tensor_static image_static blas_enhance_static uni_static)

Expand All @@ -70,11 +80,30 @@ endif ()
enable_testing()
find_program (BASH_PROGRAM bash)
if (BASH_PROGRAM AND USE_GENERAL)
file(GLOB CPUINFO_CMAKE_FILE $ENV{BOLT_ROOT}/common/cmakes/cpuinfo.cmake ${BOLT_ROOT}/common/cmakes/cpuinfo.cmake)
include(${CPUINFO_CMAKE_FILE})
set(parameters --host_dir=${CMAKE_INSTALL_PREFIX})
if (ANDROID)
set(parameters ${parameters} -d android --device_dir=/data/local/tmp/uldra)
elseif("${CMAKE_HOST_SYSTEM_PROCESSOR}" STREQUAL "${CMAKE_SYSTEM_PROCESSOR}" AND "${CMAKE_HOST_SYSTEM}" MATCHES "${CMAKE_SYSTEM_NAME}*")
set(parameters ${parameters} -d host)
if ("${CMAKE_HOST_SYSTEM_PROCESSOR}" STREQUAL "aarch64" OR "${CMAKE_HOST_SYSTEM_PROCESSOR}" STREQUAL "armv7")
set(parameters ${parameters} -d host)
elseif (USE_X86)
set(x86_test ${cpuinfo_avx2})
if (USE_INT8)
set(x86_test ${cpuinfo_avx512})
endif ()
if (USE_AVX512_VNNI)
set(x86_test ${cpuinfo_avx512_vnni})
endif()
if (x86_test)
set(parameters ${parameters} -d host)
else ()
set(parameters ${parameters} -d unknown)
endif ()
else ()
set(parameters ${parameters} -d unknown)
endif()
else()
set(parameters ${parameters} -d unknown)
endif()
Expand Down
103 changes: 70 additions & 33 deletions README.md

Large diffs are not rendered by default.

42 changes: 42 additions & 0 deletions SUMMARY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Summary

* [Introduction](README.md)


* [Architechture](docs/ARCHITECTURE.md)


* [Operators](docs/OPERATORS.md)


* [Install](docs/INSTALL.md)


* [Basic Inference Usage](docs/USER_HANDBOOK.md#basic-usage)


* [Basic On-device Training Usage](training/TUTORIAL.md)


* [Advanced Features](docs/USER_HANDBOOK.md#advanced-features)


* [Developer Customization](docs/DEVELOPER.md)


* [How to Reduce GPU Initial Time](docs/REDUCE_GPU_PREPARE_TIME.md)


* [Kit Example](docs/KIT.md)


* [Changelog](docs/CHANGELOG.md)


* [FAQ](docs/FAQ.md)


* [Feedback](docs/FEEDBACK.md)


* [Appendix](docs/IOS_USAGE.md)
22 changes: 22 additions & 0 deletions book.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"plugins": [
"github",
"back-to-top-button",
"page-toc-button",
"insert-logo"
],

"pluginsConfig": {
"github": {
"url": "https://github.com/huawei-noah/bolt"
},
"page-toc-button": {
"maxTocDepth": 1,
"minTocSize": 2
},
"insert-logo":{
"url":"../docs/images/LOGO.PNG",
"style":"background:none;max-height:100px"
}
}
}
24 changes: 24 additions & 0 deletions common/cmakes/FindSecureC.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
find_path(SecureC_INCLUDE_DIR NAMES securec.h HINTS $ENV{SecureC_ROOT}/include ${SecureC_ROOT}/include)

if (USE_DYNAMIC_LIBRARY)
find_library(SecureC_LIBRARY NAMES securec HINTS $ENV{SecureC_ROOT}/lib ${SecureC_ROOT}/lib)
set(SecureC_SHARED_LIBRARY ${SecureC_LIBRARY})
else (USE_DYNAMIC_LIBRARY)
find_library(SecureC_LIBRARY NAMES ${CMAKE_STATIC_LIBRARY_PREFIX}securec${CMAKE_STATIC_LIBRARY_SUFFIX} HINTS $ENV{SecureC_ROOT}/lib ${SecureC_ROOT}/lib)
find_library(SecureC_SHARED_LIBRARY NAMES securec HINTS $ENV{SecureC_ROOT}/lib ${SecureC_ROOT}/lib)
endif (USE_DYNAMIC_LIBRARY)

if (SecureC_INCLUDE_DIR AND SecureC_LIBRARY)
set(SecureC_FOUND true)
endif (SecureC_INCLUDE_DIR AND SecureC_LIBRARY)

if (SecureC_FOUND)
include_directories(${SecureC_INCLUDE_DIR})
message(STATUS "Found securec.h: ${SecureC_INCLUDE_DIR}")
message(STATUS "Found securec: ${SecureC_LIBRARY}")
else (SecureC_FOUND)
message(FATAL_ERROR "
FATAL: can not find securec library in <SecureC_ROOT>/[include|lib] directory,
please set shell environment variable SecureC_ROOT.
")
endif (SecureC_FOUND)
81 changes: 64 additions & 17 deletions common/cmakes/bolt.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ option(USE_CAFFE "set use caffe model as input or not" OFF)
option(USE_ONNX "set use onnx model as input or not" OFF)
option(USE_TFLITE "set use tflite model as input or not" OFF)
option(USE_TENSORFLOW "set use tensorflow model as input or not" OFF)
option(USE_MINDSPORE "set use mindspore model as input or not" OFF)

# blas_enhance tensor
option(USE_GENERAL "set use CPU serial code or not" OFF)
Expand All @@ -26,28 +27,43 @@ option(USE_INT8_WINOGRAD "set use ARM NEON INT8 winograd" ON)
option(USE_OPENMP "set use openmp to run test(tinybert) or not" OFF)

option(USE_LIBRARY_TUNING "set use algorithm tuning or not" OFF)
option(USE_MEM_CHECK "set to use memory check or not" OFF)
option(USE_MODEL_PRINT "set to use model print or not" ON)
option(USE_SECURE_C "set to use Huawei Secure C or not" OFF)

option(USE_TRAINING "set whether to use training or not" OFF)
option(USE_FLOW "set whether to use flow or not" OFF)

option(USE_JNI "set whether to use Java API or not" OFF)

option(BUILD_TEST "set to build unit test or not" OFF)

include(CheckCXXCompilerFlag)

if (USE_TRAINING)
set(ANDROID_TOOLCHAIN_PREFIX "aarch64-linux-android-")
endif(USE_TRAINING)

function (set_policy)
if (POLICY CMP0074)
cmake_policy(SET CMP0074 NEW)
endif()
endfunction(set_policy)

macro (set_c_cxx_flags)
set(COMMON_FLAGS "-W -Wextra -O3 -fPIC")
if (NOT WIN32)
set(COMMON_FLAGS "${COMMON_FLAGS} -fstack-protector-all")
endif()
set(COMMON_FLAGS "-O3 -fPIC -fPIE")
# warning flag can be remove in release version
set(COMMON_FLAGS "${COMMON_FLAGS} -W -Wextra")
set(COMMON_FLAGS "${COMMON_FLAGS} -fstack-protector-all -fstack-protector-strong")
set(COMMON_FLAGS "${COMMON_FLAGS} -Wno-unused-command-line-argument -Wno-unused-parameter")
set(COMMON_FLAGS "${COMMON_FLAGS} -Wno-unused-result -Wno-deprecated-declarations -Wno-unused-variable")

if (USE_OPENMP)
set(COMMON_FLAGS "${COMMON_FLAGS} -D_USE_OPENMP -fopenmp")
CHECK_CXX_COMPILER_FLAG("-static-openmp" COMPILER_SUPPORTS_STATIC_OPENMP)
if (COMPILER_SUPPORTS_STATIC_OPENMP)
set(COMMON_FLAGS "${COMMON_FLAGS} -static-openmp")
endif ()
endif(USE_OPENMP)

if (USE_THREAD_SAFE OR USE_CAFFE OR USE_ONNX OR USE_FLOW)
Expand Down Expand Up @@ -99,27 +115,29 @@ macro (set_c_cxx_flags)
if (USE_INT8)
set(COMMON_FLAGS "${COMMON_FLAGS} -mavx512f")
endif (USE_INT8)
if (USE_AVX512_VNNI)
if (USE_AVX512_VNNI)
set(COMMON_FLAGS "${COMMON_FLAGS} -D_USE_AVX512_VNNI")
endif(USE_AVX512_VNNI)
endif(USE_AVX512_VNNI)
endif(USE_X86)

if (USE_FP32)
set(COMMON_FLAGS "${COMMON_FLAGS} -D_USE_FP32")
endif (USE_FP32)

if (USE_FP16)
set(COMMON_FLAGS "${COMMON_FLAGS} -D_USE_FP16")
if (USE_F16_MIX_PRECISION)
set(COMMON_FLAGS "${COMMON_FLAGS} -D_USE_F16_MIX_PRECISION")
endif (USE_F16_MIX_PRECISION)
endif ()

if (USE_INT8)
set(COMMON_FLAGS "${COMMON_FLAGS} -D_USE_INT8")
endif (USE_INT8)

if (USE_NEON)
set(COMMON_FLAGS "${COMMON_FLAGS} -D_USE_NEON")

if (USE_FP16)
set(COMMON_FLAGS "${COMMON_FLAGS} -D_USE_FP16")
if (USE_F16_MIX_PRECISION)
set(COMMON_FLAGS "${COMMON_FLAGS} -D_USE_F16_MIX_PRECISION")
endif (USE_F16_MIX_PRECISION)
if (USE_INT8)
if (USE_INT8_WINOGRAD)
set(COMMON_FLAGS "${COMMON_FLAGS} -D_USE_INT8_WINOGRAD")
Expand All @@ -137,9 +155,6 @@ macro (set_c_cxx_flags)
endif ()
endif (USE_INT8)
endif (USE_FP16)
if (USE_INT8)
set(COMMON_FLAGS "${COMMON_FLAGS} -D_USE_INT8")
endif ()
endif(USE_NEON)

if (USE_CAFFE)
Expand All @@ -154,6 +169,21 @@ macro (set_c_cxx_flags)
if (USE_TENSORFLOW)
set(COMMON_FLAGS "${COMMON_FLAGS} -D_USE_TENSORFLOW")
endif()
if (USE_MINDSPORE)
set(COMMON_FLAGS "${COMMON_FLAGS} -D_USE_MINDSPORE")
endif()

if (USE_MEM_CHECK)
set(COMMON_FLAGS "${COMMON_FLAGS} -D_USE_MEM_CHECK")
endif()

if (USE_MODEL_PRINT)
set(COMMON_FLAGS "${COMMON_FLAGS} -D_USE_MODEL_PRINT")
endif()

if (USE_SECURE_C)
set(COMMON_FLAGS "${COMMON_FLAGS} -D_USE_SECURE_C")
endif()

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${COMMON_FLAGS} -std=gnu99")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMMON_FLAGS} -std=c++11")
Expand All @@ -168,8 +198,14 @@ endmacro(set_c_cxx_flags)
macro (set_test_c_cxx_flags)
if (NOT USE_DYNAMIC_LIBRARY)
set(COMMON_FLAGS "${COMMON_FLAGS} -static-libstdc++")
if (NOT "${CMAKE_HOST_SYSTEM_PROCESSOR}" STREQUAL "${CMAKE_SYSTEM_PROCESSOR}" AND "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
set(COMMON_FLAGS "${COMMON_FLAGS} -static")
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
set(COMMON_FLAGS "${COMMON_FLAGS} -static-libgcc")
if (NOT "${CMAKE_HOST_SYSTEM_PROCESSOR}" STREQUAL "${CMAKE_SYSTEM_PROCESSOR}")
set(COMMON_FLAGS "${COMMON_FLAGS} -static")
endif()
if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows")
set(COMMON_FLAGS "${COMMON_FLAGS} -static")
endif()
endif()
endif()

Expand Down Expand Up @@ -198,6 +234,7 @@ if(USE_DYNAMIC_LIBRARY)
set(model_tools_onnx_library model_tools_onnx)
set(model_tools_tflite_library model_tools_tflite)
set(model_tools_tensorflow_library model_tools_tensorflow)
set(model_tools_mindspore_library model_tools_mindspore)
set(model_tools_library model_tools)
set(engine_library engine)
set(flow_library flow)
Expand All @@ -213,17 +250,24 @@ else()
set(model_tools_onnx_library model_tools_onnx_static)
set(model_tools_tflite_library model_tools_tflite_static)
set(model_tools_tensorflow_library model_tools_tensorflow_static)
set(model_tools_mindspore_library model_tools_mindspore_static)
set(model_tools_library model_tools_static)
set(engine_library engine_static)
set(flow_library flow_static)
endif()

macro(include_uni)
include_directories(${BOLT_ROOT}/common/uni/include)
if (USE_SECURE_C)
include_directories(${SecureC_ROOT}/include)
endif ()
endmacro()

macro(link_uni name)
target_link_libraries(${name} ${uni_library})
if (USE_SECURE_C)
target_link_libraries(${name} ${SecureC_LIBRARY})
endif ()
endmacro()

macro(include_model_spec)
Expand Down Expand Up @@ -330,7 +374,10 @@ macro(link_model_tools name)
target_link_libraries(${name} ${model_tools_tensorflow_library})
target_link_libraries(${name} ${JSONCPP_LIBRARY})
endif()
if(USE_CAFFE OR USE_ONNX)
if(USE_MINDSPORE)
target_link_libraries(${name} ${model_tools_mindspore_library})
endif()
if(USE_CAFFE OR USE_ONNX OR USE_MINDSPORE)
link_protobuf(${name})
endif()
link_model_spec(${name})
Expand Down
16 changes: 16 additions & 0 deletions common/cmakes/cpuinfo.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
set(CPUINFO "null")
file(GLOB CPUINFO_FILE /proc/cpuinfo)
if (CPUINFO_FILE)
exec_program(cat ARGS ${CPUINFO_FILE} OUTPUT_VARIABLE CPUINFO)
else ()
message(STATUS "can not find /proc/cpuinfo")
endif ()

macro(check_cpuinfo feature)
string(REGEX REPLACE "^.*(${feature}).*$" "\\1" _FEATURE_THERE ${CPUINFO})
string(COMPARE EQUAL "${feature}" "${_FEATURE_THERE}" cpuinfo_${feature})
endmacro()

check_cpuinfo(avx2)
check_cpuinfo(avx512)
check_cpuinfo(avx512_vnni)
Loading

0 comments on commit c3eb7a2

Please sign in to comment.