Skip to content

Commit

Permalink
[Backend] fix ort backend windows build error (#2269)
Browse files Browse the repository at this point in the history
* support ort offline graph optimize option

* support ort offline graph optimize option

* [Backend] fix windows build error
  • Loading branch information
DefTruth committed Nov 2, 2023
1 parent 6a8cd4d commit cfebd24
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions fastdeploy/runtime/backends/ort/ort_backend.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,16 @@ namespace fastdeploy {
std::vector<OrtCustomOp*> OrtBackend::custom_operators_ =
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) {
option_ = option;
if (option.graph_optimization_level >= 0) {
Expand All @@ -47,7 +57,12 @@ bool OrtBackend::BuildOption(const OrtBackendOption& option) {
session_options_.SetExecutionMode(ExecutionMode(option.execution_mode));
}
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());
#endif
}

#ifdef WITH_DIRECTML
Expand Down

0 comments on commit cfebd24

Please sign in to comment.