@@ -114,6 +114,7 @@ Test the gradients of `f` with respect to `args` using the specified backends.
114
114
- `soft_fail`: If `true`, then the test will be recorded as a `soft_fail` test. This
115
115
overrides any `broken` kwargs. Alternatively, a list of backends can be passed to
116
116
`soft_fail` to allow soft_fail tests for only those backends.
117
+ - `enzyme_set_runtime_activity`: If `true`, then activate runtime activity for Enzyme.
117
118
- `kwargs`: Additional keyword arguments to pass to `check_approx`.
118
119
119
120
## Example
@@ -129,6 +130,7 @@ julia> test_gradients(f, 1.0, x, nothing)
129
130
"""
130
131
function test_gradients (f, args... ; skip_backends= [], broken_backends= [],
131
132
soft_fail:: Union{Bool, Vector} = false ,
133
+ enzyme_set_runtime_activity:: Bool = false ,
132
134
# Internal kwargs start
133
135
source:: LineNumberNode = LineNumberNode (0 , nothing ),
134
136
test_expr:: Expr = :(check_approx (∂args, ∂args_gt; kwargs... )),
@@ -146,7 +148,12 @@ function test_gradients(f, args...; skip_backends=[], broken_backends=[],
146
148
total_length ≤ 100 && push! (backends, AutoForwardDiff ())
147
149
total_length ≤ 100 && push! (backends, AutoFiniteDiff ())
148
150
# TODO : Move Enzyme out of here once it supports GPUs
149
- ENZYME_TESTING_ENABLED && push! (backends, AutoEnzyme ())
151
+ if ENZYME_TESTING_ENABLED
152
+ mode = enzyme_set_runtime_activity ?
153
+ Enzyme. set_runtime_activity (Enzyme. Reverse) :
154
+ Enzyme. Reverse
155
+ push! (backends, AutoEnzyme (; mode))
156
+ end
150
157
end
151
158
push! (backends, AutoTracker ())
152
159
0 commit comments