@@ -142,7 +142,6 @@ function test_approx_structs(l, l̄, l̄2; atol=1e-5, rtol=1e-5,
142
142
end
143
143
144
144
145
-
146
145
"""
147
146
to32(m)
148
147
@@ -166,57 +165,3 @@ function to64(m)
166
165
f (x) = adapt (Float64, x)
167
166
return fmap (f, m)
168
167
end
169
-
170
-
171
-
172
- # function gpu_gradtest(l, x_cpu = nothing, args...; test_cpu = true)
173
- # isnothing(x_cpu) && error("Missing input to test the layers against.")
174
- # @testset "$name GPU grad tests" begin
175
- # for layer in layers
176
- # @testset "$layer Layer GPU grad test" begin
177
-
178
- # # compute output and grad of parameters
179
- # l_cpu = layer(args...)
180
- # ps_cpu = Flux.params(l_cpu)
181
- # y_cpu, back_cpu = pullback(() -> sum(l_cpu(x_cpu)), ps_cpu)
182
- # gs_cpu = back_cpu(1f0)
183
-
184
- # x_gpu = gpu(x_cpu)
185
- # l_gpu = l_cpu |> gpu
186
- # ps_gpu = Flux.params(l_gpu)
187
-
188
- # if typeof(l_gpu) <: BROKEN_LAYERS
189
- # @test_broken gradient(() -> sum(l_gpu(x_gpu)), ps_gpu) isa Flux.Zygote.Grads
190
- # else
191
- # y_gpu, back_gpu = pullback(() -> sum(l_gpu(x_gpu)), ps_gpu)
192
- # gs_gpu = back_gpu(1f0) # TODO many layers error out when backprop int 1, should fix
193
-
194
- # # compute grad of input
195
- # xg_cpu = gradient(x -> sum(l_cpu(x)), x_cpu)[1]
196
- # xg_gpu = gradient(x -> sum(l_gpu(x)), x_gpu)[1]
197
-
198
- # # test
199
- # if test_cpu
200
- # @test y_gpu ≈ y_cpu rtol=1f-3 atol=1f-3
201
- # if isnothing(xg_cpu)
202
- # @test isnothing(xg_gpu)
203
- # else
204
- # @test Array(xg_gpu) ≈ xg_cpu rtol=1f-3 atol=1f-3
205
- # end
206
- # end
207
- # @test gs_gpu isa Flux.Zygote.Grads
208
- # for (p_cpu, p_gpu) in zip(ps_cpu, ps_gpu)
209
- # if isnothing(gs_cpu[p_cpu])
210
- # @test isnothing(gs_gpu[p_gpu])
211
- # else
212
- # @test gs_gpu[p_gpu] isa Flux.CUDA.CuArray
213
- # if test_cpu
214
- # @test Array(gs_gpu[p_gpu]) ≈ gs_cpu[p_cpu] rtol=1f-3 atol=1f-3
215
- # end
216
- # end
217
- # end
218
- # end
219
- # end
220
- # end
221
- # end
222
- # end
0 commit comments