Programs¶
Typed entry-point metadata for programs elaborated into computations.
programs
¶
Typed entry-point metadata for programs elaborated into computations.
A program declaration elaborates to an ordinary named computation whose
parameters are the program's data, observations, and fibrations, and whose
body performs the canonical Random.sample and Score.add requests.
What the computation alone does not say is which parameter plays which
role, which locals are the program's sites, and what the return tuple's
labels are. The records here carry that, beside the computation, so a
runtime, a transpiler, or a tool can drive the entry point without
re-reading the source.
ParameterRole
¶
ParameterRole = Literal['domain', 'scalar', 'data', 'observation', 'fibration', 'weight', 'bias', 'table', 'kernel-input']
How a program parameter is supplied.
domain parameters carry the value the program is applied to, one per
real factor of its domain; scalar ones are its declared parameters;
data ones are free names its steps read; observation ones are the
values observe steps score; fibration ones map observation rows to
groups; weight and bias are the numbers of a declared morphism's
affine parameter map and table those of a morphism over a finite
domain, one row per element; kernel-input holds a kernel's input
locations.
SiteKind
¶
What a program step does at its site.
ProgramParameter
dataclass
¶
ProgramParameter(name: str, role: ParameterRole, type: TypeExpr, axes: tuple[str, ...] = (), tag: Literal['program_parameter'] = 'program_parameter')
One parameter of an elaborated program.
| PARAMETER | DESCRIPTION |
|---|---|
name
|
The parameter's name, which is the computation parameter's.
TYPE:
|
role
|
How the parameter is supplied.
TYPE:
|
type
|
Its type.
TYPE:
|
axes
|
The name of each dimension of a tensor-typed parameter, the object or extent it ranges over; empty for a scalar.
TYPE:
|
tag
|
The serialization discriminator; always
TYPE:
|
ProgramSite
dataclass
¶
ProgramSite(name: str, kind: SiteKind, family: str, batch: tuple[PlateAxis, ...] = (), event: tuple[PlateAxis, ...] = (), tag: Literal['program_site'] = 'program_site')
One probabilistic step of an elaborated program.
| PARAMETER | DESCRIPTION |
|---|---|
name
|
The site's label, the name the step binds or scores.
TYPE:
|
kind
|
Whether the step samples, observes, or marginalizes.
TYPE:
|
family
|
The distribution family the step draws from.
TYPE:
|
batch
|
The plate's batch axes.
TYPE:
|
event
|
The plate's event axes.
TYPE:
|
tag
|
The serialization discriminator; always
TYPE:
|
ProgramEntry
dataclass
¶
ProgramEntry(name: str, computation: ComputationId, parameters: tuple[ProgramParameter, ...], return_names: tuple[str, ...], return_labels: tuple[str, ...] | None, sites: tuple[ProgramSite, ...], random_instance: EffectInstanceId, score_instance: EffectInstanceId, telescope: Telescope = (), tag: Literal['program_entry'] = 'program_entry')
The typed entry point a program declaration elaborates to.
| PARAMETER | DESCRIPTION |
|---|---|
name
|
The program's source name.
TYPE:
|
computation
|
The identity of the named computation holding its body.
TYPE:
|
parameters
|
The computation's parameters with their roles, in order.
TYPE:
|
return_names
|
The names the program returns, in order.
TYPE:
|
return_labels
|
The labels of a labelled return tuple, or
TYPE:
|
sites
|
The program's probabilistic steps, in source order, those of marginalization scopes included.
TYPE:
|
random_instance
|
The lexical
TYPE:
|
score_instance
|
The lexical
TYPE:
|
telescope
|
The static binders the computation takes: one index binder per extent of an input the program's steps leave open, which a run reads off the data it is given.
TYPE:
|
tag
|
The serialization discriminator; always
TYPE:
|