Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

各位大佬,Tengine1.5-dev版本,使用官方提供的yolov5s.tmfile模型,在计算图预先运行时报错 #1420

Open
chnejing88 opened this issue Jun 10, 2023 · 0 comments

Comments

@chnejing88
Copy link

代码如下:

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant