Auto merge of #129458 - EnzymeAD:enzyme-frontend, r=jieyouxu · qinheping/verify-rust-std@cc7730e (original) (raw)

3 files changed

lines changed

Original file line number Diff line number Diff line change
@@ -270,6 +270,15 @@ pub mod assert_matches {
270 270 pub use crate::macros::{assert_matches, debug_assert_matches};
271 271 }
272 272
273 +// We don't export this through #[macro_export] for now, to avoid breakage.
274 +#[cfg(not(bootstrap))]
275 +#[unstable(feature = "autodiff", issue = "124509")]
276 +/// Unstable module containing the unstable `autodiff` macro.
277 +pub mod autodiff {
278 +#[unstable(feature = "autodiff", issue = "124509")]
279 +pub use crate::macros::builtin::autodiff;
280 +}
281 +
273 282 #[unstable(feature = "cfg_match", issue = "115585")]
274 283 pub use crate::macros::cfg_match;
275 284
Original file line number Diff line number Diff line change
@@ -1539,6 +1539,24 @@ pub(crate) mod builtin {
1539 1539 ($file:expr $(,)?) => {{ /* compiler built-in */ }};
1540 1540 }
1541 1541
1542 +/// Automatic Differentiation macro which allows generating a new function to compute
1543 + /// the derivative of a given function. It may only be applied to a function.
1544 + /// The expected usage syntax is
1545 + /// `#[autodiff(NAME, MODE, INPUT_ACTIVITIES, OUTPUT_ACTIVITY)]`
1546 + /// where:
1547 + /// NAME is a string that represents a valid function name.
1548 + /// MODE is any of Forward, Reverse, ForwardFirst, ReverseFirst.
1549 + /// INPUT_ACTIVITIES consists of one valid activity for each input parameter.
1550 + /// OUTPUT_ACTIVITY must not be set if we implicitely return nothing (or explicitely return
1551 + /// `-> ()`. Otherwise it must be set to one of the allowed activities.
1552 + #[unstable(feature = "autodiff", issue = "124509")]
1553 + #[allow_internal_unstable(rustc_attrs)]
1554 + #[rustc_builtin_macro]
1555 + #[cfg(not(bootstrap))]
1556 +pub macro autodiff($item:item) {
1557 +/* compiler built-in */
1558 +}
1559 +
1542 1560 /// Asserts that a boolean expression is `true` at runtime.
1543 1561 ///
1544 1562 /// This will invoke the [`panic!`] macro if the provided expression cannot be
Original file line number Diff line number Diff line change
@@ -267,6 +267,7 @@
267 267 #![allow(unused_features)]
268 268 //
269 269 // Features:
270 +#![cfg_attr(not(bootstrap), feature(autodiff))]
270 271 #![cfg_attr(test, feature(internal_output_capture, print_internals, update_panic_count, rt))]
271 272 #![cfg_attr(
272 273 all(target_vendor = "fortanix", target_env = "sgx"),
@@ -624,7 +625,13 @@ pub mod simd {
624 625 #[doc(inline)]
625 626 pub use crate::std_float::StdFloat;
626 627 }
627 -
628 +#[cfg(not(bootstrap))]
629 +#[unstable(feature = "autodiff", issue = "124509")]
630 +/// This module provides support for automatic differentiation.
631 +pub mod autodiff {
632 +/// This macro handles automatic differentiation.
633 + pub use core::autodiff::autodiff;
634 +}
628 635 #[stable(feature = "futures_api", since = "1.36.0")]
629 636 pub mod task {
630 637 //! Types and Traits for working with asynchronous tasks.