arm平台多线程设置无效
Created by: biscuit-dot
Paddle-Lite 版本:v2.6.0 模型:mobilenet_v1 http://paddle-inference-dist.bj.bcebos.com/mobilenet_v1.tar.gz 硬件:海思3516CV500 两个CPU,设置1个线程和2个线程,速度一样
void RunModel(std::string model_name, int num_threads=1) {
std::cout << model_name << "\n";
int n = 1;
int c = 3;
int h = 224;
int w = 224;
// 1. Create MobileConfig
MobileConfig config;
config.set_model_from_file(model_name);
// 2. Create PaddlePredictor by CxxConfig
std::shared_ptr<PaddlePredictor> predictor =
CreatePaddlePredictor<MobileConfig>(config);
config.set_threads(num_threads);
std::cout << "num_threads = " << config.threads() << "\n";
// 3. Prepare input data
std::unique_ptr<Tensor> input_tensor(std::move(predictor->GetInput(0)));
input_tensor->Resize({n, c, h, w});
auto* data = input_tensor->mutable_data<float>();
for (int i = 0; i < ShapeProduction(input_tensor->shape()); ++i) {
data[i] = 1;
}
// 4. Run predictor
predictor->Run();
}
}