|
3 | 3 | //@ needs-enzyme
|
4 | 4 |
|
5 | 5 | #![feature(autodiff)]
|
| 6 | +#![feature(intrinsics)] |
6 | 7 | #[prelude_import]
|
7 | 8 | use ::std::prelude::rust_2015::*;
|
8 | 9 | #[macro_use]
|
|
36 | 37 | ::core::panicking::panic("not implemented")
|
37 | 38 | }
|
38 | 39 | #[rustc_autodiff(Forward, 1, Dual, Const, Dual)]
|
39 |
| -#[inline(never)] |
40 |
| -pub fn df1(x: &[f64], bx_0: &[f64], y: f64) -> (f64, f64) { |
41 |
| - unsafe { asm!("NOP", options(pure, nomem)); }; |
42 |
| - ::core::hint::black_box(f1(x, y)); |
43 |
| - ::core::hint::black_box((bx_0,)); |
44 |
| - ::core::hint::black_box(<(f64, f64)>::default()) |
45 |
| -} |
| 40 | +#[rustc_intrinsic] |
| 41 | +pub fn df1(x: &[f64], bx_0: &[f64], y: f64) -> (f64, f64); |
46 | 42 | #[rustc_autodiff]
|
47 | 43 | #[inline(never)]
|
48 | 44 | pub fn f2(x: &[f64], y: f64) -> f64 {
|
49 | 45 | ::core::panicking::panic("not implemented")
|
50 | 46 | }
|
51 | 47 | #[rustc_autodiff(Forward, 1, Dual, Const, Const)]
|
52 |
| -#[inline(never)] |
53 |
| -pub fn df2(x: &[f64], bx_0: &[f64], y: f64) -> f64 { |
54 |
| - unsafe { asm!("NOP", options(pure, nomem)); }; |
55 |
| - ::core::hint::black_box(f2(x, y)); |
56 |
| - ::core::hint::black_box((bx_0,)); |
57 |
| - ::core::hint::black_box(f2(x, y)) |
58 |
| -} |
| 48 | +#[rustc_intrinsic] |
| 49 | +pub fn df2(x: &[f64], bx_0: &[f64], y: f64) -> f64; |
59 | 50 | #[rustc_autodiff]
|
60 | 51 | #[inline(never)]
|
61 | 52 | pub fn f3(x: &[f64], y: f64) -> f64 {
|
62 | 53 | ::core::panicking::panic("not implemented")
|
63 | 54 | }
|
64 | 55 | #[rustc_autodiff(Forward, 1, Dual, Const, Const)]
|
65 |
| -#[inline(never)] |
66 |
| -pub fn df3(x: &[f64], bx_0: &[f64], y: f64) -> f64 { |
67 |
| - unsafe { asm!("NOP", options(pure, nomem)); }; |
68 |
| - ::core::hint::black_box(f3(x, y)); |
69 |
| - ::core::hint::black_box((bx_0,)); |
70 |
| - ::core::hint::black_box(f3(x, y)) |
71 |
| -} |
| 56 | +#[rustc_intrinsic] |
| 57 | +pub fn df3(x: &[f64], bx_0: &[f64], y: f64) -> f64; |
72 | 58 | #[rustc_autodiff]
|
73 | 59 | #[inline(never)]
|
74 | 60 | pub fn f4() {}
|
75 | 61 | #[rustc_autodiff(Forward, 1, None)]
|
76 |
| -#[inline(never)] |
77 |
| -pub fn df4() -> () { |
78 |
| - unsafe { asm!("NOP", options(pure, nomem)); }; |
79 |
| - ::core::hint::black_box(f4()); |
80 |
| - ::core::hint::black_box(()); |
81 |
| -} |
| 62 | +#[rustc_intrinsic] |
| 63 | +pub fn df4() -> (); |
82 | 64 | #[rustc_autodiff]
|
83 | 65 | #[inline(never)]
|
84 | 66 | pub fn f5(x: &[f64], y: f64) -> f64 {
|
85 | 67 | ::core::panicking::panic("not implemented")
|
86 | 68 | }
|
87 | 69 | #[rustc_autodiff(Forward, 1, Const, Dual, Const)]
|
88 |
| -#[inline(never)] |
89 |
| -pub fn df5_y(x: &[f64], y: f64, by_0: f64) -> f64 { |
90 |
| - unsafe { asm!("NOP", options(pure, nomem)); }; |
91 |
| - ::core::hint::black_box(f5(x, y)); |
92 |
| - ::core::hint::black_box((by_0,)); |
93 |
| - ::core::hint::black_box(f5(x, y)) |
94 |
| -} |
| 70 | +#[rustc_intrinsic] |
| 71 | +pub fn df5_y(x: &[f64], y: f64, by_0: f64) -> f64; |
95 | 72 | #[rustc_autodiff(Forward, 1, Dual, Const, Const)]
|
96 |
| -#[inline(never)] |
97 |
| -pub fn df5_x(x: &[f64], bx_0: &[f64], y: f64) -> f64 { |
98 |
| - unsafe { asm!("NOP", options(pure, nomem)); }; |
99 |
| - ::core::hint::black_box(f5(x, y)); |
100 |
| - ::core::hint::black_box((bx_0,)); |
101 |
| - ::core::hint::black_box(f5(x, y)) |
102 |
| -} |
| 73 | +#[rustc_intrinsic] |
| 74 | +pub fn df5_x(x: &[f64], bx_0: &[f64], y: f64) -> f64; |
103 | 75 | #[rustc_autodiff(Reverse, 1, Duplicated, Const, Active)]
|
104 |
| -#[inline(never)] |
105 |
| -pub fn df5_rev(x: &[f64], dx_0: &mut [f64], y: f64, dret: f64) -> f64 { |
106 |
| - unsafe { asm!("NOP", options(pure, nomem)); }; |
107 |
| - ::core::hint::black_box(f5(x, y)); |
108 |
| - ::core::hint::black_box((dx_0, dret)); |
109 |
| - ::core::hint::black_box(f5(x, y)) |
110 |
| -} |
| 76 | +#[rustc_intrinsic] |
| 77 | +pub fn df5_rev(x: &[f64], dx_0: &mut [f64], y: f64, dret: f64) -> f64; |
111 | 78 | struct DoesNotImplDefault;
|
112 | 79 | #[rustc_autodiff]
|
113 | 80 | #[inline(never)]
|
114 | 81 | pub fn f6() -> DoesNotImplDefault {
|
115 | 82 | ::core::panicking::panic("not implemented")
|
116 | 83 | }
|
117 | 84 | #[rustc_autodiff(Forward, 1, Const)]
|
118 |
| -#[inline(never)] |
119 |
| -pub fn df6() -> DoesNotImplDefault { |
120 |
| - unsafe { asm!("NOP", options(pure, nomem)); }; |
121 |
| - ::core::hint::black_box(f6()); |
122 |
| - ::core::hint::black_box(()); |
123 |
| - ::core::hint::black_box(f6()) |
124 |
| -} |
| 85 | +#[rustc_intrinsic] |
| 86 | +pub fn df6() -> DoesNotImplDefault; |
125 | 87 | #[rustc_autodiff]
|
126 | 88 | #[inline(never)]
|
127 | 89 | pub fn f7(x: f32) -> () {}
|
128 | 90 | #[rustc_autodiff(Forward, 1, Const, None)]
|
129 |
| -#[inline(never)] |
130 |
| -pub fn df7(x: f32) -> () { |
131 |
| - unsafe { asm!("NOP", options(pure, nomem)); }; |
132 |
| - ::core::hint::black_box(f7(x)); |
133 |
| - ::core::hint::black_box(()); |
134 |
| -} |
| 91 | +#[rustc_intrinsic] |
| 92 | +pub fn df7(x: f32) -> (); |
135 | 93 | #[no_mangle]
|
136 | 94 | #[rustc_autodiff]
|
137 | 95 | #[inline(never)]
|
138 | 96 | fn f8(x: &f32) -> f32 { ::core::panicking::panic("not implemented") }
|
139 | 97 | #[rustc_autodiff(Forward, 4, Dual, Dual)]
|
140 |
| -#[inline(never)] |
| 98 | +#[rustc_intrinsic] |
141 | 99 | fn f8_3(x: &f32, bx_0: &f32, bx_1: &f32, bx_2: &f32, bx_3: &f32)
|
142 |
| - -> [f32; 5usize] { |
143 |
| - unsafe { asm!("NOP", options(pure, nomem)); }; |
144 |
| - ::core::hint::black_box(f8(x)); |
145 |
| - ::core::hint::black_box((bx_0, bx_1, bx_2, bx_3)); |
146 |
| - ::core::hint::black_box(<[f32; 5usize]>::default()) |
147 |
| -} |
| 100 | +-> [f32; 5usize]; |
148 | 101 | #[rustc_autodiff(Forward, 4, Dual, DualOnly)]
|
149 |
| -#[inline(never)] |
| 102 | +#[rustc_intrinsic] |
150 | 103 | fn f8_2(x: &f32, bx_0: &f32, bx_1: &f32, bx_2: &f32, bx_3: &f32)
|
151 |
| - -> [f32; 4usize] { |
152 |
| - unsafe { asm!("NOP", options(pure, nomem)); }; |
153 |
| - ::core::hint::black_box(f8(x)); |
154 |
| - ::core::hint::black_box((bx_0, bx_1, bx_2, bx_3)); |
155 |
| - ::core::hint::black_box(<[f32; 4usize]>::default()) |
156 |
| -} |
| 104 | +-> [f32; 4usize]; |
157 | 105 | #[rustc_autodiff(Forward, 1, Dual, DualOnly)]
|
158 |
| -#[inline(never)] |
159 |
| -fn f8_1(x: &f32, bx_0: &f32) -> f32 { |
160 |
| - unsafe { asm!("NOP", options(pure, nomem)); }; |
161 |
| - ::core::hint::black_box(f8(x)); |
162 |
| - ::core::hint::black_box((bx_0,)); |
163 |
| - ::core::hint::black_box(<f32>::default()) |
164 |
| -} |
| 106 | +#[rustc_intrinsic] |
| 107 | +fn f8_1(x: &f32, bx_0: &f32) -> f32; |
165 | 108 | pub fn f9() {
|
166 | 109 | #[rustc_autodiff]
|
167 | 110 | #[inline(never)]
|
168 | 111 | fn inner(x: f32) -> f32 { x * x }
|
169 | 112 | #[rustc_autodiff(Forward, 1, Dual, Dual)]
|
170 |
| - #[inline(never)] |
171 |
| - fn d_inner_2(x: f32, bx_0: f32) -> (f32, f32) { |
172 |
| - unsafe { asm!("NOP", options(pure, nomem)); }; |
173 |
| - ::core::hint::black_box(inner(x)); |
174 |
| - ::core::hint::black_box((bx_0,)); |
175 |
| - ::core::hint::black_box(<(f32, f32)>::default()) |
176 |
| - } |
| 113 | + #[rustc_intrinsic] |
| 114 | + fn d_inner_2(x: f32, bx_0: f32) |
| 115 | + -> (f32, f32); |
177 | 116 | #[rustc_autodiff(Forward, 1, Dual, DualOnly)]
|
178 |
| - #[inline(never)] |
179 |
| - fn d_inner_1(x: f32, bx_0: f32) -> f32 { |
180 |
| - unsafe { asm!("NOP", options(pure, nomem)); }; |
181 |
| - ::core::hint::black_box(inner(x)); |
182 |
| - ::core::hint::black_box((bx_0,)); |
183 |
| - ::core::hint::black_box(<f32>::default()) |
184 |
| - } |
| 117 | + #[rustc_intrinsic] |
| 118 | + fn d_inner_1(x: f32, bx_0: f32) |
| 119 | + -> f32; |
185 | 120 | }
|
186 | 121 | #[rustc_autodiff]
|
187 | 122 | #[inline(never)]
|
188 | 123 | pub fn f10<T: std::ops::Mul<Output = T> + Copy>(x: &T) -> T { *x * *x }
|
189 | 124 | #[rustc_autodiff(Reverse, 1, Duplicated, Active)]
|
190 |
| -#[inline(never)] |
| 125 | +#[rustc_intrinsic] |
191 | 126 | pub fn d_square<T: std::ops::Mul<Output = T> +
|
192 |
| - Copy>(x: &T, dx_0: &mut T, dret: T) -> T { |
193 |
| - unsafe { asm!("NOP", options(pure, nomem)); }; |
194 |
| - ::core::hint::black_box(f10::<T>(x)); |
195 |
| - ::core::hint::black_box((dx_0, dret)); |
196 |
| - ::core::hint::black_box(f10::<T>(x)) |
197 |
| -} |
| 127 | +Copy>(x: &T, dx_0: &mut T, dret: T) -> T; |
198 | 128 | fn main() {}
|
0 commit comments