Skip to content

Mek101/rust-ncnn

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

72 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rust-ncnn

GitHub license CI

Rust bindings for ncnn.

Docs

Open Github pages

Or cargo doc and open with browser byself

$ cd /path/to/rust-ncnn
$ cargo doc --open

Prequisition

Rust Env

$ curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSf | sh

CMake >= 3.12

Rust cmake needs --parallel option thus CMake>=3.12 is complusory

$ pip install cmake --upgrade --user

Clang >= 3.9

Rust bindgen uses clang to generate bindings.rs from c_api.h

$ sudo apt install clang-3.9 libclang-3.9-dev
$ sudo apt install clang-10 libclang-10-dev # use clang-10 for ubuntu 20.04 

Build

ncnn build from source:

$ cd rust-ncnn/
$ cargo run --example get_version

Use specific ncnn release:

$ export NCNN_TAG="20220420"

Use prebuilt ncnn:

$ export NCNN_DIR="/path/to/your/ncnn/lib"

Or use vcpkg

vcpkg install ncnn:x64-windows-static-md
cargo run --example get_version

Linking

By default library uses dynamic linking on linux and static linking on windows.

To explicitly use static linking:

$ cargo build --example benchmark --features ncnn-bind/static

To explicitly use dynamic linking:

$ cargo build --example benchmark --features ncnn-bind/dynamic

Vulkan

Build with Vulkan support (requires Vulkan SDK):

$ cargo build --example benchmark --features ncnn-bind/vulkan

Run Examples and UnitTest

$ cargo test
$ cargo run --example get_version
$ cargo run --example benchmark --release
    Finished release [optimized] target(s) in 0.01s
     Running `target/release/examples/benchmark`
squeezenet.param 		 2 ms
squeezenet_int8.param 		 5 ms
mobilenet.param 		 3 ms
mobilenet_int8.param 		 7 ms
mobilenet_v2.param 		 3 ms
mobilenet_v3.param 		 2 ms
shufflenet.param 		 2 ms
shufflenet_v2.param 		 2 ms
mnasnet.param 		 2 ms
proxylessnasnet.param 		 3 ms
efficientnet_b0.param 		 5 ms
regnety_400m.param 		 6 ms
blazeface.param 		 0 ms
googlenet.param 		 10 ms
googlenet_int8.param 		 19 ms
resnet18.param 		 9 ms
resnet18_int8.param 		 16 ms
alexnet.param 		 7 ms
vgg16.param 		 49 ms
vgg16_int8.param 		 71 ms
resnet50.param 		 18 ms
resnet50_int8.param 		 40 ms
squeezenet_ssd.param 		 17 ms
squeezenet_ssd_int8.param 		 13 ms
mobilenet_ssd.param 		 8 ms
mobilenet_ssd_int8.param 		 15 ms
mobilenet_yolo.param 		 30 ms
mobilenetv2_yolov3.param 		 13 ms
yolov4-tiny.param 		 20 ms
nanodet-plus-m_416.param 		 11 ms
nanodet-plus-m_416-int8.param 		 20 ms

Acknowledgements

Releases

No releases published

Packages

No packages published

Languages

  • Rust 100.0%