├── .gitignore ├── .travis.yml ├── CMakeLists.txt ├── CONTRIBUTING.md ├── Info.plist ├── LICENSE.txt ├── README.md ├── benchmark ├── CMakeLists.txt ├── README.md ├── alexnet.param ├── benchncnn.cpp ├── googlenet.param ├── mnasnet.param ├── mobilenet.param ├── mobilenet_ssd.param ├── mobilenet_v2.param ├── mobilenet_yolo.param ├── mobilenet_yolov3.param ├── proxylessnasnet.param ├── resnet18.param ├── shufflenet.param ├── squeezenet.param ├── squeezenet_ssd.param └── vgg16.param ├── build.sh ├── examples ├── CMakeLists.txt ├── fasterrcnn.cpp ├── mobilenetssd.cpp ├── mobilenetv2ssdlite.cpp ├── rfcn.cpp ├── shufflenetv2.cpp ├── squeezencnn │ ├── AndroidManifest.xml │ ├── ant.properties │ ├── assets │ │ ├── squeezenet_v1.1.bin │ │ ├── squeezenet_v1.1.param.bin │ │ └── synset_words.txt │ ├── build.xml │ ├── jni │ │ ├── Android.mk │ │ ├── Application.mk │ │ ├── squeezencnn_jni.cpp │ │ └── squeezenet_v1.1.id.h │ ├── local.properties │ ├── proguard-project.txt │ ├── project.properties │ ├── res │ │ ├── layout │ │ │ └── main.xml │ │ └── values │ │ │ └── strings.xml │ └── src │ │ └── com │ │ └── tencent │ │ └── squeezencnn │ │ ├── MainActivity.java │ │ └── SqueezeNcnn.java ├── squeezenet.cpp ├── squeezenet_v1.1.bin ├── squeezenet_v1.1.caffemodel ├── squeezenet_v1.1.param ├── squeezenet_v1.1.prototxt ├── squeezenetssd.cpp ├── synset_words.txt ├── yolov2.cpp └── yolov3.cpp ├── images ├── 128-ncnn.png ├── 16-ncnn.png ├── 256-ncnn.png ├── 32-ncnn.png └── 64-ncnn.png ├── package.sh ├── src ├── CMakeLists.txt ├── allocator.cpp ├── allocator.h ├── benchmark.cpp ├── benchmark.h ├── blob.cpp ├── blob.h ├── cpu.cpp ├── cpu.h ├── layer.cpp ├── layer.h ├── layer │ ├── absval.cpp │ ├── absval.h │ ├── argmax.cpp │ ├── argmax.h │ ├── arm │ │ ├── absval_arm.cpp │ │ ├── absval_arm.h │ │ ├── batchnorm_arm.cpp │ │ ├── batchnorm_arm.h │ │ ├── bias_arm.cpp │ │ ├── bias_arm.h │ │ ├── clip_arm.cpp │ │ ├── clip_arm.h │ │ ├── convolution_1x1.h │ │ ├── convolution_1x1_int8.h │ │ ├── convolution_2x2.h │ │ ├── convolution_3x3.h │ │ ├── convolution_3x3_int8.h │ │ ├── convolution_4x4.h │ │ ├── convolution_5x5.h │ │ ├── convolution_7x7.h │ │ ├── convolution_arm.cpp │ │ ├── convolution_arm.h │ │ ├── convolutiondepthwise_3x3.h │ │ ├── convolutiondepthwise_3x3_int8.h │ │ ├── convolutiondepthwise_5x5.h │ │ ├── convolutiondepthwise_arm.cpp │ │ ├── convolutiondepthwise_arm.h │ │ ├── deconvolution_3x3.h │ │ ├── deconvolution_4x4.h │ │ ├── deconvolution_arm.cpp │ │ ├── deconvolution_arm.h │ │ ├── deconvolutiondepthwise_arm.cpp │ │ ├── deconvolutiondepthwise_arm.h │ │ ├── dequantize_arm.cpp │ │ ├── dequantize_arm.h │ │ ├── eltwise_arm.cpp │ │ ├── eltwise_arm.h │ │ ├── innerproduct_arm.cpp │ │ ├── innerproduct_arm.h │ │ ├── lrn_arm.cpp │ │ ├── lrn_arm.h │ │ ├── neon_mathfun.h │ │ ├── pooling_2x2.h │ │ ├── pooling_3x3.h │ │ ├── pooling_arm.cpp │ │ ├── pooling_arm.h │ │ ├── prelu_arm.cpp │ │ ├── prelu_arm.h │ │ ├── quantize_arm.cpp │ │ ├── quantize_arm.h │ │ ├── relu_arm.cpp │ │ ├── relu_arm.h │ │ ├── scale_arm.cpp │ │ ├── scale_arm.h │ │ ├── sigmoid_arm.cpp │ │ ├── sigmoid_arm.h │ │ ├── softmax_arm.cpp │ │ └── softmax_arm.h │ ├── batchnorm.cpp │ ├── batchnorm.h │ ├── bias.cpp │ ├── bias.h │ ├── binaryop.cpp │ ├── binaryop.h │ ├── bnll.cpp │ ├── bnll.h │ ├── clip.cpp │ ├── clip.h │ ├── concat.cpp │ ├── concat.h │ ├── convolution.cpp │ ├── convolution.h │ ├── convolutiondepthwise.cpp │ ├── convolutiondepthwise.h │ ├── crop.cpp │ ├── crop.h │ ├── deconvolution.cpp │ ├── deconvolution.h │ ├── deconvolutiondepthwise.cpp │ ├── deconvolutiondepthwise.h │ ├── dequantize.cpp │ ├── dequantize.h │ ├── detectionoutput.cpp │ ├── detectionoutput.h │ ├── dropout.cpp │ ├── dropout.h │ ├── eltwise.cpp │ ├── eltwise.h │ ├── elu.cpp │ ├── elu.h │ ├── embed.cpp │ ├── embed.h │ ├── exp.cpp │ ├── exp.h │ ├── expanddims.cpp │ ├── expanddims.h │ ├── flatten.cpp │ ├── flatten.h │ ├── innerproduct.cpp │ ├── innerproduct.h │ ├── input.cpp │ ├── input.h │ ├── instancenorm.cpp │ ├── instancenorm.h │ ├── interp.cpp │ ├── interp.h │ ├── log.cpp │ ├── log.h │ ├── lrn.cpp │ ├── lrn.h │ ├── lstm.cpp │ ├── lstm.h │ ├── memorydata.cpp │ ├── memorydata.h │ ├── mvn.cpp │ ├── mvn.h │ ├── normalize.cpp │ ├── normalize.h │ ├── padding.cpp │ ├── padding.h │ ├── permute.cpp │ ├── permute.h │ ├── pooling.cpp │ ├── pooling.h │ ├── power.cpp │ ├── power.h │ ├── prelu.cpp │ ├── prelu.h │ ├── priorbox.cpp │ ├── priorbox.h │ ├── proposal.cpp │ ├── proposal.h │ ├── psroipooling.cpp │ ├── psroipooling.h │ ├── quantize.cpp │ ├── quantize.h │ ├── reduction.cpp │ ├── reduction.h │ ├── relu.cpp │ ├── relu.h │ ├── reorg.cpp │ ├── reorg.h │ ├── reshape.cpp │ ├── reshape.h │ ├── rnn.cpp │ ├── rnn.h │ ├── roialign.cpp │ ├── roialign.h │ ├── roipooling.cpp │ ├── roipooling.h │ ├── scale.cpp │ ├── scale.h │ ├── shufflechannel.cpp │ ├── shufflechannel.h │ ├── sigmoid.cpp │ ├── sigmoid.h │ ├── slice.cpp │ ├── slice.h │ ├── softmax.cpp │ ├── softmax.h │ ├── split.cpp │ ├── split.h │ ├── spp.cpp │ ├── spp.h │ ├── squeeze.cpp │ ├── squeeze.h │ ├── tanh.cpp │ ├── tanh.h │ ├── threshold.cpp │ ├── threshold.h │ ├── tile.cpp │ ├── tile.h │ ├── unaryop.cpp │ ├── unaryop.h │ ├── x86 │ │ ├── avx_mathfun.h │ │ ├── convolution_1x1.h │ │ ├── convolution_1x1_int8.h │ │ ├── convolution_3x3.h │ │ ├── convolution_3x3_int8.h │ │ ├── convolution_5x5.h │ │ ├── convolution_x86.cpp │ │ ├── convolution_x86.h │ │ ├── convolutiondepthwise_3x3.h │ │ ├── convolutiondepthwise_3x3_int8.h │ │ ├── convolutiondepthwise_x86.cpp │ │ ├── convolutiondepthwise_x86.h │ │ └── sse_mathfun.h │ ├── yolodetectionoutput.cpp │ ├── yolodetectionoutput.h │ ├── yolov3detectionoutput.cpp │ └── yolov3detectionoutput.h ├── layer_declaration.h.in ├── layer_registry.h.in ├── layer_type.h ├── layer_type_enum.h.in ├── mat.cpp ├── mat.h ├── mat_pixel.cpp ├── mat_pixel_resize.cpp ├── modelbin.cpp ├── modelbin.h ├── net.cpp ├── net.h ├── opencv.cpp ├── opencv.h ├── paramdict.cpp ├── paramdict.h └── platform.h.in ├── toolchains ├── aarch64-linux-gnu.toolchain.cmake ├── arm-linux-gnueabi.toolchain.cmake ├── arm-linux-gnueabihf.toolchain.cmake ├── himix100.toolchain.cmake ├── hisiv300.toolchain.cmake ├── hisiv500.toolchain.cmake ├── host.gcc.toolchain.cmake ├── ios.toolchain.cmake ├── iossimxc.toolchain.cmake ├── iosxc.toolchain.cmake └── pi3.toolchain.cmake └── tools ├── CMakeLists.txt ├── caffe ├── CMakeLists.txt ├── caffe.proto └── caffe2ncnn.cpp ├── darknet └── readme.txt ├── mxnet ├── CMakeLists.txt └── mxnet2ncnn.cpp ├── ncnn2mem.cpp ├── onnx ├── CMakeLists.txt ├── onnx.proto └── onnx2ncnn.cpp ├── plugin ├── ImageWatchNCNN.natvis ├── README.md └── snapshot.png ├── pytorch └── readme.txt └── tensorflow ├── CMakeLists.txt ├── attr_value.proto ├── function.proto ├── graph.proto ├── node_def.proto ├── op_def.proto ├── resource_handle.proto ├── tensor.proto ├── tensor_shape.proto ├── tensorflow2ncnn.cpp ├── types.proto └── versions.proto /.gitignore: -------------------------------------------------------------------------------- 1 | # CMake build directory 2 | *build*/ 3 | 4 | # Backup files. 5 | *~ 6 | 7 | # Prerequisites 8 | *.d 9 | 10 | # Compiled Object files 11 | *.slo 12 | *.lo 13 | *.o 14 | *.obj 15 | 16 | # Precompiled Headers 17 | *.gch 18 | *.pch 19 | 20 | # Compiled Dynamic libraries 21 | *.so 22 | *.dylib 23 | *.dll 24 | 25 | # Fortran module files 26 | *.mod 27 | *.smod 28 | 29 | # Compiled Static libraries 30 | *.lai 31 | *.la 32 | *.a 33 | *.lib 34 | 35 | # Executables 36 | *.exe 37 | *.out 38 | *.app 39 | 40 | # Compiled pb file 41 | 42 | *.pb.cc 43 | *.pb.h 44 | 45 | # Compiled framework 46 | ncnn.framework/ 47 | 48 | # IDE 49 | .idea/ -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | 2 | ## Acknowledgements 3 | - Thanks to bug1989 [https://github.com/bug1989] for contributing the initial quantized int8 inference code and a large variety of device benchmark 4 | -------------------------------------------------------------------------------- /Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleName 6 | ncnn 7 | CFBundleIdentifier 8 | com.tencent.ncnn 9 | CFBundleVersion 10 | 1.0 11 | CFBundleShortVersionString 12 | 1.0 13 | CFBundleSignature 14 | ???? 15 | CFBundlePackageType 16 | FMWK 17 | 18 | 19 | -------------------------------------------------------------------------------- /benchmark/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../src) 3 | include_directories(${CMAKE_CURRENT_BINARY_DIR}/../src) 4 | 5 | add_executable(benchncnn benchncnn.cpp) 6 | set_property(TARGET benchncnn PROPERTY COMPILE_FLAGS "-fpie") 7 | set_property(TARGET benchncnn PROPERTY LINK_FLAGS "-pie") 8 | target_link_libraries(benchncnn ncnn) 9 | -------------------------------------------------------------------------------- /benchmark/alexnet.param: -------------------------------------------------------------------------------- 1 | 7767517 2 | 24 24 3 | Input data 0 1 data 0=227 1=227 2=3 4 | Convolution conv1 1 1 data conv1 0=96 1=11 2=1 3=4 4=0 5=1 6=34848 5 | ReLU relu1 1 1 conv1 conv1_relu1 6 | LRN norm1 1 1 conv1_relu1 norm1 0=0 1=5 2=0.000100 3=0.750000 7 | Pooling pool1 1 1 norm1 pool1 0=0 1=3 2=2 3=0 4=0 8 | ConvolutionDepthWise conv2 1 1 pool1 conv2 0=256 1=5 2=1 3=1 4=2 5=1 6=307200 7=2 9 | ReLU relu2 1 1 conv2 conv2_relu2 10 | LRN norm2 1 1 conv2_relu2 norm2 0=0 1=5 2=0.000100 3=0.750000 11 | Pooling pool2 1 1 norm2 pool2 0=0 1=3 2=2 3=0 4=0 12 | Convolution conv3 1 1 pool2 conv3 0=384 1=3 2=1 3=1 4=1 5=1 6=884736 13 | ReLU relu3 1 1 conv3 conv3_relu3 14 | ConvolutionDepthWise conv4 1 1 conv3_relu3 conv4 0=384 1=3 2=1 3=1 4=1 5=1 6=663552 7=2 15 | ReLU relu4 1 1 conv4 conv4_relu4 16 | ConvolutionDepthWise conv5 1 1 conv4_relu4 conv5 0=256 1=3 2=1 3=1 4=1 5=1 6=442368 7=2 17 | ReLU relu5 1 1 conv5 conv5_relu5 18 | Pooling pool5 1 1 conv5_relu5 pool5 0=0 1=3 2=2 3=0 4=0 19 | InnerProduct fc6 1 1 pool5 fc6 0=4096 1=1 2=37748736 20 | ReLU relu6 1 1 fc6 fc6_relu6 21 | Dropout drop6 1 1 fc6_relu6 fc6_drop6 22 | InnerProduct fc7 1 1 fc6_drop6 fc7 0=4096 1=1 2=16777216 23 | ReLU relu7 1 1 fc7 fc7_relu7 24 | Dropout drop7 1 1 fc7_relu7 fc7_drop7 25 | InnerProduct fc8 1 1 fc7_drop7 fc8 0=1000 1=1 2=4096000 26 | Softmax prob 1 1 fc8 prob 0=0 27 | -------------------------------------------------------------------------------- /examples/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | find_package(OpenCV QUIET COMPONENTS core highgui imgproc imgcodecs) 3 | if(NOT OpenCV_FOUND) 4 | find_package(OpenCV REQUIRED COMPONENTS core highgui imgproc) 5 | endif() 6 | 7 | include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../src) 8 | include_directories(${CMAKE_CURRENT_BINARY_DIR}/../src) 9 | 10 | add_executable(squeezenet squeezenet.cpp) 11 | target_link_libraries(squeezenet ncnn ${OpenCV_LIBS}) 12 | 13 | add_executable(fasterrcnn fasterrcnn.cpp) 14 | target_link_libraries(fasterrcnn ncnn ${OpenCV_LIBS}) 15 | 16 | add_executable(rfcn rfcn.cpp) 17 | target_link_libraries(rfcn ncnn ${OpenCV_LIBS}) 18 | 19 | add_executable(yolov2 yolov2.cpp) 20 | target_link_libraries(yolov2 ncnn ${OpenCV_LIBS}) 21 | 22 | add_executable(yolov3 yolov3.cpp) 23 | target_link_libraries(yolov3 ncnn ${OpenCV_LIBS}) 24 | 25 | add_executable(mobilenetv2ssdlite mobilenetv2ssdlite.cpp) 26 | target_link_libraries(mobilenetv2ssdlite ncnn ${OpenCV_LIBS}) 27 | 28 | add_executable(mobilenetssd mobilenetssd.cpp) 29 | target_link_libraries(mobilenetssd ncnn ${OpenCV_LIBS}) 30 | 31 | add_executable(squeezenetssd squeezenetssd.cpp) 32 | target_link_libraries(squeezenetssd ncnn ${OpenCV_LIBS}) 33 | 34 | add_executable(shufflenetv2 shufflenetv2.cpp) 35 | target_link_libraries(shufflenetv2 ncnn ${OpenCV_LIBS}) 36 | -------------------------------------------------------------------------------- /examples/squeezencnn/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /examples/squeezencnn/ant.properties: -------------------------------------------------------------------------------- 1 | # This file is used to override default values used by the Ant build system. 2 | # 3 | # This file must be checked into Version Control Systems, as it is 4 | # integral to the build system of your project. 5 | 6 | # This file is only used by the Ant script. 7 | 8 | # You can use this to override default values such as 9 | # 'source.dir' for the location of your java source folder and 10 | # 'out.dir' for the location of your output folder. 11 | 12 | # You can also use it define how the release builds are signed by declaring 13 | # the following properties: 14 | # 'key.store' for the location of your keystore and 15 | # 'key.alias' for the name of the key to use. 16 | # The password will be asked during the build when you use the 'release' target. 17 | 18 | key.store=/home/nihui/osd/nihuini-release-key.keystore 19 | key.alias=nihuini 20 | key.store.password=nihuini 21 | key.alias.password=nihuini 22 | -------------------------------------------------------------------------------- /examples/squeezencnn/assets/squeezenet_v1.1.bin: -------------------------------------------------------------------------------- 1 | ../../squeezenet_v1.1.bin -------------------------------------------------------------------------------- /examples/squeezencnn/assets/squeezenet_v1.1.param.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiangxiluning/ncnn-tensorflow/4f84be38d58102529c94d87d48aac71e5739fa9e/examples/squeezencnn/assets/squeezenet_v1.1.param.bin -------------------------------------------------------------------------------- /examples/squeezencnn/assets/synset_words.txt: -------------------------------------------------------------------------------- 1 | ../../synset_words.txt -------------------------------------------------------------------------------- /examples/squeezencnn/jni/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH := $(call my-dir) 2 | 3 | # change this folder path to yours 4 | NCNN_INSTALL_PATH := /home/nihui/osd/ncnn/ncnn-android-lib 5 | 6 | include $(CLEAR_VARS) 7 | LOCAL_MODULE := ncnn 8 | LOCAL_SRC_FILES := $(NCNN_INSTALL_PATH)/$(TARGET_ARCH_ABI)/libncnn.a 9 | include $(PREBUILT_STATIC_LIBRARY) 10 | 11 | include $(CLEAR_VARS) 12 | 13 | LOCAL_MODULE := squeezencnn 14 | LOCAL_SRC_FILES := squeezencnn_jni.cpp 15 | 16 | LOCAL_C_INCLUDES := $(NCNN_INSTALL_PATH)/include 17 | 18 | LOCAL_STATIC_LIBRARIES := ncnn 19 | 20 | LOCAL_CFLAGS := -O2 -fvisibility=hidden -fomit-frame-pointer -fstrict-aliasing -ffunction-sections -fdata-sections -ffast-math 21 | LOCAL_CPPFLAGS := -O2 -fvisibility=hidden -fvisibility-inlines-hidden -fomit-frame-pointer -fstrict-aliasing -ffunction-sections -fdata-sections -ffast-math 22 | LOCAL_LDFLAGS += -Wl,--gc-sections 23 | 24 | LOCAL_CFLAGS += -fopenmp 25 | LOCAL_CPPFLAGS += -fopenmp 26 | LOCAL_LDFLAGS += -fopenmp 27 | 28 | LOCAL_LDLIBS := -lz -llog -ljnigraphics 29 | 30 | include $(BUILD_SHARED_LIBRARY) 31 | -------------------------------------------------------------------------------- /examples/squeezencnn/jni/Application.mk: -------------------------------------------------------------------------------- 1 | 2 | # APP_STL := stlport_static 3 | APP_STL := gnustl_static 4 | # APP_ABI := armeabi armeabi-v7a 5 | APP_ABI := armeabi-v7a arm64-v8a 6 | APP_PLATFORM := android-9 7 | # NDK_TOOLCHAIN_VERSION := 4.9 8 | -------------------------------------------------------------------------------- /examples/squeezencnn/local.properties: -------------------------------------------------------------------------------- 1 | # This file is automatically generated by Android Tools. 2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED! 3 | # 4 | # This file must *NOT* be checked into Version Control Systems, 5 | # as it contains information specific to your local configuration. 6 | 7 | # location of the SDK. This is only used by Ant 8 | # For customization when using a Version Control System, please read the 9 | # header note. 10 | sdk.dir=/home/nihui/osd/android-sdk-linux 11 | -------------------------------------------------------------------------------- /examples/squeezencnn/proguard-project.txt: -------------------------------------------------------------------------------- 1 | # To enable ProGuard in your project, edit project.properties 2 | # to define the proguard.config property as described in that file. 3 | # 4 | # Add project specific ProGuard rules here. 5 | # By default, the flags in this file are appended to flags specified 6 | # in ${sdk.dir}/tools/proguard/proguard-android.txt 7 | # You can edit the include path and order by changing the ProGuard 8 | # include property in project.properties. 9 | # 10 | # For more details, see 11 | # http://developer.android.com/guide/developing/tools/proguard.html 12 | 13 | # Add any project specific keep options here: 14 | 15 | # If your project uses WebView with JS, uncomment the following 16 | # and specify the fully qualified class name to the JavaScript interface 17 | # class: 18 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 19 | # public *; 20 | #} 21 | -------------------------------------------------------------------------------- /examples/squeezencnn/project.properties: -------------------------------------------------------------------------------- 1 | # This file is automatically generated by Android Tools. 2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED! 3 | # 4 | # This file must be checked in Version Control Systems. 5 | # 6 | # To customize properties used by the Ant build system edit 7 | # "ant.properties", and override values to adapt the script to your 8 | # project structure. 9 | # 10 | # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): 11 | #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt 12 | 13 | # Project target. 14 | target=android-9 15 | -------------------------------------------------------------------------------- /examples/squeezencnn/res/layout/main.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 11 | 12 |