forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 8
Closed
Description
Overlaps with not using extern blocks anymore.
Design proposal as per our discussion:
fn foo<T: Add>(a: T) -> T {
a * a
}
#[autodiff(foo, dfoo, Active, Duplicated)]
fn dfoo<T>(a: T, b: T) -> T;
fn main() {
dbg!(dfoo<f32>(3.14, 1.0));
}
require ;
after function declaration trough the autodiff macro.
Automatically replace ;
with {unimplemented!();}
Required Checks:
dfoo<f32>
checks if foo<f32>
is a valid instanciation
input and output Activity must be valid for the given T (think of Output for Scalar types, Duplicated for ptr/ref/.. types.
Actions:
Instanciate foo in case that no other code is using foo<f32>
.
Mark foo as used s.t. it won't be optimized away. Similar to our previous primary fncs.
Explanation:
Asking for the derivative dfoo<T>
must differentiate the source code of foo<T>
, so we must instanciate foo<T>
.