Combined determinism + AMP dtype-resolution guard.
Constructed once at the top of an op's dispatch routine. The
constructor performs both checks; subsequent code reads the resolved
dtype via effective_dtype.
Despite the "Guard" suffix this is not an RAII resource holder — it owns no locks, allocations, or thread-local state. The name reflects its role as a gate at the entry of the op, not a scope object.
See Also
check_schema_determinism — determinism-only variant.
Examples
.. code-block:: cpp // Inside a forward op
SchemaGuard guard(MyOp::schema_v1, input->dtype(), input->device());
const Dtype dt = guard.effective_dtype();
auto out = backend->allocate(out_shape, dt);
dispatch_kernel(input, out, dt);Constructors
1SchemaGuard
void SchemaGuard(const OpSchema & schema, Dtype input_dtype, Device device)Constructs the guard and runs both gates.
Parameters
schemaconst OpSchema&input_dtypeDtypedeviceDevice, default= Device::CPUAmpPolicy::Promote, since Accelerate has no native F16 path.Raises
LucidErrorcheck_schema_determinism for the exact message format.Methods
1Returns the dtype that the op should use for its computation.
May differ from the input_dtype passed at construction when
AMP is active and the schema's AmpPolicy is Promote
(returns the autocast dtype, possibly demoted on CPU) or
ForceFP32 (returns Dtype::F32). Equals
input_dtype for KeepInput and when AMP is not active.
Returns
DtypeThe effective compute dtype for the op.
Notes
Marked noexcept — purely a field read, no allocations or
exceptions.