Single commit implementing the enzyme/autodiff frontend · qinheping/verify-rust-std@2b6b22c (original) (raw)

3 files changed

lines changed

Original file line number Diff line number Diff line change
@@ -278,6 +278,15 @@ pub mod assert_matches {
278 278 pub use crate::macros::{assert_matches, debug_assert_matches};
279 279 }
280 280
281 +// We don't export this through #[macro_export] for now, to avoid breakage.
282 +#[cfg(not(bootstrap))]
283 +#[unstable(feature = "autodiff", issue = "124509")]
284 +/// Unstable module containing the unstable `autodiff` macro.
285 +pub mod autodiff {
286 +#[unstable(feature = "autodiff", issue = "124509")]
287 +pub use crate::macros::builtin::autodiff;
288 +}
289 +
281 290 #[unstable(feature = "cfg_match", issue = "115585")]
282 291 pub use crate::macros::cfg_match;
283 292
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"),
@@ -627,7 +628,13 @@ pub mod simd {
627 628 #[doc(inline)]
628 629 pub use crate::std_float::StdFloat;
629 630 }
630 -
631 +#[cfg(not(bootstrap))]
632 +#[unstable(feature = "autodiff", issue = "124509")]
633 +/// This module provides support for automatic differentiation.
634 +pub mod autodiff {
635 +/// This macro handles automatic differentiation.
636 + pub use core::autodiff::autodiff;
637 +}
631 638 #[stable(feature = "futures_api", since = "1.36.0")]
632 639 pub mod task {
633 640 //! Types and Traits for working with asynchronous tasks.