Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/spec/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ the layout / shard hierarchy diagram lives in [shard](./shard.md).
The parser turns Python DSL source into a `core_ir.Module`. There are
two layers: a **module layer** (`parse_module`, the sole top entry)
that assembles the compilation unit, and a **function layer**
(`parse_func` / `parse_prim_func`) that turns each `ast.FunctionDef`
(`parse_function(fn, context)`) that turns each authored Python `FunctionType`
into an `hir.Function` or `tir.PrimFunction`. The DSL surface
(authoring namespace, OpSchema registry, dispatch tokens, AST
subset, sugar disambiguation) and the lexical-env rules for
Expand Down
4 changes: 2 additions & 2 deletions docs/spec/code-organization.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ each get their own file. Codegen consumes TIR only.

**Rule 5 — `<category>/__init__.py` re-export rules:** real Op submodules are
re-exported; aliases are imported only for registration side effects; user imports
go through [parser §2](./parser.md#2-dsl-namespace-surface).
go through [parser §2](./parser.md#2-syntax-and-rules).

**Rule 6 — one pass = one file.** A pass class lives in
`passes/transforms/<pass_name>.py`; internal visitors / mutators stay in that file.
Expand Down Expand Up @@ -227,7 +227,7 @@ from tilefoundry.dsl import tf, T, Tensor
sugar; it is owned by `tilefoundry.dsl` (defined under
`tilefoundry.dsl._tensor`, re-exported as `tilefoundry.dsl.Tensor`). It
is **not** the IR tensor type — the IR type carrier is
`tilefoundry.ir.types.TensorType`. See [parser §1.4](./parser.md#14-tensor-and-consttensor-annotations) for
`tilefoundry.ir.types.TensorType`. See [parser §2.1](./parser.md#21-syntax) for
the annotation grammar.
- `DType` is **not** re-exported. dtype values use string form in
DSL source (`Tensor[(8,), "bf16"]`, `zeros((1, 64), "bf16", ...)`);
Expand Down
6 changes: 3 additions & 3 deletions docs/spec/core-ir.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ invocation. Owning a `Function`, attaching a child `Module`, or declaring a
Python-to-HIR entry and HIR-to-HIR device calls are governed by
[hir §1.1](./hir.md#11-function).

- `parse_module` (see [parser §1](./parser.md#1-dsl-syntax)) returns a `Module`.
- `parse_module` (see [parser §2](./parser.md#2-syntax-and-rules)) returns a `Module`.
- A bare `@func` / `@prim_func` becomes an implicit single-function
`Module` whose `entry` is set to that function. A function that declares
execution context of its own is therefore already a `Module`.
Expand Down Expand Up @@ -131,7 +131,7 @@ chain and is not copied onto each Module or Function.
renamed by index) and one prototype serve any number of independent builds.
- `methods` collects plain Python functions (orchestration methods, e.g.
`forward` / `init_caches`; full collection rule in
[parser §2.7](./parser.md#27-module-authoring-surface)). A function name,
[parser §3](./parser.md#3-implementation-overview)). A function name,
a child module name, and a method name MUST be disjoint at one `Module`'s
own level — all three resolve through the same attribute surface ([§1.1](#11-function-access)
below), so a name used by more than one would be ambiguous.
Expand Down Expand Up @@ -305,7 +305,7 @@ class SourceSpanMetadata(IRMetadata):
- `SourceSpanMetadata` records the parser source range before type inference.
- `ExecutionDomainMetadata` records the `with Mesh(...)` scopes a `Call` was
written inside, outermost first
([parser §1.6](./parser.md#16-with-mesh-as-m)). `at(level)` returns the
([parser §2.1](./parser.md#21-syntax)). `at(level)` returns the
innermost scope naming *level*, or `None` when none does. It states where
the work ran, which is not what the result's layout states -- a value laid
out across threads may have been produced by work one CTA did -- so the two
Expand Down
10 changes: 5 additions & 5 deletions docs/spec/hir.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ across sessions.
`Tensor[..., (sugar)]` annotation on a parameter or return appears
at the kernel boundary, where the underlying engine is a shared
buffer handed across the FFI surface. When the surface sugar emits
`Layout(strides=None)` ([parser.md §1.5](./parser.md#15-layout-sugar)),
`Layout(strides=None)` ([parser.md §2.1](./parser.md#21-syntax)),
function-signature binding MUST materialize it to **shared-engine
C-order over the canonical global shape** before the resulting
`TensorType` enters the body. Verbose `Layout(strides=tuple)`
Expand Down Expand Up @@ -355,7 +355,7 @@ class GridRegionExpr(Expr):
`for i in range(...)` — lower to this one node; they share the domain
`(start, extent, step)` and differ only in the loop-variable binding (`tile`
binds a parser-side Python `slice`, while `range` binds a scalar; see
[parser §1.7](./parser.md#17-for-i-in-tile--for-i-in-range-hir-only)). `range` is not unrolled. `induction_var` ranges
[parser §2.1](./parser.md#21-syntax)). `range` is not unrolled. `induction_var` ranges
over `range(start, extent, step)`: `start` and `extent` are the **half-open**
`[start, extent)` Python-range endpoints (so `extent` is the **stop** value,
not a count). `start` defaults to `0` (`tile(...)` and `range(stop)`); the
Expand All @@ -369,7 +369,7 @@ already a coordinate in `range(0, extent, step)`, not an ordinal to multiply by

- When `start` / `extent` / `step` are static `int`, the trip count is
recoverable from the node alone, without the parser-side window binding
([parser §1.7](./parser.md#17-for-i-in-tile--for-i-in-range-hir-only)).
([parser §2.1](./parser.md#21-syntax)).
- Every `DimVar` referenced by a `ShapeDim` `start` / `extent` / `step` MUST
be bound by the enclosing Function's parameter shapes. Resolution
substitutes each such `DimVar` with the corresponding argument-shape
Expand Down Expand Up @@ -404,7 +404,7 @@ parser scope.
`GridRegionExpr.type` is `TensorType` (single carry) or `TupleType`
(multi-carry); the value is the Expr itself, not a `Call`.
Parser-side rules: see
[parser §5.1](./parser.md#51-gridregionexpr-carry-out-lifting).
[parser §3](./parser.md#3-implementation-overview).

**Minimal example** — loop-carried accumulator:

Expand Down Expand Up @@ -508,7 +508,7 @@ class Binary(Op):
- Values follow torch pointwise semantics; dtypes do not promote. Both operands
MUST already carry the same `dtype`, and typeinfer MUST reject a mismatch. A
Python float scalar is given the other operand's float dtype by the authoring
surface, before it is an operand at all ([parser §1.9](./parser.md#19-compile-time-values)); a Python
surface, before it is an operand at all ([parser §2.1](./parser.md#21-syntax)); a Python
integer is not.
- The elementwise `min` / `max` kinds are also surfaced as `minimum` / `maximum`.
- Equal plain layouts, or one plain layout paired with `layout=None`, pass
Expand Down
12 changes: 6 additions & 6 deletions docs/spec/inspection.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ resolves to — an inherited Target or topology hierarchy prints nothing, so
the declaration-versus-inheritance split survives the round trip. A declared
Target prints as the `@module(target=...)` argument and a declared hierarchy
as the `@module(topologies=...)` argument
([parser §2.7](./parser.md#27-module-authoring-surface)).
([parser §3](./parser.md#3-implementation-overview)).
Every dimension referenced only by a declared topology expression MUST still
be emitted in the dimension prelude. A topology `ShapeDim` MUST use the same
DSL expression text as tensor and Mesh geometry, including public constructors
Expand All @@ -144,7 +144,7 @@ such as `ceildiv`, so importing restores the same expression tree.
- constraints:
- The decorator MUST print in its called form, `@module()` included. A bare
decorator has not run while the class body is evaluated, so a body naming a
child call could not resolve it ([parser §1.1](./parser.md#11-decorators)).
child call could not resolve it ([parser §2.1](./parser.md#21-syntax)).
- A nested Module MUST print before the owner's Functions, because a body
calling one names the attribute it is bound to and a class body binds in the
order it is written.
Expand All @@ -154,7 +154,7 @@ such as `ceildiv`, so importing restores the same expression tree.
from the attached entry's identity and the recorded origin
([hir §1.1](./hir.md#11-function)), not from the name they share and not from
the parser's consumed authoring record
([parser §4.2](./parser.md#42-closure-then-registry-callee-resolution)):
([parser §3](./parser.md#3-implementation-overview)):
anything may be called the same, and two attributes may hold copies of one
Module.
- Such a call MUST print exactly the arguments `Call.args` carries
Expand All @@ -177,7 +177,7 @@ output supports two modes derived from the same pretty-print core:

- `canonical` — round-trippable text used by `as_script()`, pass
dumps, and viewer detail `code` blocks: the `Tensor[...]` form of
[parser §1.5](./parser.md#15-layout-sugar) (storage as the string
[parser §2.1](./parser.md#21-syntax) (storage as the string
slot, `gmem` omitted).
- `compact` — abbreviated, **display-only / non-round-trip** text for
summaries / labels: `dtype[shape] {value-state?} @storage`. It inlines
Expand Down Expand Up @@ -245,7 +245,7 @@ def small_sequence(x: Tensor[(S,), "f32"]) -> Tensor[(S,), "f32"]:

The pattern prints in its constructor form (`DimVarRangePat("S", 1, 4)`;
other `Pattern` subclasses fall back to `repr(pattern)`). The emitted binding
mirrors the authoring surface ([parser.md §1.1](./parser.md#11-decorators));
mirrors the authoring surface ([parser.md §2.1](./parser.md#21-syntax));
when an IR variant has no display label, the printer synthesizes a valid binding
from its canonical specialization signature. Because a
dispatch prototype has a `DimVar` parameter, its rendering is a
Expand All @@ -267,7 +267,7 @@ MUST agree over
- DType annotations and op attributes preserve the selected descriptor singleton
through their canonical names
- Partial layouts preserve mesh names through the canonical
[parser §1.5](./parser.md#15-layout-sugar) value-state form, and preserve `Partial.reduction` plus the
[parser §2.1](./parser.md#21-syntax) value-state form, and preserve `Partial.reduction` plus the
attrs-position mesh axis in the underlying IR

**Display-only** — the rendering of a function with a `DimVar` parameter, and
Expand Down
Loading
Loading