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

reshape not support dimensions == 3 The Creator Don't support type 73, 257 #483

Closed
HangJie720 opened this issue Nov 28, 2019 · 6 comments
Closed

Comments

@HangJie720
Copy link

HangJie720 commented Nov 28, 2019

Hello, UltraFace is face detection demo, reference to https://github.com/Linzaer/Ultra-Light-Fast-Generic-Face-Detector-1MB/tree/master/MNN/src/UltraFace.cpp, I want to put it to /MNN/demo/exec directory to run with arm v8 GPU(RK3399), opencl included.

However, when compiled by 'mkdir build && cd build && cmake .. -DMNN_BUILD_DEMO=ON && make -j4', compiled failure as follows, my opencv version is 4.1.1,

In file included from /usr/local/include/opencv4/opencv2/flann/params.h:33:0,
                 from /usr/local/include/opencv4/opencv2/flann/flann_base.hpp:40,
                 from /usr/local/include/opencv4/opencv2/flann.hpp:48,
                 from /usr/local/include/opencv4/opencv2/opencv.hpp:65,
                 from /root/data/user/jie.hang/MNN/demo/exec/UltraFace.hpp:14,
                 from /root/data/user/jie.hang/MNN/demo/exec/main.cpp:4:
/usr/local/include/opencv4/opencv2/flann/any.h: In member function 'virtual const std::type_info& cvflann::anyimpl::typed_base_any_policy<T>::type()':
/usr/local/include/opencv4/opencv2/flann/any.h:58:71: error: cannot use typeid with -fno-rtti
     virtual const std::type_info& type() CV_OVERRIDE { return typeid(T); }
                                                                       ^
/usr/local/include/opencv4/opencv2/flann/any.h: In member function 'T& cvflann::any::cast()':
/usr/local/include/opencv4/opencv2/flann/any.h:274:39: error: cannot use typeid with -fno-rtti
         if (policy->type() != typeid(T)) throw anyimpl::bad_any_cast();
                                       ^
/usr/local/include/opencv4/opencv2/flann/any.h: In member function 'const T& cvflann::any::cast() const':
/usr/local/include/opencv4/opencv2/flann/any.h:283:39: error: cannot use typeid with -fno-rtti
         if (policy->type() != typeid(T)) throw anyimpl::bad_any_cast();
                                       ^
/usr/local/include/opencv4/opencv2/flann/any.h: In member function 'bool cvflann::any::empty() const':
/usr/local/include/opencv4/opencv2/flann/any.h:291:59: error: cannot use typeid with -fno-rtti
         return policy->type() == typeid(anyimpl::empty_any);
                                                           ^
/usr/local/include/opencv4/opencv2/flann/any.h: In member function 'bool cvflann::any::has_type()':
/usr/local/include/opencv4/opencv2/flann/any.h:311:42: error: cannot use typeid with -fno-rtti
         return policy->type() == typeid(T);
                                          ^
In file included from /usr/local/include/opencv4/opencv2/flann/flann_base.hpp:41:0,
                 from /usr/local/include/opencv4/opencv2/flann.hpp:48,
                 from /usr/local/include/opencv4/opencv2/opencv.hpp:65,
                 from /root/data/user/jie.hang/MNN/demo/exec/UltraFace.hpp:14,
                 from /root/data/user/jie.hang/MNN/demo/exec/main.cpp:4:
/usr/local/include/opencv4/opencv2/flann/saving.h: In function 'cvflann::IndexHeader cvflann::load_header(FILE*)':
/usr/local/include/opencv4/opencv2/flann/saving.h:113:63: error: exception handling disabled, use -fexceptions to enable
         throw FLANNException("Invalid index file, cannot read");
                                                               ^
demo/exec/CMakeFiles/UltraFace.out.dir/build.make:62: recipe for target 'demo/exec/CMakeFiles/UltraFace.out.dir/main.cpp.o' failed
make[2]: *** [demo/exec/CMakeFiles/UltraFace.out.dir/main.cpp.o] Error 1
CMakeFiles/Makefile2:716: recipe for target 'demo/exec/CMakeFiles/UltraFace.out.dir/all' failed
make[1]: *** [demo/exec/CMakeFiles/UltraFace.out.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
@Naville
Copy link
Contributor

Naville commented Nov 28, 2019

This is a issue with our current build system. Try removing -fno-rtti and -fno-exceptions from the following CMakeLists:

demo/android/app/CMakeLists.txt:set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fvisibility=hidden -fvisibility-inlines-hidden -fomit-frame-pointer -fstrict-aliasing -ffunction-sections -fdata-sections -ffast-math -fno-rtti -fno-exceptions -flax-vector-conversions")

CMakeLists.txt:    set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}  -fomit-frame-pointer -fstrict-aliasing -ffunction-sections -fdata-sections -ffast-math -fno-rtti -fno-exceptions")

express/CMakeLists.txt:        set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}  -fomit-frame-pointer -fstrict-aliasing -ffunction-sections -fdata-sections -ffast-math -fno-rtti -fno-exceptions")

source/backend/arm82/CMakeLists.txt:set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}  -fvisibility-inlines-hidden -fomit-frame-pointer -fstrict-aliasing -ffunction-sections -fdata-sections -ffast-math -fno-rtti -fno-exceptions")

