rknpu
rknpu copied to clipboard
C++ API cost much more time compare to python API
ret = rknn_outputs_get(ctx, 2, outputs, nullptr) this API need too much time, the same rknn model ,Python need 9ms one imgs ,but C++ API need 20ms C++ API do not use NPU?
double timeConsume,start;
start = static_cast<double>(cv::getTickCount()); //记录当前时刻CPU时钟周期
for (int j=0;j<300;j++){
// Load image
inputs[0].buf = img.data;
ret = rknn_inputs_set(ctx, 1, inputs);
if(ret < 0) {
printf("rknn_input_set fail! ret=%d\n", ret);
goto Error;
}
// Start Inference
ret = rknn_run(ctx, nullptr);
if(ret < 0) {
printf("rknn_run fail! ret=%d\n", ret);
goto Error;
}
outputs[0].want_float = true;
outputs[0].is_prealloc = false;
outputs[1].want_float = true;
outputs[1].is_prealloc = false;
ret = rknn_outputs_get(ctx, 2, outputs, nullptr);
if(ret < 0) {
printf("rknn_outputs_get fail! ret=%d\n", ret);
goto Error;
}
}
timeConsume = ((double)cv::getTickCount() - start) / cv::getTickFrequency();
printf("\n timeSonsume: %f\n" ,timeConsume );