Conversation
|
/build |
Greptile SummaryThis PR fixes the Key changes:
Confidence Score: 5/5Safe to merge — the rank-1 shift logic is correct, the static_assert guards cleanly resolve the prior rank≥3 concern, and all three new test cases verify the expected modular-shift arithmetic. All previously raised P1 concerns (SHIFT_DIM_ aliasing for rank≥3, missing rank-3 test coverage) are resolved by the new static_asserts. The only remaining findings from prior threads (JIT double-indentation, missing trailing newline) are P2 style issues that do not affect runtime correctness or compilation. No new P0/P1 issues were found during this review pass. No files require special attention beyond the pre-existing style items already flagged in prior threads. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["shift<DIM>(op, shift_op)"] --> B{shift_rank_ == 1?}
B -- "Yes (rank-1 tensor)" --> C["static_assert: get_rank<T1>() == 2"]
C --> D["SHIFT_DIM_ = DIM==0 ? 1 : 0"]
D --> E["Validate: shift_.Size(0) == sizes_[SHIFT_DIM_]"]
E --> F["get_impl: shift = -get_value(shiftin, idx[SHIFT_DIM_])"]
B -- "No (scalar / rank-0)" --> G["shift_rank_ == 0: pass size check"]
G --> H["get_impl: shift = -get_value(shiftin, indices...)"]
F --> I["shift = (shift + idx[DIM]) % sizes[DIM]"]
H --> I
I --> J{"shift < 0?"}
J -- Yes --> K["shift += sizes[DIM]"]
J -- No --> L["idx[DIM] = shift"]
K --> L
L --> M["return get_value(op, idx)"]
Reviews (3): Last reviewed commit: "Fixing issue with rank 3" | Re-trigger Greptile |
include/matx/operators/shift.h
Outdated
| static_assert(shift_rank_ <= 1, "Shift operator must be rank 0 or rank 1. Higher-rank shift operators are not supported."); | ||
| static_assert(shift_rank_ != 1 || detail::get_rank<T1>() >= 2, | ||
| "Rank-1 shift operator requires input operator of rank 2 or higher"); |
There was a problem hiding this comment.
No test coverage for rank ≥ 3 with rank-1 shift
The static_assert only blocks rank < 2 for T1 when shift_rank_ == 1, which means rank-3+ tensors compile successfully. However, as noted in the SHIFT_DIM_ comment, rank ≥ 3 exhibits unintuitive behavior (multiple DIMs alias to the same SHIFT_DIM_). Given that this path is reachable and has subtleties, it would be worth either:
- Adding a test that explicitly documents the rank-3 behavior, or
- Strengthening the
static_asserttodetail::get_rank<T1>() == 2to limit rank-1 shift operators to rank-2 inputs only until the higher-rank case is fully designed and tested.
The
shift()operator can take an operator as an input to provide multiple shift values along an axis. This should be limited to 0 or 1D operators. This feature was not working and produced incorrect results. Unit tests and examples in the docs added to cover this case.