环境 win10 onnxruntime 1.15.1
在使用yolov5 进行推理部署时,一直报错Ort::Exception: 读取内存冲突等
,后分析发现,是声明的 Ort相关变量都是局部变量,需要修改成全局变量,如下所示,我是在.h文件中声明的。
Env env = Env(ORT_LOGGING_LEVEL_ERROR, “yolov5s”);
Ort::Session* ort_session = nullptr;
SessionOptions sessionOptions = SessionOptions();
vector<const char* > input_names;
vector<const char* > output_names;
vector<vector<int64_t>> input_node_dims; // >=1 outputs
vector<vector<int64_t>> output_node_dims; // >=1 outputs
std::vector In_AllocatedStringPtr;
std::vector Out_AllocatedStringPtr;
还有一个问题就是 onnxruntime 在1.12版本以后 不能使用GetInputName,需要改成GetInputNameAllocated,并且 需要使用
.h内
std::vector<AllocatedStringPtr> In_AllocatedStringPtr;
std::vector<AllocatedStringPtr> Out_AllocatedStringPtr; 来获取相关信息,
.cpp内
AllocatorWithDefaultOptions allocator;
In_AllocatedStringPtr.push_back(ort_session->GetInputNameAllocated(i, allocator));
input_names.push_back(In_AllocatedStringPtr.at(i).get());
AllocatorWithDefaultOptions allocator;
Out_AllocatedStringPtr.push_back(ort_session->GetOutputNameAllocated(i, allocator));
output_names.push_back(Out_AllocatedStringPtr.at(i).get());
microsoft/onnxruntime: 是一个用于运行各种机器学习模型的开源库。适合对机器学习和深度学习有兴趣的人,特别是在开发和部署机器学习模型时需要处理各种不同框架和算子的人。特点是支持多种机器学习框架和算子,包括 TensorFlow、PyTorch、Caffe 等,具有高性能和广泛的兼容性。
最近提交(Master分支:4 个月前 )
ff8465ed
### Description
Use onnx_protobuf.h to suppress some GCC warnings.
All the changes are autogenerated by a shell command.
```bash
find . -type f -exec sed -i 's/#include\s\+<onnx\/onnx_pb.h>/#include "core\/graph\/onnx_protobuf.h"/g' {} \;
```
### Motivation and Context
This PR is needed for making vcpkg work(without disabling all warnings)
This PR is split from another bigger PR per request from a reviewer. 11 小时前
c9614fbf
### Description
Suppress some strict-aliasing related warnings in WebGPU EP
For example:
```
/home/chasun/src/onnxruntime/onnxruntime/core/providers/webgpu/math/unary_elementwise_ops.cc:208:30: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
208 | float encoded_value = *reinterpret_cast<const float*>(attr);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```
This PR does not really fix the problems. It just suppresses the
warnings to make build pass. Some issues related to strict aliasing may
be fixed by using std::bit_cast, which requires c++20 however.
### Motivation and Context
Build the code on Azure Linux 3 fails. To reproduce the issue, you may
get an AzureLinux3 machine and run:
```
python3 tools/ci_build/build.py --update --build --build_wheel --use_xnnpack --build_nodejs --use_webgpu --build_dir b --skip_submodule_sync --parallel --use_binskim_compliant_compile_flags --build_shared_lib --config Release
``` 14 小时前
所有评论(0)