if(CMAKE_TOOLCHAIN_FILE)
set(LIBRARY_OUTPUT_PATH_ROOT ${CMAKE_BINARY_DIR} CACHE PATH "root for library output, set this to change where android libs are compiled to")
# get absolute path, but get_filename_component ABSOLUTE only refer with source dir, so find_file here :(
get_filename_component(CMAKE_TOOLCHAIN_FILE_NAME ${CMAKE_TOOLCHAIN_FILE} NAME)
find_file(CMAKE_TOOLCHAIN_FILE ${CMAKE_TOOLCHAIN_FILE_NAME} PATHS ${CMAKE_SOURCE_DIR} NO_DEFAULT_PATH)
message(STATUS "CMAKE_TOOLCHAIN_FILE = ${CMAKE_TOOLCHAIN_FILE}")
endif()
if(NOT DEFINED CMAKE_INSTALL_PREFIX)
set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/install" CACHE PATH "Installation Directory")
endif()
message(STATUS "CMAKE_INSTALL_PREFIX = ${CMAKE_INSTALL_PREFIX}")
if(NOT DEFINED NCNN_VERSION)
string(TIMESTAMP NCNN_VERSION "%Y%m%d")
endif()
set(NCNN_VERSION_MAJOR 1)
set(NCNN_VERSION_MINOR 0)
set(NCNN_VERSION_PATCH ${NCNN_VERSION})
set(NCNN_VERSION_STRING ${NCNN_VERSION_MAJOR}.${NCNN_VERSION_MINOR}.${NCNN_VERSION_PATCH})
message(STATUS "NCNN_VERSION_STRING = ${NCNN_VERSION_STRING}")
cmake_minimum_required(VERSION 2.8.12)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE release CACHE STRING "Choose the type of build" FORCE)
endif()
if(NOT CMAKE_VERSION VERSION_LESS "3.15")
# enable CMAKE_MSVC_RUNTIME_LIBRARY
cmake_policy(SET CMP0091 NEW)
endif()
if(POLICY CMP0025)
# reference from https://cmake.org/cmake/help/latest/policy/CMP0025.html
cmake_policy(SET CMP0025 NEW)
endif()
project(ncnn)
if(MSVC AND NOT CMAKE_VERSION VERSION_LESS "3.15")
option(NCNN_BUILD_WITH_STATIC_CRT "Enables use of statically linked CRT for statically linked ncnn" OFF)
if(NCNN_BUILD_WITH_STATIC_CRT)
# cmake before version 3.15 not work
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
endif()
endif()
option(NCNN_SHARED_LIB "shared library support" OFF)
option(NCNN_ENABLE_LTO "enable link-time optimization" OFF)
option(NCNN_OPENMP "openmp support" ON)
option(NCNN_STDIO "load model from external file" ON)
option(NCNN_STRING "plain and verbose string" ON)
option(NCNN_INSTALL_SDK "install ncnn library and headers" ON)
option(NCNN_SIMPLEOCV "minimal opencv structure emulation" OFF)
option(NCNN_SIMPLEOMP "minimal openmp runtime emulation" OFF)
option(NCNN_SIMPLESTL "minimal cpp stl structure emulation" OFF)
option(NCNN_THREADS "build with threads" ON)
option(NCNN_BENCHMARK "print benchmark information for every layer" OFF)
option(NCNN_C_API "build with C api" ON)
option(NCNN_PLATFORM_API "build with platform api candy" ON)
option(NCNN_PIXEL "convert and resize from/to image pixel" ON)
option(NCNN_PIXEL_ROTATE "rotate image pixel orientation" ON)
option(NCNN_PIXEL_AFFINE "warp affine image pixel" ON)
option(NCNN_PIXEL_DRAWING "draw basic figure and text" ON)
option(NCNN_CMAKE_VERBOSE "print verbose cmake messages" OFF)
option(NCNN_VULKAN "vulkan compute support" OFF)
option(NCNN_SYSTEM_GLSLANG "use system glslang library" OFF)
option(NCNN_RUNTIME_CPU "runtime dispatch cpu routines" ON)
option(NCNN_DISABLE_PIC "disable position-independent code" OFF)
option(NCNN_BUILD_TESTS "build tests" OFF)
option(NCNN_COVERAGE "build for coverage" OFF)
option(NCNN_ASAN "build for address sanitizer" OFF)
option(NCNN_BUILD_BENCHMARK "build benchmark" ON)
option(NCNN_PYTHON "build python api" OFF)
option(NCNN_INT8 "int8 inference" ON)
option(NCNN_BF16 "bf16 inference" ON)
option(NCNN_FORCE_INLINE "force inline some function" ON)
if(ANDROID OR IOS OR NCNN_SIMPLESTL OR CMAKE_CROSSCOMPILING)
option(NCNN_DISABLE_RTTI "disable rtti" ON)
option(NCNN_BUILD_TOOLS "build tools" OFF)
option(NCNN_BUILD_EXAMPLES "build examples" OFF)
else()
option(NCNN_DISABLE_RTTI "disable rtti" OFF)
option(NCNN_BUILD_TOOLS "build tools" ON)
option(NCNN_BUILD_EXAMPLES "build examples" ON)
endif()
if(ANDROID OR IOS OR NCNN_SIMPLESTL)
option(NCNN_DISABLE_EXCEPTION "disable exception" ON)
else()
option(NCNN_DISABLE_EXCEPTION "disable exception" OFF)
endif()
if(NCNN_SHARED_LIB)
if(NCNN_BUILD_TESTS)
message(WARNING "NCNN_SHARED_LIB must be OFF to build tests! NCNN_BUILD_TESTS will be turned off.")
set(NCNN_BUILD_TESTS OFF)
endif()
if(NCNN_ENABLE_LTO)
# enable global link time optimization
cmake_policy(SET CMP0069 NEW)
set(CMAKE_POLICY_DEFAULT_CMP0069 NEW)
include(CheckIPOSupported)
check_ipo_supported(RESULT ipo_supported OUTPUT ipo_supported_output)
if(ipo_supported)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
else()
message(WARNING "IPO is not supported: ${ipo_supported_output}")
set(NCNN_ENABLE_LTO OFF)
endif()
endif()
endif()
if(NOT NCNN_STDIO OR NOT NCNN_STRING)
if(NCNN_BUILD_TOOLS)
message(WARNING "NCNN_STDIO or NCNN_STRING disabled, NCNN_BUILD_TOOLS will be turned off.")
set(NCNN_BUILD_TOOLS OFF)
endif()
if(NCNN_BUILD_EXAMPLES)
message(WARNING "NCNN_STDIO or NCNN_STRING disabled, NCNN_BUILD_EXAMPLES will be turned off.")
set(NCNN_BUILD_EXAMPLES OFF)
endif()
if(NCNN_BUILD_BENCHMARK)
message(WARNING "NCNN_STDIO or NCNN_STRING disabled, NCNN_BUILD_BENCHMARK will be turned off.")
set(NCNN_BUILD_BENCHMARK OFF)
endif()
if(NCNN_BUILD_TESTS)
message(WARNING "NCNN_STDIO or NCNN_STRING disabled, NCNN_BUILD_TESTS will be turned off.")
set(NCNN_BUILD_TESTS OFF)
endif()
endif()
##############################################
include(CheckCXXCompilerFlag)
check_cxx_source_compiles("int main() { int a = 0; asm volatile(\"\" : \"=r\"(a) : \"0\"(a) : \"memory\"); return 0; }" NCNN_COMPILER_SUPPORT_GNU_INLINE_ASM)
if(NCNN_COMPILER_SUPPORT_GNU_INLINE_ASM)
option(NCNN_GNU_INLINE_ASM "optimize platform with gnu style inline assembly" ON)
else()
message(WARNING "The compiler does not support gnu style inline assembly. NCNN_GNU_INLINE_ASM will be OFF.")
endif()
if((IOS AND CMAKE_OSX_ARCHITECTURES MATCHES "arm")
OR (APPLE AND CMAKE_OSX_ARCHITECTURES MATCHES "arm64")
OR (CMAKE_SYSTEM_PROCESSOR MATCHES "^(arm|aarch64)")
OR (CMAKE_CXX_COMPILER_ARCHITECTURE_ID MATCHES "ARM64")
OR ((CMAKE_CXX_COMPILER_ID MATCHES "MSVC" OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND CMAKE_CXX_SIMULATE_ID MATCHES "MSVC" AND CMAKE_CXX_COMPILER_FRONTEND_VARIANT MATCHES "MSVC")) AND (${CMAKE_GENERATOR_PLATFORM} MATCHES "^(arm|arm64)")))
set(NCNN_TARGET_ARCH arm)
if(CMAKE_SIZEOF_VOID_P EQUAL 4 AND NOT (CMAKE_CXX_COMPILER_ID MATCHES "MSVC" OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND CMAKE_CXX_SIMULATE_ID MATCHES "MSVC" AND CMAKE_CXX_COMPILER_FRONTEND_VARIANT MATCHES "MSVC")))
set(CMAKE_REQUIRED_FLAGS "-mfpu=neon-vfpv4")
check_cxx_source_compiles("#include <arm_neon.h>\nint main() { float32x4_t _a; float16x4_t _s = vcvt_f16_f32(_a); return 0; }" NCNN_COMPILER_SUPPORT_ARM_VFPV4)
if(NOT NCNN_COMPILER_SUPPORT_ARM_VFPV4)
set(CMAKE_REQUIRED_FLAGS "-mfpu=neon-vfpv4 -mfp16-format=ieee")
check_cxx_source_compiles("#include <arm_neon.h>\nint main() { float32x4_t _a; float16x4_t _s = vcvt_f16_f32(_a); return 0; }" NCNN_COMPILER_SUPPORT_ARM_VFPV4_FP16)
endif()
unset(CMAKE_REQUIRED_FLAGS)
if(NCNN_COMPILER_SUPPORT_ARM_VFPV4 OR NCNN_COMPILER_SUPPORT_ARM_VFPV4_FP16)
option(NCNN_VFPV4 "optimize armv7 platform with vfpv4" ON)
else()
message(WARNING "The compiler does not support arm vfpv4. NCNN_VFPV4 will be OFF.")
endif()
endif()
if(CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT (CMAKE_CXX_COMPILER_ID MATCHES "MSVC" OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND CMAKE_CXX_SIMULATE_ID MATCHES "MSVC" AND CMAKE_CXX_COMPILER_FRONTEND_VARIANT MATCHES "MSVC")))
set(CMAKE_REQUIRED_FLAGS "-march=armv8-a")
check_cxx_source_compiles("#include <arm_neon.h>\nint main() { float32x4_t _a; float16x4_t _s = vcvt_f16_f32(_a); return 0;
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
该项目是一个基于C++的ncnn神经网络库设计源码,共计包含3283个文件,涵盖1134个C++源代码文件、875个头文件、583个Python脚本、393个编译文件、68个CMake配置文件、61个Markdown文件、59个YAML配置文件、38个参数文件、22个文本文件、9个输入文件。此外,该项目还支持C和Shell语言。该库旨在提供高效、跨语言的神经网络处理能力,适用于多种开发环境和平台。
资源推荐
资源详情
资源评论
收起资源包目录
基于C++的ncnn神经网络库设计源码及跨语言支持 (2000个子文件)
mat_pixel_rotate.cpp 229KB
onnx2ncnn.cpp 207KB
gpu.cpp 179KB
gemm_arm.cpp 172KB
command.cpp 135KB
gemm_arm_asimdhp.cpp 99KB
ir.cpp 91KB
mat_pixel.cpp 87KB
ncnnoptimize.cpp 84KB
mxnet2ncnn.cpp 81KB
net.cpp 79KB
mat_pixel_affine.cpp 78KB
allocator.cpp 73KB
requantize_loongarch.cpp 71KB
requantize_mips.cpp 70KB
fuse_multiheadattention.cpp 69KB
requantize_arm.cpp 68KB
cpu.cpp 67KB
innerproduct_arm.cpp 64KB
dequantize_arm.cpp 60KB
packing_riscv.cpp 60KB
innerproduct_loongarch.cpp 59KB
innerproduct_mips.cpp 58KB
mlir2ncnn.cpp 58KB
convolution_arm.cpp 58KB
gru_arm.cpp 57KB
packing_arm.cpp 55KB
eltwise_arm_asimdhp.cpp 55KB
ncnn2table.cpp 55KB
convolutiondepthwise_arm.cpp 54KB
dequantize_arm_asimdhp.cpp 53KB
deconvolution_arm_asimdhp.cpp 51KB
softmax_arm.cpp 50KB
eltwise_arm.cpp 47KB
caffe2ncnn.cpp 45KB
c_api.cpp 43KB
F_interpolate.cpp 42KB
binaryop_riscv.cpp 42KB
deconvolution_arm.cpp 41KB
gru_arm_asimdhp.cpp 41KB
mat.cpp 40KB
softmax_arm_asimdhp.cpp 40KB
lstm_arm_asimdhp.cpp 40KB
binaryop_arm.cpp 39KB
mat_pixel_drawing.cpp 39KB
interp_riscv.cpp 38KB
lstm_arm.cpp 38KB
convolution_loongarch.cpp 37KB
convolution_mips.cpp 37KB
reduction.cpp 36KB
quantize_arm.cpp 35KB
pass_level2.cpp 35KB
gru_riscv.cpp 34KB
dequantize_mips.cpp 32KB
darknet2ncnn.cpp 32KB
dequantize_loongarch.cpp 32KB
innerproduct_riscv.cpp 32KB
convolutiondepthwise_loongarch.cpp 32KB
convolutiondepthwise_mips.cpp 32KB
deconvolutiondepthwise_riscv.cpp 31KB
quantize_arm_asimdhp.cpp 31KB
pooling_riscv.cpp 31KB
interp_arm_asimdhp.cpp 31KB
innerproduct_arm_asimdhp.cpp 31KB
concat_arm.cpp 31KB
slice_arm.cpp 31KB
rnn_arm.cpp 29KB
rnn_arm_asimdhp.cpp 29KB
simpleomp.cpp 29KB
interp_arm.cpp 29KB
pixelshuffle_arm.cpp 28KB
convolution1d_riscv.cpp 28KB
pooling_arm_asimdhp.cpp 28KB
fuse_dynamic_adaptive_pool.cpp 27KB
shufflechannel_arm.cpp 27KB
padding_arm.cpp 26KB
reshape_arm.cpp 26KB
crop_arm.cpp 26KB
pooling_arm.cpp 25KB
fuse_expression.cpp 25KB
convolution_arm_asimdhp.cpp 25KB
F_local_response_norm.cpp 24KB
deconvolutiondepthwise_arm_asimdhp.cpp 23KB
deconvolutiondepthwise_arm.cpp 23KB
binaryop_arm_asimdhp.cpp 23KB
padding_riscv.cpp 22KB
gemm_arm_vfpv4.cpp 22KB
convolutiondepthwise_arm_asimdhp.cpp 22KB
flatten_arm.cpp 21KB
convolutiondepthwise.cpp 21KB
binaryop_loongarch.cpp 20KB
nn_MultiheadAttention.cpp 20KB
binaryop_mips.cpp 20KB
packing_mips.cpp 19KB
unaryop_riscv.cpp 19KB
quantize_loongarch.cpp 19KB
packing_loongarch.cpp 19KB
quantize_mips.cpp 19KB
relu_arm.cpp 18KB
ncnn2int8.cpp 18KB
共 2000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
资源评论
csbysj2020
- 粉丝: 2403
- 资源: 5445
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功