FAILURE MAP
← Case archive

FA-98766 / Tensor stride and reshape semantics / Open access

Tensor views: reshape inferred dimension uses exact element count · case 01

reshape inferred dimension uses exact element count.

Verified by executionVariant 1 · 6 checks per implementationDownload source bundle ↓JSON ↗

ROOT CAUSE

The inferred size is copied from one input axis instead of derived from total element count.

THE FAILURE

The inferred size is copied from one input axis instead of derived from total element count.

Unsuccessful approach: Using only one input axis gives the right answer for some shapes but fails flattening.

Case contract

Infer one -1 dimension from element count; reject nonintegral inference is outside contract.

Why this case matters

Dense tensor views rely on consistent logical coordinates and physical storage addresses.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(shape, target):
    return [shape[0] if d==-1 else d for d in target]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('matrix to rows',solve([N,3],[-1,3]),[N,3])
check('flatten',solve([2,N],[-1]),[2*N])
check('infer leading',solve([2,3],[-1,2]),[3,2])
check('no inference',solve([2,3],[3,2]),[3,2])
check('unit count',solve([1],[-1,1]),[1,1])
check('rank zero target',solve([1],[]),[])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
matrix to rows[1, 3][1, 3]Passed
flatten[2][2]Passed
infer leading[2, 2][3, 2]Failed
no inference[3, 2][3, 2]Passed
unit count[1, 1][1, 1]Passed
rank zero target[][]Passed

SHA-256 / 1ca7046d6fc3c9ccc15430c45cf35df71e40434454698df1308c3e0c02c777c4

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(shape, target):
    total=1
    for d in shape: total*=d
    out=list(target)
    for i,d in enumerate(out):
     if d==-1: out[i]=total//(out[i-1] if i else 1); break
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('matrix to rows',solve([N,3],[-1,3]),[N,3])
check('flatten',solve([2,N],[-1]),[2*N])
check('infer leading',solve([2,3],[-1,2]),[3,2])
check('no inference',solve([2,3],[3,2]),[3,2])
check('unit count',solve([1],[-1,1]),[1,1])
check('rank zero target',solve([1],[]),[])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
matrix to rows[3, 3][1, 3]Failed
flatten[2][2]Passed
infer leading[6, 2][3, 2]Failed
no inference[3, 2][3, 2]Passed
unit count[1, 1][1, 1]Passed
rank zero target[][]Passed

SHA-256 / 6c09eb8a0cd26b07477d92be2c3cc9c1280220f6d6a83bdce6b9a6e17278282d

HELD IN THE MEMBER ARCHIVE

The verified repair and its recorded checks are member-only.

This mechanism has 6 recorded checks per implementation. The open-access tier publishes the failure and the unsuccessful fix; the repaired source that passes every check, and the observations that prove it, are available to members.

Every case sharing this mechanism uses the same contract and the same repair, so this one record is held back for all of them.

Member access is invitation-based. Sign in with your invited account to inspect the repair.

Sign in to the archive ↗

Verification & scope

Self-contained integer metadata models only; no production framework compatibility or performance claim. This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.

Observations recorded using Python 3.12.14 at 2026-09-30T16:48:16.724948+00:00.

Case digest / f25f0c2ac5f8fd81a059ffe9bf1fff7373735f88594ba4fa60fdfc2d6429a208