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_viewCanonical 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).versionintMonotonic schema version starting at 1. Bump on backwards- incompatible changes — bumping invalidates checkpoints / traces that reference the previous version.
declared_ amp_ policyAmpPolicyThe 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.deterministicbooltrue 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_viewHuman-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_ arityintExpected number of input tensors.
-1 means variadic (the op accepts any number of inputs; the op is responsible for its own arity validation).output_ arityintNumber 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.
internalbooltrue 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
1ctor
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_viewCanonical op name.
vintSchema version (start at 1).
apAmpPolicySets
declared_amp_policy.detbool, default= trueDeterminism flag.
notestd::string_view, default= ""Non-determinism explanation; ignored when
det is true.realbool, default= falseSets
real_valued.closedbool, default= falseSets
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.