FAILURE MAP
← Case archive

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

Tensor views: unsqueeze inserts a unit dimension at normalized axis · case 01

unsqueeze inserts a unit dimension at normalized axis.

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

ROOT CAUSE

A new unit axis receives a fixed stride rather than one compatible with its insertion point.

THE FAILURE

A new unit axis receives a fixed stride rather than one compatible with its insertion point.

Unsuccessful approach: Looking at the preceding axis selects the wrong layout for middle and trailing insertions.

Case contract

Insert size one and a contiguous-compatible stride: at end stride 1, otherwise shape[a]*stride[a].

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, strides, axis):
    out=list(shape); out.insert(axis,1)
    s=list(strides); s.insert(axis,1)
    return out,s
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('leading',solve([N,3],[3,1],0),([1,N,3],[N*3,3,1]))
check('middle',solve([2,3],[3,1],1),([2,1,3],[3,3,1]))
check('trailing',solve([2,3],[3,1],2),([2,3,1],[3,1,1]))
check('noncontiguous',solve([2,3],[7,2],1),([2,1,3],[7,6,2]))
check('scalar',solve([] ,[],0),([1],[1]))
check('offset-compatible units',solve([1,3],[99,1],0),([1,1,3],[99,99,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
leading[[1, 1, 3], [1, 3, 1]][[1, 1, 3], [3, 3, 1]]Failed
middle[[2, 1, 3], [3, 1, 1]][[2, 1, 3], [3, 3, 1]]Failed
trailing[[2, 3, 1], [3, 1, 1]][[2, 3, 1], [3, 1, 1]]Passed
noncontiguous[[2, 1, 3], [7, 1, 2]][[2, 1, 3], [7, 6, 2]]Failed
scalar[[1], [1]][[1], [1]]Passed
offset-compatible units[[1, 1, 3], [1, 99, 1]][[1, 1, 3], [99, 99, 1]]Failed

SHA-256 / 76206c97870a8ab1751e0f24c5dcdd8c3a781760a94364f6713c6cf3e9b0fa21

2 / The unsuccessful fix

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

N = 1
observations = []
def solve(shape, strides, axis):
    out=list(shape); s=list(strides); stride=shape[axis-1]*strides[axis-1] if axis else 1
    out.insert(axis,1); s.insert(axis,stride)
    return out,s
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('leading',solve([N,3],[3,1],0),([1,N,3],[N*3,3,1]))
check('middle',solve([2,3],[3,1],1),([2,1,3],[3,3,1]))
check('trailing',solve([2,3],[3,1],2),([2,3,1],[3,1,1]))
check('noncontiguous',solve([2,3],[7,2],1),([2,1,3],[7,6,2]))
check('scalar',solve([] ,[],0),([1],[1]))
check('offset-compatible units',solve([1,3],[99,1],0),([1,1,3],[99,99,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
leading[[1, 1, 3], [1, 3, 1]][[1, 1, 3], [3, 3, 1]]Failed
middle[[2, 1, 3], [3, 6, 1]][[2, 1, 3], [3, 3, 1]]Failed
trailing[[2, 3, 1], [3, 1, 3]][[2, 3, 1], [3, 1, 1]]Failed
noncontiguous[[2, 1, 3], [7, 14, 2]][[2, 1, 3], [7, 6, 2]]Failed
scalar[[1], [1]][[1], [1]]Passed
offset-compatible units[[1, 1, 3], [1, 99, 1]][[1, 1, 3], [99, 99, 1]]Failed

SHA-256 / ca33d53e14be5ee40279eb238bc76aace2bcc9ee79c8c9e5cef7ec2c616a5479

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.725026+00:00.

Case digest / b37e88f24d48b0006de42702ae3e7fc5b3010443af1bf1e7ac2d0c89ac1a3495