mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-07-02 03:55:34 +00:00
Fix Windows Inbox build failing on 1) building raw api tests and 2) referencing _winml namespace in onnxruntime.dll (#3872)
* add build inbox flag * remove raw tests and wstring for utf filenames * enable raw tests * use ToWideString * create new utf8 helper * update string helper to utf8 Co-authored-by: Sheil Kumar <sheilk@microsoft.com>
This commit is contained in:
parent
22a711457f
commit
cf6a1c1715
5 changed files with 30 additions and 7 deletions
|
|
@ -24,6 +24,8 @@ set(winml_lib_api_ort_dir ${REPO_ROOT}/winml/lib/api.ort)
|
|||
set(winml_lib_common_dir ${REPO_ROOT}/winml/lib/common)
|
||||
set(winml_lib_telemetry_dir ${REPO_ROOT}/winml/lib/telemetry)
|
||||
|
||||
set(winml_is_inbox false)
|
||||
|
||||
if (onnxruntime_WINML_NAMESPACE_OVERRIDE)
|
||||
set(output_name "${onnxruntime_WINML_NAMESPACE_OVERRIDE}.AI.MachineLearning")
|
||||
set(idl_native_output_name "${onnxruntime_WINML_NAMESPACE_OVERRIDE}.AI.MachineLearning.Native")
|
||||
|
|
@ -31,6 +33,7 @@ if (onnxruntime_WINML_NAMESPACE_OVERRIDE)
|
|||
|
||||
if (onnxruntime_WINML_NAMESPACE_OVERRIDE STREQUAL "Windows")
|
||||
set(winml_midl_defines "/DBUILD_INBOX=1")
|
||||
set(winml_is_inbox true)
|
||||
endif()
|
||||
|
||||
set(winml_root_ns "${onnxruntime_WINML_NAMESPACE_OVERRIDE}")
|
||||
|
|
|
|||
|
|
@ -80,11 +80,27 @@ function(get_winml_test_api_src
|
|||
output_winml_test_api_src
|
||||
)
|
||||
file(GLOB winml_test_api_src CONFIGURE_DEPENDS
|
||||
"${winml_test_src_path}/api/*.h"
|
||||
"${winml_test_src_path}/api/*.cpp"
|
||||
"${winml_test_src_path}/api/APITest.h"
|
||||
"${winml_test_src_path}/api/LearningModelAPITest.h"
|
||||
"${winml_test_src_path}/api/LearningModelBindingAPITest.h"
|
||||
"${winml_test_src_path}/api/LearningModelSessionAPITest.h"
|
||||
"${winml_test_src_path}/api/LearningModelAPITest.cpp"
|
||||
"${winml_test_src_path}/api/LearningModelBindingAPITest.cpp"
|
||||
"${winml_test_src_path}/api/LearningModelSessionAPITest.cpp")
|
||||
|
||||
if (NOT winml_is_inbox)
|
||||
file(GLOB winml_redist_only_api_src CONFIGURE_DEPENDS
|
||||
"${winml_test_src_path}/api/RawApiHelpers.h"
|
||||
"${winml_test_src_path}/api/RawApiTests.h"
|
||||
"${winml_test_src_path}/api/RawApiTestsGpu.h"
|
||||
"${winml_test_src_path}/api/RawApiHelpers.cpp"
|
||||
"${winml_test_src_path}/api/RawApiTests.cpp"
|
||||
"${winml_test_src_path}/api/RawApiTestsGpu.cpp"
|
||||
"${winml_test_src_path}/api/raw/*.h"
|
||||
"${winml_test_src_path}/api/raw/*.cpp")
|
||||
set(${output_winml_test_api_src} ${winml_test_api_src} PARENT_SCOPE)
|
||||
endif()
|
||||
|
||||
set(${output_winml_test_api_src} ${winml_test_api_src} ${winml_redist_only_api_src} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
function(get_winml_test_concurrency_src
|
||||
|
|
|
|||
|
|
@ -241,4 +241,5 @@ inline std::wstring ToWideString(const std::wstring& s) { return s; }
|
|||
#else
|
||||
inline std::string ToWideString(const std::string& s) { return s; }
|
||||
#endif
|
||||
|
||||
} // namespace onnxruntime
|
||||
|
|
|
|||
|
|
@ -20,10 +20,10 @@ std::string ToMBString(const std::wstring& s) {
|
|||
std::wstring ToWideString(const std::string& s) {
|
||||
if (s.size() >= static_cast<size_t>(std::numeric_limits<int>::max())) throw std::runtime_error("length overflow");
|
||||
const int src_len = static_cast<int>(s.size() + 1);
|
||||
const int len = MultiByteToWideChar(CP_ACP, 0, s.data(), src_len, nullptr, 0);
|
||||
const int len = MultiByteToWideChar(CP_UTF8, 0, s.data(), src_len, nullptr, 0);
|
||||
assert(len > 0);
|
||||
std::wstring ret(static_cast<size_t>(len) - 1, '\0');
|
||||
const int r = MultiByteToWideChar(CP_ACP, 0, s.data(), src_len, (wchar_t*)ret.data(), len);
|
||||
const int r = MultiByteToWideChar(CP_UTF8, 0, s.data(), src_len, (wchar_t*)ret.data(), len);
|
||||
assert(len == r);
|
||||
return ret;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,13 +11,13 @@
|
|||
#include "core/session/ort_apis.h"
|
||||
#include "winml_adapter_apis.h"
|
||||
#include "core/framework/error_code_helper.h"
|
||||
#include "core/common/common.h"
|
||||
|
||||
#include <io.h>
|
||||
#include <fcntl.h>
|
||||
#include <winrt/base.h>
|
||||
#include "google/protobuf/io/zero_copy_stream_impl.h"
|
||||
#include "core/framework/onnxruntime_typeinfo.h"
|
||||
#include "StringHelpers.h"
|
||||
|
||||
namespace winmla = Windows::AI::MachineLearning::Adapter;
|
||||
|
||||
|
|
@ -120,7 +120,10 @@ OrtModel::OrtModel(std::unique_ptr<onnx::ModelProto> model_proto) : model_proto_
|
|||
// factory methods for creating an ort model from a path
|
||||
static OrtStatus* CreateModelProto(const char* path, std::unique_ptr<onnx::ModelProto>& out) {
|
||||
int file_descriptor;
|
||||
auto wide_path = _winml::Strings::HStringFromUTF8(path);
|
||||
|
||||
auto path_str = std::string(path);
|
||||
auto wide_path = onnxruntime::ToWideString(path_str);
|
||||
|
||||
_set_errno(0); // clear errno
|
||||
_wsopen_s(
|
||||
&file_descriptor,
|
||||
|
|
|
|||
Loading…
Reference in a new issue