|
25 | 25 |
|
26 | 26 | // We want to be sure that the same function can be differentiated in different ways
|
27 | 27 |
|
| 28 | + |
| 29 | + // Make sure, that we add the None for the default return. |
| 30 | + |
| 31 | + |
28 | 32 | ::core::panicking::panic("not implemented")
|
29 | 33 | }
|
30 |
| -#[rustc_autodiff(Forward, Dual, Const, Dual,)] |
| 34 | +#[rustc_autodiff(Forward, 1, Dual, Const, Dual)] |
31 | 35 | #[inline(never)]
|
32 |
| -pub fn df1(x: &[f64], bx: &[f64], y: f64) -> (f64, f64) { |
| 36 | +pub fn df1(x: &[f64], bx_0: &[f64], y: f64) -> (f64, f64) { |
33 | 37 | unsafe { asm!("NOP", options(pure, nomem)); };
|
34 | 38 | ::core::hint::black_box(f1(x, y));
|
35 |
| - ::core::hint::black_box((bx,)); |
36 |
| - ::core::hint::black_box((f1(x, y), f64::default())) |
| 39 | + ::core::hint::black_box((bx_0,)); |
| 40 | + ::core::hint::black_box(<(f64, f64)>::default()) |
37 | 41 | }
|
38 | 42 | #[rustc_autodiff]
|
39 | 43 | #[inline(never)]
|
40 | 44 | pub fn f2(x: &[f64], y: f64) -> f64 {
|
41 | 45 | ::core::panicking::panic("not implemented")
|
42 | 46 | }
|
43 |
| -#[rustc_autodiff(Forward, Dual, Const, Const,)] |
| 47 | +#[rustc_autodiff(Forward, 1, Dual, Const, Const)] |
44 | 48 | #[inline(never)]
|
45 |
| -pub fn df2(x: &[f64], bx: &[f64], y: f64) -> f64 { |
| 49 | +pub fn df2(x: &[f64], bx_0: &[f64], y: f64) -> f64 { |
46 | 50 | unsafe { asm!("NOP", options(pure, nomem)); };
|
47 | 51 | ::core::hint::black_box(f2(x, y));
|
48 |
| - ::core::hint::black_box((bx,)); |
| 52 | + ::core::hint::black_box((bx_0,)); |
49 | 53 | ::core::hint::black_box(f2(x, y))
|
50 | 54 | }
|
51 | 55 | #[rustc_autodiff]
|
52 | 56 | #[inline(never)]
|
53 | 57 | pub fn f3(x: &[f64], y: f64) -> f64 {
|
54 | 58 | ::core::panicking::panic("not implemented")
|
55 | 59 | }
|
56 |
| -#[rustc_autodiff(Forward, Dual, Const, Const,)] |
| 60 | +#[rustc_autodiff(Forward, 1, Dual, Const, Const)] |
57 | 61 | #[inline(never)]
|
58 |
| -pub fn df3(x: &[f64], bx: &[f64], y: f64) -> f64 { |
| 62 | +pub fn df3(x: &[f64], bx_0: &[f64], y: f64) -> f64 { |
59 | 63 | unsafe { asm!("NOP", options(pure, nomem)); };
|
60 | 64 | ::core::hint::black_box(f3(x, y));
|
61 |
| - ::core::hint::black_box((bx,)); |
| 65 | + ::core::hint::black_box((bx_0,)); |
62 | 66 | ::core::hint::black_box(f3(x, y))
|
63 | 67 | }
|
64 | 68 | #[rustc_autodiff]
|
65 | 69 | #[inline(never)]
|
66 | 70 | pub fn f4() {}
|
67 |
| -#[rustc_autodiff(Forward, None)] |
| 71 | +#[rustc_autodiff(Forward, 1, None)] |
68 | 72 | #[inline(never)]
|
69 |
| -pub fn df4() { |
| 73 | +pub fn df4() -> () { |
70 | 74 | unsafe { asm!("NOP", options(pure, nomem)); };
|
71 | 75 | ::core::hint::black_box(f4());
|
72 | 76 | ::core::hint::black_box(());
|
|
76 | 80 | pub fn f5(x: &[f64], y: f64) -> f64 {
|
77 | 81 | ::core::panicking::panic("not implemented")
|
78 | 82 | }
|
79 |
| -#[rustc_autodiff(Forward, Const, Dual, Const,)] |
| 83 | +#[rustc_autodiff(Forward, 1, Const, Dual, Const)] |
80 | 84 | #[inline(never)]
|
81 |
| -pub fn df5_y(x: &[f64], y: f64, by: f64) -> f64 { |
| 85 | +pub fn df5_y(x: &[f64], y: f64, by_0: f64) -> f64 { |
82 | 86 | unsafe { asm!("NOP", options(pure, nomem)); };
|
83 | 87 | ::core::hint::black_box(f5(x, y));
|
84 |
| - ::core::hint::black_box((by,)); |
| 88 | + ::core::hint::black_box((by_0,)); |
85 | 89 | ::core::hint::black_box(f5(x, y))
|
86 | 90 | }
|
87 |
| -#[rustc_autodiff(Forward, Dual, Const, Const,)] |
| 91 | +#[rustc_autodiff(Forward, 1, Dual, Const, Const)] |
88 | 92 | #[inline(never)]
|
89 |
| -pub fn df5_x(x: &[f64], bx: &[f64], y: f64) -> f64 { |
| 93 | +pub fn df5_x(x: &[f64], bx_0: &[f64], y: f64) -> f64 { |
90 | 94 | unsafe { asm!("NOP", options(pure, nomem)); };
|
91 | 95 | ::core::hint::black_box(f5(x, y));
|
92 |
| - ::core::hint::black_box((bx,)); |
| 96 | + ::core::hint::black_box((bx_0,)); |
93 | 97 | ::core::hint::black_box(f5(x, y))
|
94 | 98 | }
|
95 |
| -#[rustc_autodiff(Reverse, Duplicated, Const, Active,)] |
| 99 | +#[rustc_autodiff(Reverse, 1, Duplicated, Const, Active)] |
96 | 100 | #[inline(never)]
|
97 |
| -pub fn df5_rev(x: &[f64], dx: &mut [f64], y: f64, dret: f64) -> f64 { |
| 101 | +pub fn df5_rev(x: &[f64], dx_0: &mut [f64], y: f64, dret: f64) -> f64 { |
98 | 102 | unsafe { asm!("NOP", options(pure, nomem)); };
|
99 | 103 | ::core::hint::black_box(f5(x, y));
|
100 |
| - ::core::hint::black_box((dx, dret)); |
| 104 | + ::core::hint::black_box((dx_0, dret)); |
101 | 105 | ::core::hint::black_box(f5(x, y))
|
102 | 106 | }
|
| 107 | +struct DoesNotImplDefault; |
| 108 | +#[rustc_autodiff] |
| 109 | +#[inline(never)] |
| 110 | +pub fn f6() -> DoesNotImplDefault { |
| 111 | + ::core::panicking::panic("not implemented") |
| 112 | +} |
| 113 | +#[rustc_autodiff(Forward, 1, Const)] |
| 114 | +#[inline(never)] |
| 115 | +pub fn df6() -> DoesNotImplDefault { |
| 116 | + unsafe { asm!("NOP", options(pure, nomem)); }; |
| 117 | + ::core::hint::black_box(f6()); |
| 118 | + ::core::hint::black_box(()); |
| 119 | + ::core::hint::black_box(f6()) |
| 120 | +} |
| 121 | +#[rustc_autodiff] |
| 122 | +#[inline(never)] |
| 123 | +pub fn f7(x: f32) -> () {} |
| 124 | +#[rustc_autodiff(Forward, 1, Const, None)] |
| 125 | +#[inline(never)] |
| 126 | +pub fn df7(x: f32) -> () { |
| 127 | + unsafe { asm!("NOP", options(pure, nomem)); }; |
| 128 | + ::core::hint::black_box(f7(x)); |
| 129 | + ::core::hint::black_box(()); |
| 130 | +} |
| 131 | +#[no_mangle] |
| 132 | +#[rustc_autodiff] |
| 133 | +#[inline(never)] |
| 134 | +fn f8(x: &f32) -> f32 { ::core::panicking::panic("not implemented") } |
| 135 | +#[rustc_autodiff(Forward, 4, Dual, Dual)] |
| 136 | +#[inline(never)] |
| 137 | +fn f8_3(x: &f32, bx_0: &f32, bx_1: &f32, bx_2: &f32, bx_3: &f32) |
| 138 | + -> [f32; 5usize] { |
| 139 | + unsafe { asm!("NOP", options(pure, nomem)); }; |
| 140 | + ::core::hint::black_box(f8(x)); |
| 141 | + ::core::hint::black_box((bx_0, bx_1, bx_2, bx_3)); |
| 142 | + ::core::hint::black_box(<[f32; 5usize]>::default()) |
| 143 | +} |
| 144 | +#[rustc_autodiff(Forward, 4, Dual, DualOnly)] |
| 145 | +#[inline(never)] |
| 146 | +fn f8_2(x: &f32, bx_0: &f32, bx_1: &f32, bx_2: &f32, bx_3: &f32) |
| 147 | + -> [f32; 4usize] { |
| 148 | + unsafe { asm!("NOP", options(pure, nomem)); }; |
| 149 | + ::core::hint::black_box(f8(x)); |
| 150 | + ::core::hint::black_box((bx_0, bx_1, bx_2, bx_3)); |
| 151 | + ::core::hint::black_box(<[f32; 4usize]>::default()) |
| 152 | +} |
| 153 | +#[rustc_autodiff(Forward, 1, Dual, DualOnly)] |
| 154 | +#[inline(never)] |
| 155 | +fn f8_1(x: &f32, bx_0: &f32) -> f32 { |
| 156 | + unsafe { asm!("NOP", options(pure, nomem)); }; |
| 157 | + ::core::hint::black_box(f8(x)); |
| 158 | + ::core::hint::black_box((bx_0,)); |
| 159 | + ::core::hint::black_box(<f32>::default()) |
| 160 | +} |
103 | 161 | fn main() {}
|
0 commit comments