@@ -1499,6 +1499,25 @@ pub(crate) mod builtin {
14991499 /// - `INPUT_ACTIVITIES`: Specifies one valid activity for each input parameter.
15001500 /// - `OUTPUT_ACTIVITY`: Must not be set if the function implicitly returns nothing
15011501 /// (or explicitly returns `-> ()`). Otherwise, it must be set to one of the allowed activities.
1502+ ///
1503+ /// ACTIVITIES might either be `Dual` or `Const`, more options will be exposed later.
1504+ ///
1505+ /// `Const` should be used on non-float arguments, or float-based arguments as an optimization
1506+ /// if we are not interested in computing the derivatives with respect to this argument.
1507+ ///
1508+ /// `Dual` can be used for float scalar values or for references, raw pointers, or other
1509+ /// indirect input arguments. It can also be used on a scalar float return value.
1510+ /// If used on a return value, the generated function will return a tuple of two float scalars.
1511+ /// If used on an input argument, a new shadow argument of the same type will be created,
1512+ /// directly following the original argument.
1513+ ///
1514+ /// We might want to track how one input float affects one or more output floats. In this case,
1515+ /// the shadow of one input should be initialized to `1.0`, while the shadows of the other
1516+ /// inputs should be initialized to `0.0`. The shadow of the output(s) should be initialized to
1517+ /// `0.0`. After calling the generated function, the shadow of the input will be zeroed,
1518+ /// while the shadow(s) of the output(s) will contain the derivatives. Forward mode is generally
1519+ /// more efficient if we have more output floats marked as `Dual` than input floats.
1520+ /// Related information can also be found unter the term "Vector-Jacobian product" (VJP).
15021521 #[ unstable( feature = "autodiff" , issue = "124509" ) ]
15031522 #[ allow_internal_unstable( rustc_attrs) ]
15041523 #[ allow_internal_unstable( core_intrinsics) ]
@@ -1518,6 +1537,34 @@ pub(crate) mod builtin {
15181537 /// - `INPUT_ACTIVITIES`: Specifies one valid activity for each input parameter.
15191538 /// - `OUTPUT_ACTIVITY`: Must not be set if the function implicitly returns nothing
15201539 /// (or explicitly returns `-> ()`). Otherwise, it must be set to one of the allowed activities.
1540+ ///
1541+ /// ACTIVITIES might either be `Active`, `Duplicated` or `Const`, more options will be exposed later.
1542+ ///
1543+ /// `Active` can be used for float scalar values.
1544+ /// If used on an input, a new float will be appended to the return tuple of the generated
1545+ /// function. If the function returns a float scalar, `Active` can be used for the return as
1546+ /// well. In this case a float scalar will be appended to the argument list, it works as seed.
1547+ ///
1548+ /// `Duplicated` can be used on references, raw pointers, or other indirect input
1549+ /// arguments. It creates a new shadow argument of the same type, following the original argument.
1550+ /// A const reference or pointer argument will receive a mutable reference or pointer as shadow.
1551+ ///
1552+ /// `Const` should be used on non-float arguments, or float-based arguments as an optimization
1553+ /// if we are not interested in computing the derivatives with respect to this argument.
1554+ ///
1555+ /// We often want to track how one or more input floats affect one output float. This output can
1556+ /// be a scalar return value, or a mutable reference or pointer argument. In this case, the
1557+ /// shadow of the input should be marked as duplicated and initialized to `0.0`. The shadow of
1558+ /// the output should be marked as active or duplicated and initialized to `1.0`. After calling
1559+ /// the generated function, the shadow(s) of the input(s) will contain the derivatives. If the
1560+ /// function has more than one output float marked as active or duplicated, users might want to
1561+ /// set one of them to `1.0` and the others to `0.0` to compute partial derivatives.
1562+ /// Unlike forward-mode, a call to the generated function does not reset the shadow of the
1563+ /// inputs.
1564+ /// Reverse mode is generally more efficient if we have more active/duplicated input than
1565+ /// output floats.
1566+ ///
1567+ /// Related information can also be found unter the term "Jacobian-Vector Product" (JVP).
15211568 #[ unstable( feature = "autodiff" , issue = "124509" ) ]
15221569 #[ allow_internal_unstable( rustc_attrs) ]
15231570 #[ allow_internal_unstable( core_intrinsics) ]
0 commit comments