各位大佬,Tengine1.5-dev版本,使用官方提供的yolov5s.tmfile模型,在计算图预先运行时报错 #1420
Open
Description
代码如下:
int tengine_graph_init(void)
{
struct options opt; //options为garph的行时参数
opt.num_thread = 4;
opt.cluster = TENGINE_CLUSTER_ALL; //TENGINE_CLUSTER_ALL表示使用所有的CPU核心
opt.precision = TENGINE_MODE_FP32; //TENGINE_MODE_FP32表示使用FP32的精度
opt.affinity = 0; //affinity表示是否使用CPU亲和性,0表示不使用,没有绑定线程到核心
int dims[] = {1, 3, 640, 640};
std::vector<float> input_data(3*640*640);
if(init_tengine() != 0)
{
cout<<"tengine init failed"<<endl;
return -1;
}
cout<<get_tengine_version()<<endl;
//构建计算图
graph_t graph = create_graph(nullptr, "tengine", "yolov5s.tmfile");
if(graph != nullptr)
cout<<"graph build success"<<endl;
else
{
cout<<"graph build faild"<<endl;
return -1;
}
tensor_t input_tensor = get_graph_input_tensor(graph, 0, 0);
if (input_tensor == nullptr)
{
cout<<"Get input tensor failed"<<endl;
return -1;
}
if (set_tensor_shape(input_tensor, dims, 4) < 0)
{
cout<<"Set input tensor shape failed"<<endl;
return -1;
}
if (set_tensor_buffer(input_tensor, input_data.data(), 3*640*640 * sizeof(float)) < 0)
{
cout<<"Set input tensor buffer failed"<<endl;
return -1;
}
/* prerun graph, set work options(num_thread, cluster, precision) */
if (prerun_graph_multithread(graph, opt) < 0)
{
cout<<"Prerun multithread graph failed"<<endl;
return -1;
}
else
cout<<"prerun graph success"<<endl;
return 0;
}
报错如下:
1.5-dev
graph build success
Error: input elem num(408000) != reshaped elem num(102000)
Tengine FATAL: Infer node(id: 276, op: Reshape) shape failed.
Tengine: Infer shape of graph failed(-1).
Prerun multithread graph failed
Metadata
Assignees
Labels
No labels