Fix negative dimension handling in narrow_copy (#22969) - #22969
Conversation
|
@JakeStevens has exported this pull request. If you are a Meta employee, you can view the originating Diff in D121015244. |
This PR needs a
|
|
The valid-negative-dimension fix works, but moving normalization before validation introduces a process-abort regression for out-of-range negative dimensions. For input shape I reproduced this with the portable C++ kernel on macOS arm64, comparing head
The other nine tests pass on the PR. Despite its name, Please reject dimensions that remain negative after normalization, or validate the original dimension range before normalization. As a local diagnostic, changing the validation condition to the following made all 10 tests pass: dim >= 0 && check_narrow_copy_args(in, dim, start, length, out) |
narrow_copynarrow_copy (#22969)
Summary: Resolves: pytorch#13556 Normalize negative `dim` values before validating `narrow_copy` arguments. This prevents valid negative dimensions from reaching tensor size checks unnormalized and causing a runtime assertion. Adds regression coverage for copying with `dim=-1`. Differential Revision: D121015244
d3d29fd to
4e7d7bf
Compare
Summary: Resolves: pytorch#13556 Normalize negative `dim` values before validating `narrow_copy` arguments. This prevents valid negative dimensions from reaching tensor size checks unnormalized and causing a runtime assertion. Adds regression coverage for copying with `dim=-1`. Reviewed By: mergennachin Differential Revision: D121015244
4e7d7bf to
dc8083c
Compare
Summary: Resolves: pytorch#13556 Normalize negative `dim` values before validating `narrow_copy` arguments. This prevents valid negative dimensions from reaching tensor size checks unnormalized and causing a runtime assertion. Adds regression coverage for copying with `dim=-1`. Reviewed By: mergennachin Differential Revision: D121015244
dc8083c to
e26ff92
Compare
Summary: Pull Request resolved: pytorch#22969 Resolves: pytorch#13556 Normalize negative `dim` values before validating `narrow_copy` arguments. This prevents valid negative dimensions from reaching tensor size checks unnormalized and causing a runtime assertion. Adds regression coverage for copying with `dim=-1`. Reviewed By: mergennachin Differential Revision: D121015244
e26ff92 to
46f544a
Compare
Summary: Resolves: pytorch#13556 Normalize negative `dim` values before validating `narrow_copy` arguments. This prevents valid negative dimensions from reaching tensor size checks unnormalized and causing a runtime assertion. Adds regression coverage for copying with `dim=-1`. Reviewed By: mergennachin Differential Revision: D121015244
46f544a to
67d384d
Compare
Summary:
Resolves: #13556
Normalize negative
dimvalues before validatingnarrow_copyarguments. This prevents valid negative dimensions from reaching tensor size checks unnormalized and causing a runtime assertion.Adds regression coverage for copying with
dim=-1.Reviewed By: mergennachin
Differential Revision: D121015244