@@ -1519,33 +1519,57 @@ pub(crate) mod builtin {
1519
1519
( $file: expr $( , ) ?) => { { /* compiler built-in */ } } ;
1520
1520
}
1521
1521
1522
- /// Automatic Differentiation macro which allows generating a new function to compute
1523
- /// the derivative of a given function. It may only be applied to a function.
1524
- /// The expected usage syntax is
1525
- /// `#[autodiff(NAME, MODE, INPUT_ACTIVITIES, OUTPUT_ACTIVITY)]`
1526
- /// where:
1527
- /// NAME is a string that represents a valid function name.
1528
- /// MODE is any of Forward, Reverse, ForwardFirst, ReverseFirst.
1529
- /// INPUT_ACTIVITIES consists of one valid activity for each input parameter.
1530
- /// OUTPUT_ACTIVITY must not be set if we implicitly return nothing (or explicitly return
1531
- /// `-> ()`). Otherwise it must be set to one of the allowed activities.
1532
- #[ unstable( feature = "autodiff" , issue = "124509" ) ]
1533
- #[ allow_internal_unstable( rustc_attrs) ]
1534
- #[ rustc_builtin_macro]
1535
- pub macro autodiff( $item: item) {
1536
- /* compiler built-in */
1537
- }
1538
-
1522
+ /// the derivative of a given function in the forward mode of differentiation.
1523
+ /// It may only be applied to a function.
1524
+ ///
1525
+ /// The expected usage syntax is:
1526
+ /// `#[autodiff_forward(NAME, INPUT_ACTIVITIES, OUTPUT_ACTIVITY)]`
1527
+ ///
1528
+ /// - `NAME`: A string that represents a valid function name.
1529
+ /// - `INPUT_ACTIVITIES`: Specifies one valid activity for each input parameter.
1530
+ /// - `OUTPUT_ACTIVITY`: Must not be set if the function implicitly returns nothing
1531
+ /// (or explicitly returns `-> ()`). Otherwise, it must be set to one of the allowed activities.
1532
+ ///
1533
+ /// # Example
1534
+ ///
1535
+ /// ```rust
1536
+ /// #[autodiff_forward(df, Dual, Dual, Dual)]
1537
+ /// fn f(x: f64, y: f64) -> f64 {
1538
+ /// x * y
1539
+ /// }
1540
+ /// ```
1539
1541
#[ unstable( feature = "autodiff" , issue = "124509" ) ]
1540
1542
#[ allow_internal_unstable( rustc_attrs) ]
1541
1543
#[ rustc_builtin_macro]
1544
+ #[ cfg( not( bootstrap) ) ]
1542
1545
pub macro autodiff_forward( $item: item) {
1543
1546
/* compiler built-in */
1544
1547
}
1545
1548
1549
+ /// Automatic Differentiation macro which allows generating a new function to compute
1550
+ /// the derivative of a given function in the reverse mode of differentiation.
1551
+ /// It may only be applied to a function.
1552
+ ///
1553
+ /// The expected usage syntax is:
1554
+ /// `#[autodiff_reverse(NAME, INPUT_ACTIVITIES, OUTPUT_ACTIVITY)]`
1555
+ ///
1556
+ /// - `NAME`: A string that represents a valid function name.
1557
+ /// - `INPUT_ACTIVITIES`: Specifies one valid activity for each input parameter.
1558
+ /// - `OUTPUT_ACTIVITY`: Must not be set if the function implicitly returns nothing
1559
+ /// (or explicitly returns `-> ()`). Otherwise, it must be set to one of the allowed activities.
1560
+ ///
1561
+ /// # Example
1562
+ ///
1563
+ /// ```rust
1564
+ /// #[autodiff_reverse(df, Active, Active, Active)]
1565
+ /// fn f(x: f64, y: f64) -> f64 {
1566
+ /// x * y
1567
+ /// }
1568
+ /// ```
1546
1569
#[ unstable( feature = "autodiff" , issue = "124509" ) ]
1547
1570
#[ allow_internal_unstable( rustc_attrs) ]
1548
1571
#[ rustc_builtin_macro]
1572
+ #[ cfg( not( bootstrap) ) ]
1549
1573
pub macro autodiff_reverse( $item: item) {
1550
1574
/* compiler built-in */
1551
1575
}
0 commit comments