@@ -30,16 +30,22 @@ pub fn f4(x: f64) {
3030 unimplemented ! ( )
3131}
3232
33+ #[ autodiff( df5, Forward , Dual , Dual ) ]
34+ fn f5 ( x : f32 , y : f32 ) -> f32 {
35+ // ~^^ error: expected 3 activities, but found 2
36+ x+y
37+ }
38+
3339// We can't use Dual in Reverse mode
34- #[ autodiff( df5 , Reverse , Dual ) ]
35- pub fn f5 ( x : f64 ) {
40+ #[ autodiff( df6 , Reverse , Dual ) ]
41+ pub fn f6 ( x : f64 ) {
3642 //~^^ ERROR Dual can not be used in Reverse Mode
3743 unimplemented ! ( )
3844}
3945
4046// We can't use Duplicated in Forward mode
41- #[ autodiff( df6 , Forward , Duplicated ) ]
42- pub fn f6 ( x : f64 ) {
47+ #[ autodiff( df7 , Forward , Duplicated ) ]
48+ pub fn f7 ( x : f64 ) {
4349 //~^^ ERROR Duplicated can not be used in Forward Mode
4450 //~^^ ERROR Duplicated can not be used for this type
4551 unimplemented ! ( )
@@ -62,21 +68,21 @@ fn dummy() {
6268
6369// Malformed, where args?
6470#[ autodiff]
65- pub fn f7 ( x : f64 ) {
71+ pub fn f8 ( x : f64 ) {
6672 //~^ ERROR autodiff must be applied to function
6773 unimplemented ! ( )
6874}
6975
7076// Malformed, where args?
7177#[ autodiff( ) ]
72- pub fn f8 ( x : f64 ) {
78+ pub fn f9 ( x : f64 ) {
7379 //~^ ERROR autodiff requires at least a name and mode
7480 unimplemented ! ( )
7581}
7682
7783// Invalid attribute syntax
7884#[ autodiff = "" ]
79- pub fn f9 ( x : f64 ) {
85+ pub fn f10 ( x : f64 ) {
8086 //~^ ERROR autodiff must be applied to function
8187 unimplemented ! ( )
8288}
@@ -85,29 +91,29 @@ fn fn_exists() {}
8591
8692// We colide with an already existing function
8793#[ autodiff( fn_exists, Reverse , Active ) ]
88- pub fn f10 ( x : f64 ) {
94+ pub fn f11 ( x : f64 ) {
8995 //~^^ ERROR the name `fn_exists` is defined multiple times [E0428]
9096 unimplemented ! ( )
9197}
9298
9399// Malformed, missing a mode
94- #[ autodiff( df11 ) ]
95- pub fn f11 ( ) {
100+ #[ autodiff( df12 ) ]
101+ pub fn f12 ( ) {
96102 //~^ ERROR autodiff requires at least a name and mode
97103 unimplemented ! ( )
98104}
99105
100106// Invalid Mode
101- #[ autodiff( df12 , Debug ) ]
102- pub fn f12 ( ) {
107+ #[ autodiff( df13 , Debug ) ]
108+ pub fn f13 ( ) {
103109 //~^^ ERROR unknown Mode: `Debug`. Use `Forward` or `Reverse`
104110 unimplemented ! ( )
105111}
106112
107113// Invalid, please pick one Mode
108114// or use two autodiff macros.
109- #[ autodiff( df13 , Forward , Reverse ) ]
110- pub fn f13 ( ) {
115+ #[ autodiff( df14 , Forward , Reverse ) ]
116+ pub fn f14 ( ) {
111117 //~^^ ERROR did not recognize Activity: `Reverse`
112118 unimplemented ! ( )
113119}
@@ -117,8 +123,8 @@ struct Foo {}
117123// We can't handle Active structs, because that would mean (in the general case), that we would
118124// need to allocate and initialize arbitrary user types. We have Duplicated/Dual input args for
119125// that. FIXME: Give a nicer error and suggest to the user to have a `&mut Foo` input instead.
120- #[ autodiff( df14 , Reverse , Active , Active ) ]
121- fn f14 ( x : f32 ) -> Foo {
126+ #[ autodiff( df15 , Reverse , Active , Active ) ]
127+ fn f15 ( x : f32 ) -> Foo {
122128 unimplemented ! ( )
123129}
124130
@@ -127,15 +133,15 @@ type MyFloat = f32;
127133// We would like to support type alias to f32/f64 in argument type in the future,
128134// but that requires us to implement our checks at a later stage
129135// like THIR which has type information available.
130- #[ autodiff( df15 , Reverse , Active , Active ) ]
131- fn f15 ( x : MyFloat ) -> f32 {
136+ #[ autodiff( df16 , Reverse , Active , Active ) ]
137+ fn f16 ( x : MyFloat ) -> f32 {
132138 //~^^ ERROR failed to resolve: use of undeclared type `MyFloat` [E0433]
133139 unimplemented ! ( )
134140}
135141
136142// We would like to support type alias to f32/f64 in return type in the future
137- #[ autodiff( df16 , Reverse , Active , Active ) ]
138- fn f16 ( x : f32 ) -> MyFloat {
143+ #[ autodiff( df17 , Reverse , Active , Active ) ]
144+ fn f17 ( x : f32 ) -> MyFloat {
139145 unimplemented ! ( )
140146}
141147
@@ -145,34 +151,34 @@ struct F64Trans {
145151}
146152
147153// We would like to support `#[repr(transparent)]` f32/f64 wrapper in return type in the future
148- #[ autodiff( df17 , Reverse , Active , Active ) ]
149- fn f17 ( x : f64 ) -> F64Trans {
154+ #[ autodiff( df18 , Reverse , Active , Active ) ]
155+ fn f18 ( x : f64 ) -> F64Trans {
150156 unimplemented ! ( )
151157}
152158
153159// We would like to support `#[repr(transparent)]` f32/f64 wrapper in argument type in the future
154- #[ autodiff( df18 , Reverse , Active , Active ) ]
155- fn f18 ( x : F64Trans ) -> f64 {
160+ #[ autodiff( df19 , Reverse , Active , Active ) ]
161+ fn f19 ( x : F64Trans ) -> f64 {
156162 //~^^ ERROR failed to resolve: use of undeclared type `F64Trans` [E0433]
157163 unimplemented ! ( )
158164}
159165
160166// Invalid return activity
161- #[ autodiff( df19 , Forward , Dual , Active ) ]
162- fn f19 ( x : f32 ) -> f32 {
167+ #[ autodiff( df20 , Forward , Dual , Active ) ]
168+ fn f20 ( x : f32 ) -> f32 {
163169 //~^^ ERROR invalid return activity Active in Forward Mode
164170 unimplemented ! ( )
165171}
166172
167173#[ autodiff( df20, Reverse , Active , Dual ) ]
168- fn f20 ( x : f32 ) -> f32 {
174+ fn f21 ( x : f32 ) -> f32 {
169175 //~^^ ERROR invalid return activity Dual in Reverse Mode
170176 unimplemented ! ( )
171177}
172178
173179// Duplicated cannot be used as return activity
174180#[ autodiff( df21, Reverse , Active , Duplicated ) ]
175- fn f21 ( x : f32 ) -> f32 {
181+ fn f22 ( x : f32 ) -> f32 {
176182 //~^^ ERROR invalid return activity Duplicated in Reverse Mode
177183 unimplemented ! ( )
178184}
0 commit comments