source/backend/opencl/CMakeLists.txt:    set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}  -fvisibility-inlines-hidden -fomit-frame-pointer -fstrict-aliasing -ffunction-sections -fdata-sections -ffast-math -fno-rtti -fno-exceptions")

source/backend/vulkan/CMakeLists.txt:set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}  -fvisibility-inlines-hidden -fomit-frame-pointer -fstrict-aliasing -ffunction-sections -fdata-sections -ffast-math -fno-rtti -fno-exceptions")

source/backend/opengl/CMakeLists.txt:set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}  -fvisibility-inlines-hidden -fomit-frame-pointer -fstrict-aliasing -ffunction-sections -fdata-sections -ffast-math -fno-rtti -fno-exceptions")

@HangJie720
Copy link
Author

HangJie720 commented Nov 29, 2019

Thank you very much, compile is OK, but new problem occurred when running the following command,

./UltraFace.out slim-320-quant-ADMM-50.mnn imgs/1.jpg

print information is shown as follows,

reshape not support dimensions == 3
The Creator Don't support type 73, 257
reshape not support dimensions == 3
The Creator Don't support type 73, 303
reshape not support dimensions == 3
The Creator Don't support type 73, 343
reshape not support dimensions == 3
The Creator Don't support type 73, 373
reshape not support dimensions == 3
The Creator Don't support type 73, 243
reshape not support dimensions == 3
The Creator Don't support type 73, 289
reshape not support dimensions == 3
The Creator Don't support type 73, 329
reshape not support dimensions == 3
The Creator Don't support type 73, 361
softmax not support dimensions == 3
The Creator Don't support type 85, scores

I define config.type = MNN_FORWARD_CPU in UltraFace.cpp is OK, however config.type=MNN_FORWARD_OPENCL report error above;
I want to know If this model's partial ops, e.g., reshape, are not supported on arm GPU.

@HangJie720
Copy link
Author

Thank you very much, compile is OK, but new problem occurred when running the following command,

./UltraFace.out slim-320-quant-ADMM-50.mnn imgs/1.jpg

print information is shown as follows,

reshape not support dimensions == 3
The Creator Don't support type 73, 257
reshape not support dimensions == 3
The Creator Don't support type 73, 303
reshape not support dimensions == 3
The Creator Don't support type 73, 343
reshape not support dimensions == 3
The Creator Don't support type 73, 373
reshape not support dimensions == 3
The Creator Don't support type 73, 243
reshape not support dimensions == 3
The Creator Don't support type 73, 289
reshape not support dimensions == 3
The Creator Don't support type 73, 329
reshape not support dimensions == 3
The Creator Don't support type 73, 361
softmax not support dimensions == 3
The Creator Don't support type 85, scores

I define config.type = MNN_FORWARD_CPU in UltraFace.cpp is OK, however config.type=MNN_FORWARD_OPENCL report error above;
I want to know If this model's partial ops, e.g., reshape, are not supported on arm GPU.

From opencl support op reshape/softmax source code, problem is occurred here.

class ReshapeCreator : public OpenCLBackend::Creator {
public:
    virtual ~ReshapeCreator() = default;
    virtual Execution *onCreate(const std::vector<Tensor *> &inputs, const std::vector<Tensor *> &outputs,
                                const MNN::Op *op, Backend *backend) const override {
        if(inputs[0]->dimensions() == 3 || outputs[0]->dimensions() == 3){
            MNN_PRINT("reshape not support dimensions == 3 \n");
            return nullptr;
        }
        return new ReshapeExecution(inputs, op, backend);
    }
};
class SoftmaxCreator : public OpenCLBackend::Creator {
public:
    virtual Execution *onCreate(const std::vector<Tensor *> &inputs, const std::vector<Tensor *> &outputs,
                                const MNN::Op *op, Backend *backend) const override {
        if(inputs[0]->dimensions() == 3 || outputs[0]->dimensions() == 3){
            MNN_PRINT("softmax not support dimensions == 3 \n");
            return nullptr;
        }
        auto axis = op->main_as_Axis()->axis();
        if (-1 == axis) {
            axis = inputs[0]->dimensions() - 1;
        }
        
        if (1 == axis || 2 == axis) {
            return new SoftmaxExecution(inputs, axis, backend);
        }
        return nullptr;
    }
};

Due to author providing model's shape params is [1,-1,4] and [1,-1,2], Is there a good solution to get reshape and softmax op's running on the CPU?

@HangJie720 HangJie720 changed the title /usr/local/include/opencv4/opencv2/flann/any.h: In member function 'virtual const std::type_info& cvflann::anyimpl::typed_base_any_policy<T>::type()': /usr/local/include/opencv4/opencv2/flann/any.h:58:71: error: cannot use typeid with -fno-rtti virtual const std::type_info& type() CV_OVERRIDE { return typeid(T); } reshape not support dimensions == 3 The Creator Don't support type 73, 257 Dec 4, 2019
@hacker-joe
Copy link

If OpenCL does not support this op, the callback to the CPU is automatic

@Zhuoyao1012
Copy link

If OpenCL does not support this op, the callback to the CPU is automatic

So the data is copied from GPU Mem to CPU Mem? And if the next layer is GPU supported, the data is copied form CPU to GPU again? Or it's an unified memory, and all the backend can share all the memories?

@jxt1234
Copy link
Collaborator

jxt1234 commented Nov 5, 2020

Supported.

@jxt1234 jxt1234 closed this as completed Nov 5, 2020
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

5 participants