fix: Correct stride calculation in AffineRank2RowMajor::packed()#3048
Open
bledden wants to merge 1 commit intoNVIDIA:mainfrom
Open
fix: Correct stride calculation in AffineRank2RowMajor::packed()#3048bledden wants to merge 1 commit intoNVIDIA:mainfrom
bledden wants to merge 1 commit intoNVIDIA:mainfrom
Conversation
The packed() method was returning AffineRank2RowMajor(1, extent.row()), which sets row_stride=1 and column_stride=num_rows — identical to the column-major version. For a tightly packed row-major layout, columns should be contiguous (stride=1) and rows should be strided by the number of columns. Fixed to return AffineRank2RowMajor(extent.column(), 1), which is consistent with the single-argument constructor and the Affine2Layout_Factory specialization. Fixes NVIDIA#2991 Signed-off-by: Blake Ledden <bledden@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
I noticed that
AffineRank2RowMajor::packed()returnsAffineRank2RowMajor(1, extent.row()), which is identical to the column-major version. For a tightly packed row-major layout, columns should be contiguous (stride=1) and rows should be strided by the number of columns — so the correct call isAffineRank2RowMajor(extent.column(), 1).This is consistent with:
stride_[0] = stride; stride_[1] = 1)Affine2Layout_Factory<AffineRank2RowMajor>specialization, which multiplies byextent[1](columns) for the row stridecapacity()method, which computesextent.row() * stride_[0]— currently returningrows * 1instead ofrows * colsVerification
For a 4×8 matrix:
packed({4, 8})→ row_stride=1, col_stride=4, capacity=4packed({4, 8})→ row_stride=8, col_stride=1, capacity=32Fixes #2991
Signed-off-by: Blake Ledden bledden@users.noreply.github.com