Repository navigation
Fix: xgenerator reports memory overlap to avoid in-place assignment corruption - #2936
Conversation
80a1441 to
e8acbeb
Compare
Merging this PR will not alter performance
|
JohanMabille
left a comment
There was a problem hiding this comment.
Approving it since it fixes an issue, but I find this solution too cautious. Most generators do not read values and will suffer a performance hit with this change.
However fixing it properly required more involve changes that should be done in a dedicated PR.
|
I'll look into more, thanks for merging this PR
|
Do not hesitate if you have questions, the issue I opened to track it is not very detailed. And thanks again for the fix! |
Since xtensor-stack#2936 every xgenerator reports a possible memory overlap, so assigning arange, linspace, eye or a random expression allocates a full-size temporary even though these never read array memory. Add an is_memory_independent_generator trait on generator functors and use it in xgenerator's overlapping_memory_checker_traits. It defaults to false, so functors that hold expressions (concatenate, stack, diagonal, ...) and unknown functors keep the overlap protection. Opt in arange_generator with arithmetic types, eye_fn and random_impl; fn_impl forwards to the functor it wraps. Related to xtensor-stack#2943. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Fixes #2819. xgenerator's overlapping_memory_checker_traits returned false unconditionally, so assignment from an xgenerator reading its resized target (e.g. xt::concatenate into itself) could read uninitialized memory. Report true so a temporary is used. Root cause analysis in BYTEASK.md.