Change to std::fill (#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: https://github.com/microsoft/onnxruntime/pull/21525

Cc: @ranjitshs
This commit is contained in:
Dmitri Smirnov 2024-08-15 16:16:54 -07:00 committed by GitHub
parent b9f3a5d5b6
commit 754dba2674
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

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