diff --git a/src/NumSharp.Core/Backends/Default/Math/Default.ClipNDArray.cs b/src/NumSharp.Core/Backends/Default/Math/Default.ClipNDArray.cs index fad73efd..51649fe8 100644 --- a/src/NumSharp.Core/Backends/Default/Math/Default.ClipNDArray.cs +++ b/src/NumSharp.Core/Backends/Default/Math/Default.ClipNDArray.cs @@ -56,6 +56,8 @@ public override NDArray ClipNDArray(NDArray lhs, NDArray min, NDArray max, NPTyp NumSharpException.ThrowIfNotWriteable(@out.Shape); if (@out.Shape != lhs.Shape) throw new ArgumentException($"@out's shape ({@out.Shape}) must match lhs's shape ({lhs.Shape}).'"); + // Copy input data into @out - user-provided @out may contain garbage (e.g., np.empty) + np.copyto(@out, lhs); } var len = @out.size;