mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-06-01 23:30:35 +00:00
Fix WinML warnings (#5228)
This commit is contained in:
parent
78a29aebbc
commit
cd663d58f5
13 changed files with 44 additions and 32 deletions
|
|
@ -152,6 +152,7 @@ file(GLOB winml_test_common_src CONFIGURE_DEPENDS
|
|||
"${WINML_TEST_SRC_DIR}/common/*.h"
|
||||
"${WINML_TEST_SRC_DIR}/common/*.cpp")
|
||||
add_library(winml_test_common STATIC ${winml_test_common_src})
|
||||
target_compile_options(winml_test_common PRIVATE /wd5205) # workaround cppwinrt SDK bug https://github.com/microsoft/cppwinrt/issues/584
|
||||
add_dependencies(winml_test_common
|
||||
onnx
|
||||
winml_api
|
||||
|
|
|
|||
|
|
@ -742,8 +742,8 @@ namespace OperatorHelper
|
|||
// Determine the number of output dimensions.
|
||||
ML_CHECK_VALID_ARGUMENT(inputDimensions.size() >= 1);
|
||||
ML_CHECK_VALID_ARGUMENT(indicesDimensions.size() >= 1);
|
||||
ML_CHECK_VALID_ARGUMENT(inputDimensions.size() > batchCount);
|
||||
ML_CHECK_VALID_ARGUMENT(indicesDimensions.size() > batchCount);
|
||||
ML_CHECK_VALID_ARGUMENT(static_cast<int64_t>(inputDimensions.size()) > static_cast<int64_t>(batchCount));
|
||||
ML_CHECK_VALID_ARGUMENT(static_cast<int64_t>(indicesDimensions.size()) > static_cast<int64_t>(batchCount));
|
||||
const uint32_t numberOfCoordinatesPerIndex = indicesDimensions.back();
|
||||
ML_CHECK_VALID_ARGUMENT(inputDimensions.size() >= batchCount + numberOfCoordinatesPerIndex);
|
||||
const uint32_t numberOfOutputDimensionsFromInput = static_cast<uint32_t>(inputDimensions.size()) - batchCount - numberOfCoordinatesPerIndex;
|
||||
|
|
|
|||
|
|
@ -582,7 +582,7 @@ def generate_build_tree(cmake_path, source_dir, build_dir, cuda_home, cudnn_home
|
|||
"OFF" if args.skip_winml_tests else "ON"),
|
||||
"-Donnxruntime_GENERATE_TEST_REPORTS=ON",
|
||||
"-Donnxruntime_DEV_MODE=" + (
|
||||
"OFF" if args.use_acl or args.use_armnn or args.use_winml or
|
||||
"OFF" if args.use_acl or args.use_armnn or
|
||||
(args.ios and is_macOS()) else "ON"),
|
||||
"-DPYTHON_EXECUTABLE=" + sys.executable,
|
||||
"-Donnxruntime_USE_CUDA=" + ("ON" if args.use_cuda else "OFF"),
|
||||
|
|
|
|||
|
|
@ -27,12 +27,12 @@ namespace _winml {
|
|||
}
|
||||
|
||||
DirectX::PackedVector::HALF NominalRangeConverter::Normalize(DirectX::PackedVector::HALF val) const {
|
||||
return val / scale - shift;
|
||||
return static_cast<DirectX::PackedVector::HALF>(val / scale - shift);
|
||||
}
|
||||
|
||||
#if defined(_M_AMD64) || defined(_M_IX86)
|
||||
__m128 NominalRangeConverter::Normalize(__m128 sse_data) const {
|
||||
__m128 sse_shift = _mm_set1_ps(shift);
|
||||
__m128 sse_shift = _mm_set1_ps(static_cast<float>(shift));
|
||||
__m128 sse_scale = _mm_set1_ps(scale);
|
||||
|
||||
auto sse_dived = _mm_div_ps(sse_data, sse_scale);
|
||||
|
|
@ -48,16 +48,16 @@ namespace _winml {
|
|||
}
|
||||
|
||||
DirectX::PackedVector::HALF NominalRangeConverter::Denormalize(DirectX::PackedVector::HALF val) const {
|
||||
return scale * (val + shift);
|
||||
return static_cast<DirectX::PackedVector::HALF>(scale * (val + shift));
|
||||
}
|
||||
|
||||
#if defined(_M_AMD64) || defined(_M_IX86)
|
||||
__m128 NominalRangeConverter::Denormalize(__m128 sse_data) const {
|
||||
__m128 sse_shift = _mm_set1_ps(shift);
|
||||
__m128 sse_shift = _mm_set1_ps(static_cast<float>(shift));
|
||||
__m128 sse_scale = _mm_set1_ps(scale);
|
||||
|
||||
auto sse_added = _mm_add_ps(sse_data, sse_shift);
|
||||
return _mm_mul_ps(sse_added, sse_scale);
|
||||
}
|
||||
#endif
|
||||
} // namespace _winml
|
||||
} // namespace _winml
|
||||
|
|
|
|||
|
|
@ -223,7 +223,7 @@ void CopyInputAcrossDevices() {
|
|||
constexpr size_t input_tensor_size = [&dimensions]() {
|
||||
size_t size = 1;
|
||||
for (auto dim : dimensions)
|
||||
size *= dim;
|
||||
size *= static_cast<size_t>(dim);
|
||||
return size;
|
||||
} ();
|
||||
|
||||
|
|
@ -259,7 +259,7 @@ void CopyInputAcrossDevices_DML() {
|
|||
constexpr size_t input_tensor_size = [&dimensions]() {
|
||||
size_t size = 1;
|
||||
for (auto dim : dimensions)
|
||||
size *= dim;
|
||||
size *= static_cast<size_t>(dim);
|
||||
return size;
|
||||
} ();
|
||||
|
||||
|
|
|
|||
|
|
@ -105,13 +105,13 @@ static void ModelGetVersion() {
|
|||
static void ModelGetInputCount() {
|
||||
size_t input_count;
|
||||
winml_adapter_api->ModelGetInputCount(squeezenet_model, &input_count);
|
||||
WINML_EXPECT_EQUAL(input_count, 1);
|
||||
WINML_EXPECT_EQUAL(input_count, 1u);
|
||||
}
|
||||
|
||||
static void ModelGetOutputCount() {
|
||||
size_t output_count;
|
||||
winml_adapter_api->ModelGetOutputCount(squeezenet_model, &output_count);
|
||||
WINML_EXPECT_EQUAL(output_count, 1);
|
||||
WINML_EXPECT_EQUAL(output_count, 1u);
|
||||
}
|
||||
|
||||
static void ModelGetInputName() {
|
||||
|
|
@ -163,7 +163,7 @@ static void ModelGetInputTypeInfo() {
|
|||
|
||||
size_t dim_count;
|
||||
ort_api->GetDimensionsCount(tensor_info, &dim_count);
|
||||
WINML_EXPECT_EQUAL(dim_count, 4);
|
||||
WINML_EXPECT_EQUAL(dim_count, 4u);
|
||||
|
||||
int64_t dim_values[4];
|
||||
ort_api->GetDimensions(tensor_info, dim_values, 4);
|
||||
|
|
@ -192,7 +192,7 @@ static void ModelGetOutputTypeInfo() {
|
|||
|
||||
size_t dim_count;
|
||||
ort_api->GetDimensionsCount(tensor_info, &dim_count);
|
||||
WINML_EXPECT_EQUAL(dim_count, 4);
|
||||
WINML_EXPECT_EQUAL(dim_count, 4u);
|
||||
|
||||
int64_t dim_values[4];
|
||||
ort_api->GetDimensions(tensor_info, dim_values, 4);
|
||||
|
|
@ -207,7 +207,7 @@ static void ModelGetOutputTypeInfo() {
|
|||
static void ModelGetMetadataCount() {
|
||||
size_t metadata_count;
|
||||
winml_adapter_api->ModelGetMetadataCount(metadata_model, &metadata_count);
|
||||
WINML_EXPECT_EQUAL(metadata_count, 2);
|
||||
WINML_EXPECT_EQUAL(metadata_count, 2u);
|
||||
}
|
||||
|
||||
static void ModelGetMetadata() {
|
||||
|
|
@ -218,15 +218,15 @@ static void ModelGetMetadata() {
|
|||
|
||||
winml_adapter_api->ModelGetMetadata(metadata_model, 0, &metadata_key, &metadata_key_len, &metadata_value, &metadata_value_len);
|
||||
WINML_EXPECT_EQUAL(std::string(metadata_key), "thisisalongkey");
|
||||
WINML_EXPECT_EQUAL(metadata_key_len, 14);
|
||||
WINML_EXPECT_EQUAL(metadata_key_len, 14u);
|
||||
WINML_EXPECT_EQUAL(std::string(metadata_value), "thisisalongvalue");
|
||||
WINML_EXPECT_EQUAL(metadata_value_len, 16);
|
||||
WINML_EXPECT_EQUAL(metadata_value_len, 16u);
|
||||
|
||||
winml_adapter_api->ModelGetMetadata(metadata_model, 1, &metadata_key, &metadata_key_len, &metadata_value, &metadata_value_len);
|
||||
WINML_EXPECT_EQUAL(std::string(metadata_key), "key2");
|
||||
WINML_EXPECT_EQUAL(metadata_key_len, 4);
|
||||
WINML_EXPECT_EQUAL(metadata_key_len, 4u);
|
||||
WINML_EXPECT_EQUAL(std::string(metadata_value), "val2");
|
||||
WINML_EXPECT_EQUAL(metadata_value_len, 4);
|
||||
WINML_EXPECT_EQUAL(metadata_value_len, 4u);
|
||||
}
|
||||
|
||||
static void ModelEnsureNoFloat16() {
|
||||
|
|
@ -328,4 +328,4 @@ const AdapterTestApi& getapi() {
|
|||
EnvConfigureCustomLoggerAndProfiler,
|
||||
};
|
||||
return api;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ static void CreateModelFromFilePath() {
|
|||
|
||||
static void CreateModelFromUnicodeFilePath() {
|
||||
LearningModel learningModel = nullptr;
|
||||
WINML_EXPECT_NO_THROW(APITest::LoadModel(L"UnicodePath\\こんにちは maçã\\foo.onnx", learningModel));
|
||||
WINML_EXPECT_NO_THROW(APITest::LoadModel(L"UnicodePath\\\u3053\u3093\u306B\u3061\u306F maçã\\foo.onnx", learningModel));
|
||||
}
|
||||
|
||||
static void CreateModelFileNotFound() {
|
||||
|
|
@ -45,7 +45,6 @@ static void CreateCorruptModel() {
|
|||
APITest::LoadModel(L"corrupt-model.onnx", learningModel),
|
||||
winrt::hresult_error,
|
||||
[](const winrt::hresult_error& e) -> bool {
|
||||
auto f = __HRESULT_FROM_WIN32(e.code());
|
||||
return e.code() == __HRESULT_FROM_WIN32(ERROR_FILE_CORRUPT);
|
||||
});
|
||||
}
|
||||
|
|
@ -309,4 +308,4 @@ const LearningModelApiTestsApi& getapi() {
|
|||
api.CloseModelCheckEval = SkipTest;
|
||||
}
|
||||
return api;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -320,7 +320,8 @@ static void NamedDimensionOverride()
|
|||
WINML_EXPECT_NO_THROW(device = LearningModelDevice(LearningModelDeviceKind::Cpu));
|
||||
|
||||
// the model input shape. the batch size, n, is overriden to 5
|
||||
int64_t n = 5, c = 3, h = 720, w = 720;
|
||||
uint32_t n = 5;
|
||||
int64_t c = 3, h = 720, w = 720;
|
||||
|
||||
LearningModelSessionOptions options;
|
||||
options.OverrideNamedDimension(L"None", n);
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ auto CreateModelAsBuffer(const wchar_t* model_path)
|
|||
std::streamsize size = input_stream.tellg();
|
||||
input_stream.seekg(0, std::ios::beg);
|
||||
|
||||
std::vector<char> buffer(size);
|
||||
std::vector<char> buffer(static_cast<std::vector<char>::size_type>(size));
|
||||
input_stream.read(buffer.data(), size);
|
||||
|
||||
return std::make_pair(buffer, size);
|
||||
|
|
@ -68,12 +68,10 @@ static void EvaluateNoInputCopy() {
|
|||
static void EvaluateFromModelFromBuffer() {
|
||||
std::wstring model_path = L"model.onnx";
|
||||
|
||||
size_t size;
|
||||
std::vector<char> buffer;
|
||||
std::tie(buffer, size) = CreateModelAsBuffer(model_path.c_str());
|
||||
auto [buffer, size] = CreateModelAsBuffer(model_path.c_str());
|
||||
|
||||
std::unique_ptr<ml::learning_model> model = nullptr;
|
||||
WINML_EXPECT_NO_THROW(model = std::make_unique<ml::learning_model>(buffer.data(), size));
|
||||
WINML_EXPECT_NO_THROW(model = std::make_unique<ml::learning_model>(buffer.data(), static_cast<size_t>(size)));
|
||||
|
||||
std::unique_ptr<ml::learning_model_device> device = nullptr;
|
||||
WINML_EXPECT_NO_THROW(device = std::make_unique<ml::learning_model_device>());
|
||||
|
|
|
|||
|
|
@ -82,6 +82,9 @@
|
|||
#define WINML_EXPECT_HRESULT_FAILED(hresult_expression) EXPECT_HRESULT_FAILED(hresult_expression)
|
||||
#define WINML_EXPECT_THROW_SPECIFIC(statement, exception, condition) EXPECT_THROW_SPECIFIC(statement, exception, condition)
|
||||
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable:4505) // unreferenced local function has been removed
|
||||
|
||||
static bool RuntimeParameterExists(std::wstring param)
|
||||
{
|
||||
std::string narrowParam = std::wstring_convert<std::codecvt_utf8<wchar_t>>().to_bytes(param);
|
||||
|
|
@ -89,7 +92,7 @@ static bool RuntimeParameterExists(std::wstring param)
|
|||
return no_gpu_tests != RuntimeParameters::Parameters.end() && no_gpu_tests->second != "0";
|
||||
}
|
||||
|
||||
static bool SkipGpuTests()
|
||||
static bool SkipGpuTests()
|
||||
{
|
||||
#ifndef USE_DML
|
||||
return true;
|
||||
|
|
@ -110,3 +113,5 @@ static bool SkipTestsImpactedByOpenMP() {
|
|||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
#pragma warning(pop)
|
||||
|
|
|
|||
|
|
@ -83,7 +83,10 @@ std::vector<int64_t> GetTypeSpecificDataFromTensorProto(
|
|||
template <>
|
||||
std::vector<uint8_t> GetTypeSpecificDataFromTensorProto(
|
||||
onnx::TensorProto tensorProto) {
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable:4244) // conversion with possible loss of data
|
||||
return std::vector<uint8_t>(std::begin(tensorProto.int32_data()), std::end(tensorProto.int32_data()));
|
||||
#pragma warning(pop)
|
||||
}
|
||||
template <>
|
||||
std::vector<double> GetTypeSpecificDataFromTensorProto(
|
||||
|
|
|
|||
|
|
@ -9,6 +9,9 @@ using TeardownClass = VoidTest;
|
|||
using SetupTest = VoidTest;
|
||||
using TeardownTest = VoidTest;
|
||||
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable:4505) // unreferenced local function has been removed
|
||||
|
||||
constexpr bool alwaysTrue() {
|
||||
return true;
|
||||
}
|
||||
|
|
@ -27,3 +30,5 @@ constexpr bool alwaysFalse() {
|
|||
static void SkipTest() {
|
||||
WINML_SKIP_TEST("");
|
||||
}
|
||||
|
||||
#pragma warning(pop)
|
||||
|
|
|
|||
|
|
@ -201,8 +201,8 @@ namespace ImageTestHelper {
|
|||
// Copy from Cpu to GPU
|
||||
D3D12_SUBRESOURCE_DATA CPUData = {};
|
||||
CPUData.pData = reinterpret_cast<BYTE*>(pCPUTensor);
|
||||
CPUData.RowPitch = bufferbytesize;
|
||||
CPUData.SlicePitch = bufferbytesize;
|
||||
CPUData.RowPitch = static_cast<LONG_PTR>(bufferbytesize);
|
||||
CPUData.SlicePitch = static_cast<LONG_PTR>(bufferbytesize);
|
||||
UpdateSubresources(cmdList.get(), pGPUResource.get(), imageUploadHeap.get(), 0, 0, 1, &CPUData);
|
||||
|
||||
// Close the command list and execute it to begin the initial GPU setup.
|
||||
|
|
|
|||
Loading…
Reference in a new issue