深度學習(六十一)NNPACK 移植與實驗

2021-07-29 12:53:15 字數 2381 閱讀 5410

一、ubuntu下使用:

git clone
2、安裝nijia,並編譯

[sudo] pip install --upgrade git+

confu setup

python ./configure.py

ninja

3、鏈結的時候還需要用到pthread庫,否在會遇到找不到實現函式。

target_link_libraries(nnpack libnnpack.a libpthreadpool.a pthread)
需要加入pthread庫,否這會報錯。

4、測試**

#include #include "nnpack.h"

#include #include using namespace std;

float test_nnpack()

enum nnp_convolution_algorithm algorithm = nnp_convolution_algorithm_auto;

enum nnp_convolution_transform_strategy strategy=nnp_convolution_transform_strategy_tuple_based;

const size_t batch_size = 1;

const size_t input_channels = 128;

const size_t output_channels = 128;

const struct nnp_padding input_padding = ;

const struct nnp_size input_size =;

const struct nnp_size kernel_size = ;

const struct nnp_size stride=;

const struct nnp_size output_size = ;

//malloc memory for input, kernel, output, bias

float* input = (float*)malloc(batch_size * input_channels *input_size.height *input_size.width * sizeof(float));

float* kernel = (float*)malloc(input_channels * output_channels * kernel_size.height * kernel_size.width * sizeof(float));

float* output = (float*)malloc(batch_size* output_channels * output_size.height * output_size.width * sizeof(float));

float* bias = (float*)malloc(output_channels * sizeof(float));

pthreadpool_t threadpool= nullptr;

struct nnp_profile computation_profile;//use for compute time;

//init input data

int i,j;

for(int c=0; cout;

for(int i=0;i

在mxnet、tiny-dnn中的引用方法:

在tiny-dnn中,底層呼叫nnpack為啥只採用了乙個執行緒,於是我測試了多執行緒的速度,經過測試發現nnpack的弱點,原來在於多執行緒:

二、android使用

1、新增ndk-build環境變數路徑:

export ndk_root=/home/hjimce/android/sdk/ndk-bundle/
2、直接執行:

$/ndk-build

arguments "-dandroid_arm_neon=true", "-dandroid_toolchain=clang"

ndk

手機速度測試:

修改:多執行緒時間測試不能使用time.clock(),可使用auto begin =std::chrono::high_resolution_clock::now();

OpenCV Python 高動態範圍 六十一

作者 opencv python tutorials 編譯 vincent opencv python tutorials 在本章中,我們將 高動態範圍成像 hdri或hdr 是一種用於成像和攝影的技術,可以比標準數字成像或攝影技術重現更大的動態亮度範圍。雖然人眼可以適應各種光照條件,但是大多數成像...

《劍指Offer》題六十一 題六十八

六十 一 撲克牌中的順子 題目 從撲克牌中隨機抽5張牌,判斷是不是乙個順子,即這5張牌是不是連續的。2 10為數字本身,a為1,j為11,q為12,k為13,而大 小王可以看成任意數字。六十二 圓圈中最後剩下的數字 題目 0,1,n 1這n個數字排成乙個圓圈,從數字0開始,每次從這個圓圈裡刪除第m個...

計算機網路 練習(六十一)

練習 六十一 下列無線網路技術中,覆蓋範圍最小的是 a.802.15.1 藍芽 b.802.11n 無線區域網 c.802.15.4 zigbee d.802.16m 無線都會網路 答案 a解析 wifi,wifi 是目前應用最廣泛的無線通訊技術,傳輸距離在 100 300 m,速率可達 300 m...