The autocast entry of an engine composite — an op with no schema of its own, built from other *_op calls.
The composite's row in the policy table is applied once, here, to its
inputs; autocast is then off on the device until the scope ends, as
SchemaGuard does for a primitive. Without it each primitive
inside applied its own row: log1p lowered its add to float16 and
raised its log to float32, then refused to combine the two
(DtypeMismatch), and log10 came out in float16 because its last
step is a div.
Only float16, bfloat16 and float32 inputs are cast; float64, complex and integer inputs pass through. Outside an autocast scope nothing is cast, nothing is turned off and the table is not read.
Examples
.. code-block:: cpp TensorImplPtr log10_op(const TensorImplPtr& a_in) {
const AmpScope amp{"log10", a_in->device()};
const TensorImplPtr a = amp.cast(a_in);
...Constructors
1Operators
1Methods
2t at the dtype the row gives one input. PromoteWidest leaves a lone input alone — use cast_widest for an op's operands.
The operands of one op, cast together. Under PromoteWidest every eligible operand goes to the widest eligible dtype among them — float16 with bfloat16 is float32, as the reference promotes them; under any other policy each is cast on its own. The one owner of PromoteWidest: SchemaGuard sees one input and keeps it.