Skip to content

Commit 754dba2

Browse files
authored
Change to std::fill (microsoft#21759)
### Description Replace `memset(0)` with `std::fill(T{})`. This would ensure that all the types are initialized in a portable way. ### Motivation and Context Some platforms exhibit intermittent failures with NaN results. Follow up to: microsoft#21525 Cc: @ranjitshs
1 parent b9f3a5d commit 754dba2

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

Diff for: onnxruntime/core/providers/cpu/math/matmul.cc

+2-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@ Status MatMul<T>::Compute(OpKernelContext* ctx) const {
106106
if (helper.K() == 0) {
107107
// When we have (M, 0, N) then the inputs are empty, but the output should
108108
// be filled out with zeros.
109-
memset(y->MutableDataRaw(), 0, y->SizeInBytes());
109+
auto output_span = y->MutableDataAsSpan<T>();
110+
std::fill(output_span.begin(), output_span.end(), T{});
110111
return Status::OK();
111112
}
112113

0 commit comments

Comments
 (0)