One user-space repair task per eligible HWE debug-diag / compile-deploy base ID: 320 admitted (C 218, C++ 97, build scripts 5), 1 skipped by the content filter. Each ships a public spec with a check-to-basis table, at least two defects with single-fix fixtures, a symptom-masking fixture and an alternative correct implementation. Claude re-checked all 320: structure, the HWE quality items and trace6 Docker calibration receipts against current digests (320/320 USABLE). Difficulty is unmeasured. Known follow-up: 212 tasks use 120 ad-hoc family names; the next batch maps them to the canonical list. The batch's 1,256-line progress log stays in its factory report and the 36-local branch batch15-hwe. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
4.9 KiB
4.9 KiB
Tensor bridge contract (version 1)
- Logical coordinates always use
(n,h,w,c). A shape is valid iff1<=n<=4,1<=h,w,c<=8andn*h*w*c<=1024. Invalid shape returns TB_SHAPE. Layout values are NHWC=0 and NCHW=1; other values return TB_LAYOUT. Types I16=0, I32=1, F32=2 have widths 2,4,4 bytes; other types return TB_TYPE. The library moves bytes without numeric conversion; all 32-bit float encodings, including signed zero, infinities and NaNs, retain their bit patterns. - NHWC stores c fastest, then w, h, n. NCHW stores w fastest, then h, c, n.
tb_stridesreports strides in logical(n,h,w,c)order.tb_offsetmaps in-range coordinates;tb_coordinateis its inverse for indices smaller than element count. Invalid coordinates or indices return TB_SHAPE. Each failed output-parameter operation leaves its output unchanged. tb_plan_initvalidates shape, layouts, type in that order and records element count, byte length, widths and both strides.tb_plan_checkchecks all these derived fields; inconsistent valid-plan fields return TB_CONFIG.tb_plan_inverseswaps the layouts.tb_plan_chainrequires matching shape and type, and first output equal to second input; otherwise TB_CONFIG. Successful chain maps first input directly to second output. All plan failures leave destination plans unchanged.tb_convertchecks the plan, non-null input/output, then byte capacities, then overlap, in that order. Each capacity must cover exactly the plan byte length, independent of unused capacity tails. Any intersection of the two effective byte ranges (including identical addresses) returns TB_OVERLAP. Successful conversion moves every logical element from its input-layout offset to its output-layout offset, preserving input, and writes only the effective destination range. Any failure preserves both buffers. Caller supplies valid memory for advertised capacities; no malformed pointers are in scope.- A model has a nonzero 32-bit id, valid shape, type and target layout.
tb_model_checkreturns TB_ARGUMENT for null model/id0 and otherwise uses plan validation. A catalog contains at most eight unique ids in insertion order, with revision initially zero. Add validates model then rejects duplicates TB_DUPLICATE, then full catalog/revision overflow TB_CAPACITY. Find/get return TB_NOT_FOUND for absent id/out-of-range index and preserve destination. Replace requires an existing id; remove compacts insertion order. Each successful add/replace/remove increments revision once; failure changes nothing. Removing/find id0 returns TB_ARGUMENT. Revisions may reach UINT64_MAX but cannot wrap. Unused model slots are outside the observable contract. - Catalog validate checks count, each model, and uniqueness. Copy copies a valid catalog transactionally. Import adds a model sequence transactionally, returning TB_CAPACITY if count exceeds available slots before reading the sequence. A null sequence is permitted only for count0. Duplicate, invalid or capacity failure leaves the catalog unchanged. A count above eight is TB_STATE.
- Init zeroes a catalog or session; null init is a no-op. Open requires an inactive initialized session; reconfigure requires active. Validate the model, then configured-layout enum, then require configured layout to equal model target (TB_CONFIG otherwise), then validate input layout by plan construction. Every successful open increments retained generation and resets calls/transferred; reconfigure increments generation and preserves calls/transferred. Overflow returns TB_CAPACITY. Failure leaves the whole session unchanged. Select finds the catalog model and calls open or reconfigure according to active state. Catalog edits after selection do not alter the selected model snapshot.
- Run requires active state, a coherent model/config/plan snapshot, and non-overflowing counters. It delegates to the conversion contract. On success only, calls increments once and transferred increases by effective bytes. Failure preserves session and buffers. Reset stats requires a coherent active session and zeroes calls/transferred only. Close requires active session, clears its model/config/plan/counters and active flag, retaining generation. Repeated close returns TB_STATE. Info requires coherent active state and non-null outputs and returns model/config and
[generation,calls,transferred], leaving outputs unchanged on failure. - Any required null argument returns TB_ARGUMENT; the order for compound validation follows the clauses above. Null session is checked before active state. Catalog null/count validity is checked before catalog operations. Status numeric values and exact API declarations are in the public header. No stderr format or size constraint applies; arbitrary diagnostic bytes are permitted. Successful library/observer behavior must finish normally within ordinary resource bounds; the production grader allows compiler 20s and observer 20s, plus separate cleanup and absence deadlines of 5s each. Timing/OS process behavior is outside this tensor API.