Conversation
The static_assert in LinspaceOp::operator() checked sizeof...(indices) == NUM_RC, but the operator is always rank 2 when NUM_RC > 1. With 3+ firsts/lasts entries, the operator is called with 2 indices but the assert expected 3+, causing a compile error. Added unit tests to cover these cases
|
/build |
Greptile SummaryThis PR fixes a compile error in Key changes:
The fix is minimal, correct, and Confidence Score: 5/5This PR is safe to merge — it is a minimal, well-reasoned bug fix with no logic changes beyond the corrected static_assert. The root cause is clearly identified and the fix ( No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["linspace(firsts, lasts, count, axis)"] --> B["LinspaceOp<T, NUM_RC> constructed"]
B --> C{"NUM_RC == 1?"}
C -- Yes --> D["Rank() = 1"]
C -- No --> E["Rank() = 2 (regardless of NUM_RC)"]
D --> F["operator()(idx0)\nstatic_assert: sizeof...(indices) == Rank()"]
E --> G["operator()(idx0, idx1)\nstatic_assert: sizeof...(indices) == Rank()"]
G --> H{"axis_ == 0?"}
H -- Yes --> I["firsts_[idx1] + steps_[idx1] * idx0"]
H -- No --> J["firsts_[idx0] + steps_[idx0] * idx1"]
F --> K["firsts_[0] + steps_[0] * idx0"]
Reviews (2): Last reviewed commit: "Added examples" | Re-trigger Greptile |
Fix linspace static_assert failing when NUM_RC > 2
The static_assert in LinspaceOp::operator() checked sizeof...(indices) == NUM_RC, but the operator is always rank 2 when NUM_RC > 1. With 3+ firsts/lasts entries, the operator is called with 2 indices but the assert expected 3+, causing a compile error.