ncnn icon indicating copy to clipboard operation
ncnn copied to clipboard

yolox 移植到qnx上碰到的问题

Open jxncyym opened this issue 2 years ago • 4 comments

error log | 日志或报错信息 | ログ

/media/jessen/8191fa96-6e5d-4417-9b2a-a6538a02c569/qnx/qnx710/host/linux/x86_64/usr/bin/aarch64-unknown-nto-qnx7.1.0-ld: ./libyolox_6_14.so: undefined reference to ncnn::Layer::forward(std::vector<ncnn::Mat, std::allocator<ncnn::Mat> > const&, std::vector<ncnn::Mat, std::allocator<ncnn::Mat> >&, ncnn::Option const&) const' /media/jessen/8191fa96-6e5d-4417-9b2a-a6538a02c569/qnx/qnx710/host/linux/x86_64/usr/bin/aarch64-unknown-nto-qnx7.1.0-ld:./libyolox_6_14.so: undefined reference to ncnn::Layer::forward_inplace(std::vector<ncnn::Mat, std::allocatorncnn::Mat >&, ncnn::Option const&) const' /media/jessen/8191fa96-6e5d-4417-9b2a-a6538a02c569/qnx/qnx710/host/linux/x86_64/usr/bin/aarch64-unknown-nto-qnx7.1.0-ld:./libyolox_6_14.so: undefined reference to `typeinfo for ncnn::Layer' collect2: error: ld returned 1 exit status CMakeFiles/Argos_FatigueDetect_testv.dir/build.make:113: recipe for target 'Argos_FatigueDetect_testv' failed make[2]: *** [Argos_FatigueDetect_testv] Error 1 CMakeFiles/Makefile2:110: recipe for target 'CMakeFiles/Argos_FatigueDetect_testv.dir/all' failed make[1]: *** [CMakeFiles/Argos_FatigueDetect_testv.dir/all] Error 2 make[1]: *** Waiting for unfinished jobs....

model | 模型 | モデル

  1. original model yolox-nano

how to reproduce | 复现步骤 | 再現方法

  1. 可以使用https://github.com/Megvii-BaseDetection/YOLOX/tree/main/demo/ncnn/cpp 下的文件进行使用qnx进行编译

jxncyym avatar Jun 15 '23 03:06 jxncyym

#include "layer.h"

class YoloV5Focus : public ncnn::Layer { public: YoloV5Focus() { one_blob_only = true; }

virtual int forward(const ncnn::Mat& bottom_blob, ncnn::Mat& top_blob, const ncnn::Option& opt) const
{
    int w = bottom_blob.w;
    int h = bottom_blob.h;
    int channels = bottom_blob.c;

    int outw = w / 2;
    int outh = h / 2;
    int outc = channels * 4;

    top_blob.create(outw, outh, outc, 4u, 1, opt.blob_allocator);
    if (top_blob.empty())
        return -100;

    #pragma omp parallel for num_threads(opt.num_threads)
    for (int p = 0; p < outc; p++)
    {
        const float* ptr = bottom_blob.channel(p % channels).row((p / channels) % 2) + ((p / channels) / 2);
        float* outptr = top_blob.channel(p);

        for (int i = 0; i < outh; i++)
        {
            for (int j = 0; j < outw; j++)
            {
                *outptr = *ptr;

                outptr += 1;
                ptr += 2;
            }

            ptr += w;
        }
    }

    return 0;
}

};

DEFINE_LAYER_CREATOR(YoloV5Focus)

查找原因是上面代码出错,如果注释掉DEFINE_LAYER_CREATOR(YoloV5Focus) 能正常编译

jxncyym avatar Jun 15 '23 04:06 jxncyym

@nihui

jxncyym avatar Jun 15 '23 04:06 jxncyym

https://github.com/Tencent/ncnn/wiki/faq#rttiexceptions%E5%86%B2%E7%AA%81

nihui avatar Aug 16 '23 02:08 nihui

@nihui 这个问题是参考这一条吗?

ncnnoptimize和自定义层 先ncnnoptimize再增加自定义层,避免ncnnoptimize不能处理自定义层保存。

我这个就是加了自定义的YoloV5Focus层,用qnx工具编译没法通过,可以解释详细些吗?

jxncyym avatar Dec 07 '23 12:12 jxncyym