Skip to content

Commit dfeb3b4

Browse files
committed
[gpu] fix windows SEH exception issue
### Details: - Updated `create_data` to use the actual data size calculated from the original element type and shape for `u16`/`i16` types, ensuring `memcpy` only reads the valid memory region. ### Tickets: - *CVS-172561* Signed-off-by: zhanmyz <[email protected]>
1 parent fab9a56 commit dfeb3b4

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/plugins/intel_gpu/src/plugin/ops/constant.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,23 @@ static void create_data(ProgramBuilder& p, const ov::Shape& const_shape, const s
124124
const auto* f64data = op->get_data_ptr<double>();
125125
auto f32buf = reinterpret_cast<float*>(buf);
126126
f32buf[0] = static_cast<float>(f64data[0]);
127+
} else if (out_dtype == cldnn::data_types::f32 &&
128+
(op->get_output_element_type(0) == ov::element::u16 ||
129+
op->get_output_element_type(0) == ov::element::i16)) {
130+
size_t count = ov::shape_size(const_shape);
131+
auto f32buf = reinterpret_cast<float*>(buf);
132+
133+
if (op->get_output_element_type(0) == ov::element::u16) {
134+
const auto* u16data = op->get_data_ptr<uint16_t>();
135+
for (size_t i = 0; i < count; i++) {
136+
f32buf[i] = static_cast<float>(u16data[i]);
137+
}
138+
} else {
139+
const auto* i16data = op->get_data_ptr<int16_t>();
140+
for (size_t i = 0; i < count; i++) {
141+
f32buf[i] = static_cast<float>(i16data[i]);
142+
}
143+
}
127144
} else {
128145
std::memcpy(&buf[0], &data[0], bufSize);
129146
}

0 commit comments

Comments
 (0)