From 063ee8d50468d8b0032e80830f0e887d53038f3d Mon Sep 17 00:00:00 2001 From: Bengt Gustafsson Date: Mon, 27 Mar 2023 23:17:28 +0200 Subject: [PATCH] =?UTF-8?q?Fixed=20some=20warnings=20that=20were=20treated?= =?UTF-8?q?=20as=20errors=20when=20compiling=20with=20D=E2=80=A6=20(#15157?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit …ML in Win32/MSVC. ### Description Use onnxruntime::narrow to silence some warnings that are turned into errors when compiling the DML provider in Win32. Also one case of warning turned to error for mixing int loop variable type with a vector size() as upper bound. ### Motivation and Context Solves [https://github.com/microsoft/onnxruntime/issues/14595](https://github.com/microsoft/onnxruntime/issues/14595) Co-authored-by: bengt.gustafsson --- .../DmlExecutionProvider/src/BucketizedBufferAllocator.cpp | 4 ++-- .../dml/DmlExecutionProvider/src/Operators/DmlDFT.h | 2 +- .../src/Operators/DmlOperatorConcatFromSequence.cpp | 2 +- .../dml/DmlExecutionProvider/src/Operators/DmlSTFT.h | 5 ++--- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/onnxruntime/core/providers/dml/DmlExecutionProvider/src/BucketizedBufferAllocator.cpp b/onnxruntime/core/providers/dml/DmlExecutionProvider/src/BucketizedBufferAllocator.cpp index 588c4ac391..f5abeb5d7b 100644 --- a/onnxruntime/core/providers/dml/DmlExecutionProvider/src/BucketizedBufferAllocator.cpp +++ b/onnxruntime/core/providers/dml/DmlExecutionProvider/src/BucketizedBufferAllocator.cpp @@ -114,7 +114,7 @@ namespace Dml if (bucket->resources.empty()) { // No more resources in this bucket - allocate a new one - resourceWrapper = m_subAllocator->Alloc(bucketSize); + resourceWrapper = m_subAllocator->Alloc(onnxruntime::narrow(bucketSize)); resourceId = ++m_currentResourceId; } else @@ -129,7 +129,7 @@ namespace Dml { // The allocation will not be pooled. Construct a new one bucketSize = (size + 3) & ~3; - resourceWrapper = m_subAllocator->Alloc(bucketSize); + resourceWrapper = m_subAllocator->Alloc(onnxruntime::narrow(bucketSize)); resourceId = ++m_currentResourceId; } diff --git a/onnxruntime/core/providers/dml/DmlExecutionProvider/src/Operators/DmlDFT.h b/onnxruntime/core/providers/dml/DmlExecutionProvider/src/Operators/DmlDFT.h index 649cceb79d..636e17982d 100644 --- a/onnxruntime/core/providers/dml/DmlExecutionProvider/src/Operators/DmlDFT.h +++ b/onnxruntime/core/providers/dml/DmlExecutionProvider/src/Operators/DmlDFT.h @@ -290,7 +290,7 @@ public: ORT_THROW_IF_FAILED(outputUnknown.As(&outputResource)); // Get optional dft_length input - uint32_t dftLength = inputDims[m_axis]; + uint32_t dftLength = inputDims[onnxruntime::narrow(m_axis)]; ComPtr dftLengthTensor; if (SUCCEEDED(context->GetInputTensor(1, &dftLengthTensor)) && dftLengthTensor != nullptr) { diff --git a/onnxruntime/core/providers/dml/DmlExecutionProvider/src/Operators/DmlOperatorConcatFromSequence.cpp b/onnxruntime/core/providers/dml/DmlExecutionProvider/src/Operators/DmlOperatorConcatFromSequence.cpp index c9b38ccc90..31cf48e61b 100644 --- a/onnxruntime/core/providers/dml/DmlExecutionProvider/src/Operators/DmlOperatorConcatFromSequence.cpp +++ b/onnxruntime/core/providers/dml/DmlExecutionProvider/src/Operators/DmlOperatorConcatFromSequence.cpp @@ -108,7 +108,7 @@ public: auto outputDescs = std::vector { m_outputTensorDesc.GetDmlDesc() }; auto inputDescs = std::vector(m_inputTensorDescs.size()); - for (int i = 0; i < inputDescs.size(); i++) + for (size_t i = 0; i < inputDescs.size(); i++) { inputDescs[i] = m_inputTensorDescs[i].GetDmlDesc(); } diff --git a/onnxruntime/core/providers/dml/DmlExecutionProvider/src/Operators/DmlSTFT.h b/onnxruntime/core/providers/dml/DmlExecutionProvider/src/Operators/DmlSTFT.h index b11ed63972..dea5545fa1 100644 --- a/onnxruntime/core/providers/dml/DmlExecutionProvider/src/Operators/DmlSTFT.h +++ b/onnxruntime/core/providers/dml/DmlExecutionProvider/src/Operators/DmlSTFT.h @@ -378,8 +378,7 @@ public: ORT_THROW_IF_FAILED(executionObject.As(&commandList)); ComPtr framingOutputResource; - ORT_THROW_IF_FAILED(context->AllocateTemporaryData(m_framingOperator.outputBufferSizeInBytes, &framingOutputResource)); - + ORT_THROW_IF_FAILED(context->AllocateTemporaryData(onnxruntime::narrow(m_framingOperator.outputBufferSizeInBytes), &framingOutputResource)); DispatchFramingOperator(commandList.Get(), context, framingOutputResource.Get()); ComPtr outputResource = DmlSTFTHelpers::GetOutputResourceFromKernelContext(context, 0); @@ -450,7 +449,7 @@ public: auto tempBufferSize = bindingProps.TemporaryResourceSize; if (tempBufferSize > 0) { - ORT_THROW_IF_FAILED(context->AllocateTemporaryData(tempBufferSize, &tempBuffer)); + ORT_THROW_IF_FAILED(context->AllocateTemporaryData(onnxruntime::narrow(tempBufferSize), &tempBuffer)); DML_BUFFER_BINDING bufferBinding = { tempBuffer.Get(), 0, tempBufferSize }; DML_BINDING_DESC bindingDesc = { DML_BINDING_TYPE_BUFFER, &bufferBinding };