Skip to content

Commit 6443626

Browse files
fs-eireChangming Sun
andauthored
Suppress some warnings in WebGPU EP generated by GCC 13 (#23984)
### Description Replace #23445, resolve conflicts and add one new file. --------- Co-authored-by: Changming Sun <chasun@microsoft.com>
1 parent f18e9fa commit 6443626

File tree

7 files changed

+12
-18
lines changed

7 files changed

+12
-18
lines changed

onnxruntime/core/providers/webgpu/buffer_manager.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
#include <iosfwd>
77

8-
#include <webgpu/webgpu_cpp.h>
8+
#include "core/providers/webgpu/webgpu_external_header.h"
99

1010
#include "core/framework/execution_provider.h"
1111

onnxruntime/core/providers/webgpu/compute_context.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
#pragma once
55

6-
#include <webgpu/webgpu_cpp.h>
6+
#include "core/providers/webgpu/webgpu_external_header.h"
77

88
#include <utility>
99

onnxruntime/core/providers/webgpu/program_manager.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#include <string>
77
#include <unordered_map>
88

9-
#include <webgpu/webgpu_cpp.h>
9+
#include "core/providers/webgpu/webgpu_external_header.h"
1010

1111
#include "core/common/common.h"
1212

onnxruntime/core/providers/webgpu/shader_helper.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
#include <sstream>
77

8-
#include <webgpu/webgpu_cpp.h>
8+
#include "core/providers/webgpu/webgpu_external_header.h"
99

1010
#include "core/framework/tensor_shape.h"
1111

onnxruntime/core/providers/webgpu/tensor/pad.cc

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -146,27 +146,21 @@ Status Pad::ComputeInternal(ComputeContext& context) const {
146146
uint16_t value = math::floatToHalf(value_);
147147
std::memcpy(&value_uint32, &value, sizeof(value));
148148
} else {
149-
value_uint32 = *reinterpret_cast<const uint32_t*>(&value_);
149+
std::memcpy(&value_uint32, &value_, sizeof(value_uint32));
150150
}
151151
} else if (value_tensor) {
152152
ORT_ENFORCE(value_tensor->DataType() == input_tensor->DataType() && value_tensor->Shape().Size() == 1,
153153
"Value tensor should be a 1D tensor of size 1 with the same type as that of the input tensor");
154154
switch (data_type) {
155-
case ONNX_NAMESPACE::TensorProto_DataType_INT32: {
156-
int32_t value = value_tensor->Data<int32_t>()[0];
157-
value_uint32 = *reinterpret_cast<uint32_t*>(&value);
158-
} break;
159-
case ONNX_NAMESPACE::TensorProto_DataType_FLOAT: {
160-
float value = value_tensor->Data<float>()[0];
161-
value_uint32 = *reinterpret_cast<uint32_t*>(&value);
162-
} break;
163155
case ONNX_NAMESPACE::TensorProto_DataType_FLOAT16: {
164156
uint16_t value = value_tensor->Data<MLFloat16>()[0].val;
165157
std::memcpy(&value_uint32, &value, sizeof(value));
166158
} break;
167-
case ONNX_NAMESPACE::TensorProto_DataType_UINT32: {
168-
value_uint32 = value_tensor->Data<uint32_t>()[0];
169-
} break;
159+
case ONNX_NAMESPACE::TensorProto_DataType_INT32:
160+
case ONNX_NAMESPACE::TensorProto_DataType_FLOAT:
161+
case ONNX_NAMESPACE::TensorProto_DataType_UINT32:
162+
std::memcpy(&value_uint32, value_tensor->DataRaw(), sizeof(value_uint32));
163+
break;
170164
default:
171165
return ORT_MAKE_STATUS(ONNXRUNTIME, INVALID_ARGUMENT, "Unsupported input type: ", static_cast<int>(data_type));
172166
}

onnxruntime/core/providers/webgpu/webgpu_context.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#include <memory>
77
#include <mutex>
88

9-
#include <webgpu/webgpu_cpp.h>
9+
#include "core/providers/webgpu/webgpu_external_header.h"
1010

1111
#include "core/common/common.h"
1212
#include "core/framework/library_handles.h"

onnxruntime/core/providers/webgpu/webgpu_pix_frame_generator.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
#include <memory>
1616

17-
#include <webgpu/webgpu_cpp.h>
17+
#include "core/providers/webgpu/webgpu_external_header.h"
1818

1919
namespace onnxruntime {
2020

0 commit comments

Comments
 (0)