FAILURE MAP
← Case archive

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

Tensor views: reshape preserves total element count · case 01

reshape preserves total element count.

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

ROOT CAUSE

Matching ranks does not establish that source and target contain the same number of elements.

THE FAILURE

Matching ranks does not establish that source and target contain the same number of elements.

Unsuccessful approach: Adding a rank check wrongly rejects valid reshapes that change rank.

Case contract

A reshape target without inferred axes is valid exactly when products match; return boolean.

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 len(shape)==len(target)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('flatten valid',solve([N,3],[3*N]),True)
check('same count reordered',solve([2,3],[3,2]),True)
check('wrong count',solve([N,3],[N+1,3]),False)
check('same rank wrong count',solve([2,3],[2,4]),False)
check('scalar',solve([],[]),True)
check('singleton count',solve([1],[1,1]),True)
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
flatten validFalseTrueFailed
same count reorderedTrueTruePassed
wrong countTrueFalseFailed
same rank wrong countTrueFalseFailed
scalarTrueTruePassed
singleton countFalseTrueFailed

SHA-256 / d68ed511b7f1fc5f9b69f2da9e0caf4c13d3c8f8cfb8237393088c80fb6d0ce4

2 / The unsuccessful fix

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

N = 1
observations = []
def solve(shape, target):
    return len(shape)==len(target) and __import__('math').prod(shape)==__import__('math').prod(target)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('flatten valid',solve([N,3],[3*N]),True)
check('same count reordered',solve([2,3],[3,2]),True)
check('wrong count',solve([N,3],[N+1,3]),False)
check('same rank wrong count',solve([2,3],[2,4]),False)
check('scalar',solve([],[]),True)
check('singleton count',solve([1],[1,1]),True)
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
flatten validFalseTrueFailed
same count reorderedTrueTruePassed
wrong countFalseFalsePassed
same rank wrong countFalseFalsePassed
scalarTrueTruePassed
singleton countFalseTrueFailed

SHA-256 / 08210f22063de8379643b5ddce3d0cead49a46bd3699242c86c92dbf2b65fddf

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

Case digest / b039e21bee7358b8bb92002ecf09528b77f6bcd06159c5d138c3a957a3f10bdc