mirror of
https://github.com/PaddlePaddle/FastDeploy.git
synced 2025-10-15 05:01:00 +08:00
[Backend] fix ort backend windows build error (#2269)
* support ort offline graph optimize option * support ort offline graph optimize option * [Backend] fix windows build error
This commit is contained in:
@@ -31,6 +31,16 @@ namespace fastdeploy {
|
|||||||
std::vector<OrtCustomOp*> OrtBackend::custom_operators_ =
|
std::vector<OrtCustomOp*> OrtBackend::custom_operators_ =
|
||||||
std::vector<OrtCustomOp*>();
|
std::vector<OrtCustomOp*>();
|
||||||
|
|
||||||
|
std::wstring ToWstring(const std::string &str) {
|
||||||
|
unsigned len = str.size() * 2;
|
||||||
|
setlocale(LC_CTYPE, "");
|
||||||
|
wchar_t *p = new wchar_t[len];
|
||||||
|
mbstowcs(p, str.c_str(), len);
|
||||||
|
std::wstring wstr(p);
|
||||||
|
delete[] p;
|
||||||
|
return wstr;
|
||||||
|
}
|
||||||
|
|
||||||
bool OrtBackend::BuildOption(const OrtBackendOption& option) {
|
bool OrtBackend::BuildOption(const OrtBackendOption& option) {
|
||||||
option_ = option;
|
option_ = option;
|
||||||
if (option.graph_optimization_level >= 0) {
|
if (option.graph_optimization_level >= 0) {
|
||||||
@@ -47,7 +57,12 @@ bool OrtBackend::BuildOption(const OrtBackendOption& option) {
|
|||||||
session_options_.SetExecutionMode(ExecutionMode(option.execution_mode));
|
session_options_.SetExecutionMode(ExecutionMode(option.execution_mode));
|
||||||
}
|
}
|
||||||
if (!option.optimized_model_filepath.empty()) {
|
if (!option.optimized_model_filepath.empty()) {
|
||||||
|
#if (defined(_WIN32) || defined(_WIN64))
|
||||||
|
session_options_.SetOptimizedModelFilePath(
|
||||||
|
ToWstring(option.optimized_model_filepath).c_str());
|
||||||
|
#else
|
||||||
session_options_.SetOptimizedModelFilePath(option.optimized_model_filepath.c_str());
|
session_options_.SetOptimizedModelFilePath(option.optimized_model_filepath.c_str());
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef WITH_DIRECTML
|
#ifdef WITH_DIRECTML
|
||||||
|
Reference in New Issue
Block a user