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

Adding New Op with Converter Caused Core Dump #2142

Closed
dreamibor opened this issue Nov 22, 2022 · 0 comments
Closed

Adding New Op with Converter Caused Core Dump #2142

dreamibor opened this issue Nov 22, 2022 · 0 comments

Comments

@dreamibor
Copy link

dreamibor commented Nov 22, 2022

Platform:
Ubuntu 18.04 & MacOS 13.0 Ventura

So basically, I want to add a new op to MNN and I got segmentation fault, which doesn't quite make sense to me and it has bothered me for a while.

What I did:

  1. added 'SliceOnnx' to enum OpType;
  2. added 'SliceOnnx' to union OpParameter;
  3. added
    table SliceOnnx { starts:[int]; ends:[int]; axes:[int]; steps:[int]; }
    to CaffeOps.fbs
  4. remove OnnxSlice.cpp under tools/converter/source/optimizer/onnxextra
  5. added SliceOnnx.cpp under tools/converter/source/onnx with:
//
//  SliceOnnx.cpp
//  MNNConverter
//
//  Created by MNN on 2019/07/17.
//  Copyright © 2018, Alibaba Group Holding Limited
//

#include "onnxOpConverter.hpp"

DECLARE_OP_CONVERTER(SliceOnnx);

MNN::OpType SliceOnnx::opType() {
    return MNN::OpType_SliceOnnx;
}

MNN::OpParameter SliceOnnx::type() {
    return MNN::OpParameter_SliceOnnx;
}

void SliceOnnx::run(MNN::OpT *dstOp, const onnx::NodeProto *onnxNode,
                      OnnxScope* scope) {
    return;
}

REGISTER_CONVERTER(SliceOnnx, Slice);

The compilation works fine but when I call the MNNConvert, it gives me the following error messge with LLDB:

(lldb) settings set -- target.run-args  "-f" "ONNX" "--modelFile" "minimum_slice/minimum_slice.onnx" "--MNNModel" "minimum_slice/minimum_slice.mnn" "--bizCode" "MNN"
(lldb) r
Process 50470 launched: '/Users/xxx/Develop/MNN/build/MNNConvert' (arm64)
hw.cpufamily: 458787763 , size = 4
The device support dot:1, support fp16:1, support i8mm: 0
Start to Convert Other Model Format To MNN Model...
[22:51:01] /Users/xxx/Develop/MNN/tools/converter/source/onnx/onnxConverter.cpp:40: ONNX Model ir version: 8
Start to Optimize the MNN Net...
Process 50470 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
    frame #0: 0x0000000100192ff8 libMNN_Express.dylib`MNN::CreateSliceOnnx(flatbuffers::FlatBufferBuilder&, MNN::SliceOnnxT const*, std::__1::function<unsigned long long (void*)> const*) + 24
libMNN_Express.dylib`MNN::CreateSliceOnnx:
->  0x100192ff8 <+24>: ldp    x8, x9, [x1]
    0x100192ffc <+28>: subs   x10, x9, x8
    0x100193000 <+32>: b.eq   0x10019308c               ; <+172>
    0x100193004 <+36>: asr    x2, x10, #2
Target 0: (MNNConvert) stopped.
(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
  * frame #0: 0x0000000100192ff8 libMNN_Express.dylib`MNN::CreateSliceOnnx(flatbuffers::FlatBufferBuilder&, MNN::SliceOnnxT const*, std::__1::function<unsigned long long (void*)> const*) + 24
    frame #1: 0x000000010018f150 libMNN_Express.dylib`MNN::CreateOp(flatbuffers::FlatBufferBuilder&, MNN::OpT const*, std::__1::function<unsigned long long (void*)> const*) + 92
    frame #2: 0x0000000100188b7c libMNN_Express.dylib`MNN::Express::Expr::create(MNN::OpT const*, std::__1::vector<MNN::Express::VARP, std::__1::allocator<MNN::Express::VARP> >, int) + 544
    frame #3: 0x0000000100ae7b98 libMNNConvertDeps.dylib`MNN::Express::Program::createUnit(std::__1::map<int, MNN::Express::VARP, std::__1::less<int>, std::__1::allocator<std::__1::pair<int const, MNN::Express::VARP> > >&, std::__1::vector<int, std::__1::allocator<int> >&, std::__1::vector<std::__1::unique_ptr<MNN::OpT, std::__1::default_delete<MNN::OpT> >, std::__1::allocator<std::__1::unique_ptr<MNN::OpT, std::__1::default_delete<MNN::OpT> > > > const&, MNN::OpT*, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&, std::__1::set<MNN::OpT*, std::__1::less<MNN::OpT*>, std::__1::allocator<MNN::OpT*> >&, std::__1::set<int, std::__1::less<int>, std::__1::allocator<int> >&) + 2252
    frame #4: 0x0000000100ae8af0 libMNNConvertDeps.dylib`MNN::Express::Program::create(std::__1::vector<std::__1::unique_ptr<MNN::OpT, std::__1::default_delete<MNN::OpT> >, std::__1::allocator<std::__1::unique_ptr<MNN::OpT, std::__1::default_delete<MNN::OpT> > > > const&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&, bool, bool) + 156
    frame #5: 0x0000000100ae0248 libMNNConvertDeps.dylib`MNN::Express::RunExtraPass(std::__1::unique_ptr<MNN::NetT, std::__1::default_delete<MNN::NetT> >&, std::__1::unordered_map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, MNN::Express::VARP, std::__1::hash<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::equal_to<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, MNN::Express::VARP> > > const&) + 60
    frame #6: 0x0000000100ae0dd8 libMNNConvertDeps.dylib`MNN::Express::optimizeNetImpl(std::__1::unique_ptr<MNN::NetT, std::__1::default_delete<MNN::NetT> >&, std::__1::unordered_map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, MNN::Express::VARP, std::__1::hash<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::equal_to<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, MNN::Express::VARP> > > const&) + 1096
    frame #7: 0x0000000100ae35bc libMNNConvertDeps.dylib`optimizeNet(std::__1::unique_ptr<MNN::NetT, std::__1::default_delete<MNN::NetT> >&, bool, modelConfig&) + 660
    frame #8: 0x000000010099a5a0 libMNNConvertDeps.dylib`MNN::Cli::convertModel(modelConfig&) + 3000
    frame #9: 0x0000000100003e6c MNNConvert`main + 196
    frame #10: 0x000000018906fe50 dyld`start + 2544

This is so weird since the error message shows the error happens at creating the new OP, and the function CreateSliceOnnx() is generated under schema/current/CaffeOp_generated.h

Any ideas on this? Thanks in advance.

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