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.
Inside an autocast scope the guard is an RAII scope: autocast stays off on the op's device until the guard is destroyed, so it must live as long as the op's body. Outside one it owns nothing.
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.Operators
1Methods
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 op's policy on the device is Promote
(returns the autocast dtype, possibly demoted on CPU) or
ForceFP32 (returns Dtype::F32). Equals
input_dtype for KeepInput / PromoteWidest 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.