Module ast
Source - Arg
- Named or positional argument.
- AssertStmt
@assert shape(x) == [B, S, D], "shape mismatch";- CheckBlock
@check name { assert ...; assert ...; }- ConfigBlock
@config { d_model: 768; n_heads: 12; }- CustomOpBlock
- ExprField
- A field with an expression value:
d_model: 768; - Field
- A field with a literal value:
name: "GPT-2"; - GraphBlock
@graph Forward(x: Tensor<[B,S,D], f32>) -> Tensor<[B,S,D], f32> { ... }- ImportStmt
@import "path/to/file.sw" as alias;- InferenceBlock
- InputDecl
input x: Tensor<[B,S], f32>;- LoggingBlock
- MetadataBlock
@model { name: "GPT-2"; version: "1.0"; }- MetricDef
- MetricsBlock
- NodeDecl
node h { op: matmul(x, W); } or node h: Type { ... };- OutputDecl
output logits: softmax(h); or output expr;- ParamAttr
- ParamDecl
param W: Tensor<[D,D], f32> { init: "normal(0,0.02)"; frozen: false; };- ParamDef
- A parameter definition:
name: Type [?] - PlotDef
- Program
- A complete .sw program is a sequence of directives and imports.
- TrainingBlock
- TypeDef
- TypesBlock
@types { type Hidden = Tensor<[Batch, 768], f32>; }- VisualizationBlock
- BinOp
- Binary operators.
- CustomOpStmt
- DTypeKind
- Data types supported by the language.
- Dimension
- Dimension in a Tensor type.
- Expr
- GraphStmt
- Statements inside a graph body.
- HintKind
- InferenceField
- Literal
- NodeStmt
- TopLevel
- TrainingField
- TypeExpr
- A type expression (Tensor<dims, dtype>, scalar, tuple, etc.).
- UnaryOp
- Unary operators.