Skip to content
class

KernelPolicy

KernelPolicy

Documentation-only enumeration of the compile-time policy flags a concrete kernel may override on its CRTP base.

Derived kernels do not instantiate this struct — they override the equivalent static constexpr bool kSavesInput / kSavesOutput / kHasGradient members on UnaryKernel (or sibling bases). KernelPolicy exists purely so the flag set is documented in one place and discoverable via codegen tools.

See Also

IKernel — the abstract base these flags refine. UnaryKernel, BinaryKernel — CRTP bases that read these flags via Derived::kSavesInput etc.

Attributes

saves_inputsbool
Whether forward() snapshots the input storages into saved_inputs_ for later use in apply() / grad_formula. Set false for ops whose backward formula does not need the forward inputs (e.g. Add whose backward is the identity).
saves_outputbool
Whether forward() additionally snapshots the output storage into saved_output_. Useful for ops whose backward is expressed more cheaply in terms of the output (e.g. ReLU, Softmax, Pow).
has_gradientbool
Whether the op participates in autograd at all. Setting false skips graph wiring entirely — used by in-place / non-differentiable ops such as integer cast or copy.
deterministicbool
Whether the op produces bit-identical outputs for bit-identical inputs. Currently informational only; consumed by future determinism-mode validators.