|
Mila
Deep Neural Network Library
|
Primary traits template for unified compile-time operation dispatch. More...
Primary traits template for unified compile-time operation dispatch.
Each specialization provides either a nested type alias naming the concrete operation class, or (for functor-templated ops such as ElementwiseActivationOp) a nested op_for<Functor> alias, for the given (OperationType, DeviceType, precision, policy) combination.
The primary template is intentionally left undefined. An unsupported tuple therefore names an incomplete type, and the compiler reports a single-line "use of undefined type OperationTraits<Op, Device, Precision, Policy>" naming the exact tuple – a readable diagnostic, not a multi-hundred-line constraint cascade. (A kernel that only supports FP32 must not advertise a BF16 row: the honest failure is a missing specialization here, not a poisoned row whose op fails a float || half kernel constraint deep in dispatch.)
To branch on availability at compile time – e.g. a multi-precision typed test skipping the precisions an op does not implement – use the SFINAE-safe OperationSupported<...> predicate below rather than instantiating this template. The primary must stay undefined for that predicate to work: a static_assert in the primary body would fire during the predicate's own probe, turning the detectable "false" back into a hard error.
| TOp | Operation identifier from the OperationType enum. |
| TDeviceType | Target device (Cpu, Cuda, ...). |
| TPrecision | Compute and activation precision. |
| TPolicy | Optional policy type. Defaults to void for policy-free ops. |