Skip to content
class

OpSchema

OpSchema

Per-op metadata record stored by pointer in the OpRegistry.

Schemas are intended to be constexpr statics defined alongside each op implementation; the registry stores raw pointers and assumes the pointee outlives the registry (true for process-lifetime statics). Constructing schemas with dynamic storage duration is supported but discouraged.

Attributes

namestd::string_view
Canonical op name; used as the OpRegistry key and in diagnostic / error messages. Must point into storage that lives at least as long as the registry (constexpr literals are ideal).
versionint
Monotonic schema version starting at 1. Bump on backwards- incompatible changes — bumping invalidates checkpoints / traces that reference the previous version.
declared_amp_policyAmpPolicy
The policy the op author declared. Autocast does not read it: an op's autocast behaviour is its row in the per-device table (amp::policy_for), which can differ between Metal and CPU and which one field could not express. What the field still decides is integer-input promotion outside autocast — ForceFP32 here, like real_valued, promotes an integer input to float32.
deterministicbool
true if the op produces bit-identical results given identical inputs and configuration. false for ops that rely on atomics, non-associative parallel reductions, or other sources of run-to-run variation. Consulted by check_schema_determinism / SchemaGuard when Determinism::is_enabled().
determinism_notestd::string_view
Human-readable explanation of why the op is non-deterministic (e.g. "uses atomic scatter-add"). Included verbatim in the error message raised under set_deterministic(True). Empty for deterministic ops.
input_arityint
Expected number of input tensors. -1 means variadic (the op accepts any number of inputs; the op is responsible for its own arity validation).
output_arityint
Number of output tensors produced. Defaults to 1; most ops are single-output.
stable_input_indicesstd::vector<int>
Indices into the input list whose values are saved for backward. Autograd's version-counter logic uses these to detect illegal in-place mutations between forward and backward that would corrupt the saved tensors.
internalbool
true for ops that are not part of the public Python API (implementation-detail kernels, fused / internal helpers). The Python binding layer hides these from dir(lucid) etc.

Constructors

1
ctor

OpSchema

void OpSchema(int n, int v, AmpPolicy ap, bool det, int note, bool real, bool closed)

Minimal constructor for deterministic ops with default arity.

Parameters

nstd::string_view
Canonical op name.
vint
Schema version (start at 1).
apAmpPolicy
Sets declared_amp_policy.
detbool, default= true
Determinism flag.
notestd::string_view, default= ""
Non-determinism explanation; ignored when det is true.
realbool, default= false
Sets real_valued.
closedbool, default= false
Sets integral_closed.

Notes

Leaves input_arity = -1 (variadic), output_arity = 1, stable_input_indices empty, and internal = false. Use the full constructor below when these defaults are not appropriate.