Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions test/lib/array.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,28 @@ using Zygote: ZygoteRuleConfig

test_rrule(ZygoteRuleConfig(), x->sum(sin, Diagonal(x)), ones(2); rrule_f=rrule_via_ad, check_inferred=false)
test_rrule(ZygoteRuleConfig(), x->sum(sin, Diagonal(x)), rand(3); rrule_f=rrule_via_ad, check_inferred=false)

using Test, ChainRulesTestUtils, FiniteDifferences, Zygote
@testset "sum(f, x)" begin
mutable struct F
s
end
function (f::F)(x)
f.s += x
return f.s
end
gfd = FiniteDifferences.grad(FiniteDifferences.central_fdm(5,1),
x -> begin
f = F(0)
sum(f, x)
end
, [1.0, 2.0, 3.0])[1]


gad = gradient([1.,2.,3.]) do x
f = F(0.)
sum(f, x)
end[1]

@test gad ≈ gfd
end
90 changes: 45 additions & 45 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,56 +2,56 @@ using Zygote, Test
using Zygote: gradient, ZygoteRuleConfig
using CUDA: has_cuda

if has_cuda()
@testset "CUDA tests" begin
include("cuda.jl")
end
else
@warn "CUDA not found - Skipping CUDA Tests"
end

@testset "Interface" begin
include("interface.jl")
end

@testset "Tools" begin
include("tools.jl")
end

@testset "Utils" begin
include("utils.jl")
end

@testset "lib" begin
include("lib/number.jl")
include("lib/lib.jl")
# if has_cuda()
# @testset "CUDA tests" begin
# include("cuda.jl")
# end
# else
# @warn "CUDA not found - Skipping CUDA Tests"
# end

# @testset "Interface" begin
# include("interface.jl")
# end

# @testset "Tools" begin
# include("tools.jl")
# end

# @testset "Utils" begin
# include("utils.jl")
# end

# @testset "lib" begin
# include("lib/number.jl")
# include("lib/lib.jl")
include("lib/array.jl")
end
# end

@testset "Features" begin
include("features.jl")
end
# @testset "Features" begin
# include("features.jl")
# end

@testset "Forward" begin
include("forward/forward.jl")
end
# @testset "Forward" begin
# include("forward/forward.jl")
# end

@testset "Data Structures" begin
include("structures.jl")
end
# @testset "Data Structures" begin
# include("structures.jl")
# end

@testset "ChainRules" begin
include("chainrules.jl")
end
# @testset "ChainRules" begin
# include("chainrules.jl")
# end

@testset "Gradients" begin
include("gradcheck.jl")
end
# @testset "Gradients" begin
# include("gradcheck.jl")
# end

@testset "Complex" begin
include("complex.jl")
end
# @testset "Complex" begin
# include("complex.jl")
# end

@testset "Compiler" begin
include("compiler.jl")
end
# @testset "Compiler" begin
# include("compiler.jl")
# end