mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-05-27 22:45:57 +00:00
Fix Prefast Errors (#15651)
This PR adds fixes for prefast errors with the following codes: - C26814 - C26451 - C26400
This commit is contained in:
parent
4c3e350a6a
commit
f44f6c5b2e
15 changed files with 19 additions and 18 deletions
|
|
@ -443,7 +443,7 @@ namespace Dml
|
|||
ID3D12Resource* dstData = dstAllocInfo->GetResource();
|
||||
const void* srcData = src->GetData();
|
||||
|
||||
const uint64_t dstOffset = 0;
|
||||
constexpr uint64_t dstOffset = 0;
|
||||
const auto dstState = D3D12_RESOURCE_STATE_UNORDERED_ACCESS; // GPU resources are always kept in UAV state
|
||||
|
||||
m_uploadHeap->BeginUploadToGpu(dstData, dstOffset, dstState, AsByteSpan(srcData, dataSizeInBytes));
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@ inline UINT64 DMLCalcBufferTensorSize(
|
|||
}
|
||||
else
|
||||
{
|
||||
UINT indexOfLastElement = 0;
|
||||
UINT64 indexOfLastElement = 0;
|
||||
for (UINT i = 0; i < dimensionCount; ++i)
|
||||
{
|
||||
indexOfLastElement += (sizes[i] - 1) * strides[i];
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ public:
|
|||
{
|
||||
const uint32_t onnxDimCount = gsl::narrow_cast<uint32_t>(kernelCreationContext.GetTensorShapeDescription().GetInputTensorShape(0).size());
|
||||
int axis = HandleNegativeAxis(kernelCreationContext.GetOptionalAttribute<int>(AttrName::Axis, 1), onnxDimCount);
|
||||
std::vector<int32_t> onnxAxes(onnxDimCount - axis);
|
||||
std::vector<int32_t> onnxAxes(static_cast<uint64_t>(onnxDimCount) - axis);
|
||||
std::iota(onnxAxes.begin(), onnxAxes.end(), static_cast<int32_t>(axis));
|
||||
|
||||
dmlAxes.resize(onnxDimCount - axis);
|
||||
|
|
|
|||
|
|
@ -13,7 +13,8 @@ public:
|
|||
: DmlOperator(kernelCreationContext),
|
||||
EinSumHelper(kernelCreationContext, kernelCreationContext.GetTensorShapeDescription(), opsetVersion)
|
||||
{
|
||||
ML_CHECK_VALID_ARGUMENT(kernelCreationContext.GetInputCount() + 1 == m_components.size(), "EinSum input tensor count is inconsistent with the equation component count.");
|
||||
ML_CHECK_VALID_ARGUMENT(static_cast<uint64_t>(kernelCreationContext.GetInputCount()) + 1 == m_components.size(),
|
||||
"EinSum input tensor count is inconsistent with the equation component count.");
|
||||
ML_CHECK_VALID_ARGUMENT(kernelCreationContext.GetOutputCount() == 1, "EinSum expects one output tensor.");
|
||||
|
||||
std::vector<std::optional<uint32_t>> inputIndices = {0,1,2};
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ void ComputePixelOffsetsAndScales(
|
|||
// Fill in all the input/output pixel offset for each axis,
|
||||
// and recompute the scale for certain modes.
|
||||
|
||||
for (uint32_t i = 0; i < rank; ++i)
|
||||
for (uint64_t i = 0; i < rank; ++i)
|
||||
{
|
||||
float inputPixelOffset = 0;
|
||||
float outputPixelOffset = 0;
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ TensorDesc::TensorDesc(
|
|||
dimension0 *= dimensions[i];
|
||||
}
|
||||
|
||||
for (size_t i = coerceAxis + 1, ci = dimensions.size(); i < ci; ++i)
|
||||
for (size_t i = static_cast<int64_t>(coerceAxis) + 1, ci = dimensions.size(); i < ci; ++i)
|
||||
{
|
||||
dimension1 *= dimensions[i];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -440,7 +440,7 @@ namespace OperatorHelper
|
|||
// if pads are not specified, assume all pad values are 0
|
||||
if (pads.empty())
|
||||
{
|
||||
pads.resize(2 * spatialDimensionCount);
|
||||
pads.resize(2 * static_cast<uint64_t>(spatialDimensionCount));
|
||||
}
|
||||
|
||||
ML_CHECK_VALID_ARGUMENT(pads.size() >= 2 * spatialDimensionCount);
|
||||
|
|
|
|||
|
|
@ -227,7 +227,7 @@ class CpuDetensorizer {
|
|||
xChannel += 8;
|
||||
yChannel += 8;
|
||||
zChannel += 8;
|
||||
pPixel += 8 * bytesPerPixel;
|
||||
pPixel += 8 * static_cast<uint64_t>(bytesPerPixel);
|
||||
tensorWidthRemaining -= 8;
|
||||
}
|
||||
|
||||
|
|
@ -238,7 +238,7 @@ class CpuDetensorizer {
|
|||
pPixel[2] = DetensorizeValue(zChannel, nominalRangeConverter);
|
||||
pPixel[3] = 255;
|
||||
|
||||
pPixel += bytesPerPixel;
|
||||
pPixel += static_cast<uint64_t>(bytesPerPixel);
|
||||
xChannel++;
|
||||
yChannel++;
|
||||
zChannel++;
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ class CpuTensorizer {
|
|||
|
||||
if (formatFrom == kImageTensorChannelTypeBGR8 && formatTo == kImageTensorChannelTypeBGR8 || formatFrom == kImageTensorChannelTypeRGB8 && formatTo == kImageTensorChannelTypeRGB8) {
|
||||
// Convert BGR8 -> BGR8 or RGB8 -> RGB8
|
||||
for (uint32_t y = 0; y < yElements; y++) {
|
||||
for (uint64_t y = 0; y < yElements; y++) {
|
||||
DeinterleaveRowByteToFloat(
|
||||
pBuffer + y * bufferWidth + start,
|
||||
pCPUTensor + y * inputBounds.Width,
|
||||
|
|
|
|||
|
|
@ -579,7 +579,7 @@ void TensorToVideoFrameConverter::ConvertGPUTensorToSoftwareBitmap(
|
|||
auto barrier = CD3DX12_RESOURCE_BARRIER::Transition(pInputTensor, D3D12_RESOURCE_STATE_UNORDERED_ACCESS, D3D12_RESOURCE_STATE_COPY_SOURCE);
|
||||
command_list_->ResourceBarrier(1, &barrier);
|
||||
|
||||
command_list_->CopyBufferRegion(readback_heap_.Get(), 0, pInputTensor, singleVideoFramebufferSize * batchIdx, singleVideoFramebufferSize);
|
||||
command_list_->CopyBufferRegion(readback_heap_.Get(), 0, pInputTensor, static_cast<uint64_t>(singleVideoFramebufferSize) * batchIdx, singleVideoFramebufferSize);
|
||||
|
||||
WINML_THROW_IF_FAILED(command_list_->Close());
|
||||
ID3D12CommandList* ppCommandLists[] = {command_list_.Get()};
|
||||
|
|
|
|||
|
|
@ -446,7 +446,7 @@ void VideoFrameToTensorConverter::ConvertDX12TextureToGPUTensor(
|
|||
command_list_->SetComputeRootDescriptorTable(2, uavHandle);
|
||||
|
||||
UINT64 dispatchWidth = (inputDesc.Width - 1) / 16 + 1;
|
||||
UINT64 dispatchHeight = (inputDesc.Height - 1) / 4 + 1;
|
||||
UINT64 dispatchHeight = (static_cast<UINT64>(inputDesc.Height) - 1) / 4 + 1;
|
||||
command_list_->Dispatch(static_cast<uint32_t>(dispatchWidth), static_cast<uint32_t>(dispatchHeight), 1);
|
||||
|
||||
WINML_THROW_IF_FAILED(command_list_->Close());
|
||||
|
|
|
|||
|
|
@ -110,7 +110,7 @@ HRESULT OnnxruntimeValue::IsCpu(bool* out) {
|
|||
return S_OK;
|
||||
}
|
||||
|
||||
static int64_t ShapeSize(const int64_t* shape, size_t count) {
|
||||
static uint64_t ShapeSize(const int64_t* shape, size_t count) {
|
||||
// for each dim
|
||||
int64_t size = 1;
|
||||
for (size_t i = 0; i < count; i++) {
|
||||
|
|
@ -151,7 +151,7 @@ static auto GetStrings(const OrtApi* ort_api, const OrtValue* ort_value,
|
|||
ort_api);
|
||||
|
||||
// now go build all the strings
|
||||
for (auto i = 0; i < length; ++i) {
|
||||
for (size_t i = 0; i < length; ++i) {
|
||||
size_t str_len = 0;
|
||||
// are we on the last one?
|
||||
if (i == (length - 1)) {
|
||||
|
|
|
|||
|
|
@ -835,7 +835,7 @@ TEST_F(ImageTests, ImageBindingAsGPUTensor) {
|
|||
IRandomAccessStream stream = image_file.OpenAsync(FileAccessMode::Read).get();
|
||||
SoftwareBitmap software_bitmap = (BitmapDecoder::CreateAsync(stream).get()).GetSoftwareBitmapAsync().get();
|
||||
|
||||
UINT64 buffer_byte_size = software_bitmap.PixelWidth()*software_bitmap.PixelHeight() * 3 * sizeof(float);
|
||||
UINT64 buffer_byte_size = static_cast<uint64_t>(software_bitmap.PixelWidth()) * software_bitmap.PixelHeight() * 3 * sizeof(float);
|
||||
D3D12_HEAP_PROPERTIES heap_properties = {
|
||||
D3D12_HEAP_TYPE_DEFAULT,
|
||||
D3D12_CPU_PAGE_PROPERTY_UNKNOWN,
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ winml::ITensor CreateTensorFromShape(std::vector<int64_t>& shape)
|
|||
return tensor;
|
||||
}
|
||||
|
||||
static int64_t ShapeSize(const int64_t* shape, size_t count) {
|
||||
static uint64_t ShapeSize(const int64_t* shape, size_t count) {
|
||||
// for each dim
|
||||
int64_t size = 1;
|
||||
for (size_t i = 0; i < count; i++) {
|
||||
|
|
@ -46,7 +46,7 @@ winml::ITensor CreateStringTensor(Ort::Value& val) {
|
|||
WINML_EXPECT_NO_THROW(val.GetStringTensorContent(buffer.get(), bufferLength, offsets.data(), offsets.size()));
|
||||
|
||||
// now go build all the strings
|
||||
for (auto i = 0; i < length; ++i) {
|
||||
for (size_t i = 0; i < length; ++i) {
|
||||
size_t strLength = 0;
|
||||
// are we on the last one?
|
||||
if (i == (length - 1)) {
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ struct ReluShapeInferrer : winrt::implements<ReluShapeInferrer, IMLOperatorShape
|
|||
uint32_t inputDimsSize;
|
||||
context->GetInputTensorDimensionCount(0, &inputDimsSize);
|
||||
|
||||
uint32_t *inputDims = new uint32_t[inputDimsSize];
|
||||
auto inputDims = new uint32_t[inputDimsSize];
|
||||
context->GetInputTensorShape(0, inputDimsSize, inputDims);
|
||||
|
||||
context->SetOutputTensorShape(0, inputDimsSize, inputDims);
|
||||
|
|
|
|||
Loading…
Reference in a new issue