[Performance] ClipNDArray with @out does redundant copy
Open
@Nucs is already working on this.
Since Mar 23, 2026.
api
performance
- Dominant language
- C#
- Stars
- 1.5k
- Forks
- 205
- Avg merge
- 7d 7h
- Merged PRs (30d)
- 2
Description
Problem
np.maximum/minimum/clip with @out parameter does two passes:
np.copyto(@out, lhs)- copy input to outputClipArrayMin(@out, min)- clip in-place
Root Cause
ClipArrayMin<T>(T* output, T* minArr, int size) operates in-place. No separate src parameter.
Fix
Add 3-operand kernel variants:
ClipArrayMinFromSource<T>(T* dest, T* src, T* minArr, int size)
// dest[i] = max(src[i], minArr[i]) - single pass
Same for ClipArrayMax and ClipArrayBounds.
Impact
Affects np.maximum, np.minimum, np.fmax, np.clip when @out is provided.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.