Skip to content

[ML] Remove invalid Reshape() call on output tensor in RSampler#21448

Merged
siliataider merged 1 commit intoroot-project:masterfrom
siliataider:rsampler-check
Mar 2, 2026
Merged

[ML] Remove invalid Reshape() call on output tensor in RSampler#21448
siliataider merged 1 commit intoroot-project:masterfrom
siliataider:rsampler-check

Conversation

@siliataider
Copy link
Contributor

This Pull request:

Changes or fixes:

RandomOver/UnderSampler takes RFlat2DMatrix &ShuffledTensor which may be default-constructed (size 0 at that point) and calls Reshape() on it, which will fail when it reaches the line assert(rows * cols == fRVec.size());, as it does not allocate storage.

The call is also unnecessary: few lines below that, the function calls ShuffleTensor() which which always resizes the output tensor internally (calls Resize(rows, cols))

So this PR removed the Reshape() call and relies on ShuffleTensor() to size the output tensor correctly.

Note

The assertion was triggered after moving the sampler implementation from header to source file in #21397

@siliataider siliataider marked this pull request as ready for review March 2, 2026 12:04
@siliataider siliataider requested a review from vepadulano as a code owner March 2, 2026 12:04
@siliataider siliataider self-assigned this Mar 2, 2026
@siliataider siliataider added the in:ML Everything under ROOT/ML label Mar 2, 2026
Copy link
Member

@vepadulano vepadulano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Small typo in the commit message 'Resahpe'

@siliataider siliataider changed the title [ML] Remove invalid Resahpe() call on output tensor in RSampler [ML] Remove invalid Reshape() call on output tensor in RSampler Mar 2, 2026
@github-actions
Copy link

github-actions bot commented Mar 2, 2026

Test Results

    20 files      20 suites   2d 20h 27m 13s ⏱️
 3 783 tests  3 782 ✅ 1 💤 0 ❌
69 642 runs  69 633 ✅ 9 💤 0 ❌

Results for commit 96f9455.

@siliataider siliataider merged commit e399cef into root-project:master Mar 2, 2026
28 of 30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

in:ML Everything under ROOT/ML

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants