diff --git a/onnxruntime/core/providers/cpu/math/matmul.cc b/onnxruntime/core/providers/cpu/math/matmul.cc index 16bb1ddfce..e95ac44af1 100644 --- a/onnxruntime/core/providers/cpu/math/matmul.cc +++ b/onnxruntime/core/providers/cpu/math/matmul.cc @@ -106,7 +106,8 @@ Status MatMul::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(); + std::fill(output_span.begin(), output_span.end(), T{}); return Status::OK(); }