同一个MNN模型,同样的推理代码,windows运行推理正常,安卓和iOS必定崩溃
同样的MNN模型,同样的推理代码,在windows端一直运行推理正常。 而在安卓和iOS端加载模型成功,创建session会话也成功,但是每次必然会崩溃在这行代码: auto input_names = interpreter->getSessionInputAll(session);
这是崩溃在这行代码后紧接着的堆栈:
#00 pc 000000000040ec04 basic_string (/tmp/ndk-user/tmp/gnu-libstdc++/static-arm64-v8a-4.9/include/bits/basic_string.tcc:173 [Inline: _M_rep]) [arm64-v8a]
#01 pc 00000000001d3dc0 _M_clone_node (/Users/env/android-ndk-r10e/sources/cxx-stl/gnu-libstdc++/4.9/include/bits/stl_tree.h:421 [Inline: construct<std::pair<const std::basic_string
你的调用代码是什么样的?常见问题是 BackendConfig 在创建 session 前被释放了
auto m_net = std::shared_ptr<MNN::Interpreter>(MNN::Interpreter::createFromFile(model_path.c_str()));
if (!m_net) {
std::cerr << "load model fail" << std::endl;
return nullptr;
}
MNN::ScheduleConfig config;
config.type = MNN_FORWARD_CPU;
config.numThread = 1;
MNN::BackendConfig backendConfig;
backendConfig.precision = MNN::BackendConfig::Precision_Low;
config.backendConfig = &backendConfig;
session = m_net->createSession(config);
if (!session) {
std::cerr << "createSession fail" << std::endl;
return nullptr;
}
auto input_names = m_net->getSessionInputAll(session);
这个是我的调用代码,如果加载模型或创建session会话不成功,会直接返回,不会往后执行。现在windows执行这行代码成功,并且后面推理成功也正常。但android和iOS必定崩溃在这行代码。
- precision 设成 normal 试下
- MNN 是最新代码么?相关模型发我们看看
precision 设成 normal也一样,MNN是用的最新代码。 streamsta.zip 这个是使用的相关模型
我也是,2.9.0版本,getSessionInputAll就直接崩了 (MNN::Interpreter::getSessionInputAll(MNN::Session const*) const+24) (BuildId: 7cf42083d0d460022a1a7170a36c5057edeca4f5)
@jxt1234 你好,相关模型已提供,有什么结论吗
- 更新 mnn 代码到最新
- 用 MNNV2Basic.out 在 Android 上面测试看看 https://mnn-docs.readthedocs.io/en/latest/tools/test.html
这里无法复现问题