FAILURE MAP
← Case archive

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

Tensor views: row-major linear index uses dimension suffix products · case 01

row-major linear index uses dimension suffix products.

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

ROOT CAUSE

A row-major linear index weights each coordinate by the product of dimensions after its axis.

THE FAILURE

A row-major linear index weights each coordinate by the product of dimensions after its axis.

Unsuccessful approach: Multiplying each coordinate by its own dimension uses the wrong radix.

Case contract

Convert a valid row-major multidimensional coordinate to its flattened index.

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, index):
    return sum(index)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('matrix index',solve([N,4],[1,2]),6)
check('first',solve([2,3],[0,0]),0)
check('last',solve([2,3],[1,2]),5)
check('three axes',solve([2,N,3],[1,2,1]),N*3+7)
check('unit axis',solve([1,N],[0,N-1]),N-1)
check('scalar',solve([],[]),0)
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 index36Failed
first00Passed
last35Failed
three axes410Failed
unit axis00Passed
scalar00Passed

SHA-256 / e2a9c103a2a90f8b80e8b814332f794925372bdca30b747bc2d319b773179b1d

2 / The unsuccessful fix

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

N = 1
observations = []
def solve(shape, index):
    out=0
    for d,i in zip(shape,index): out+=i*d
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('matrix index',solve([N,4],[1,2]),6)
check('first',solve([2,3],[0,0]),0)
check('last',solve([2,3],[1,2]),5)
check('three axes',solve([2,N,3],[1,2,1]),N*3+7)
check('unit axis',solve([1,N],[0,N-1]),N-1)
check('scalar',solve([],[]),0)
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 index96Failed
first00Passed
last85Failed
three axes710Failed
unit axis00Passed
scalar00Passed

SHA-256 / 08d19a6c9ff52428f4bbd7674c10d1e014f0c94441b596edb26245d4c57fdca0

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

Case digest / 94346b75952eb3c02e512173d1e09e3bb9a8900a3d33d0b450abee8905a52d08