Skip to content

Commit

Permalink
Remove uses of similar to generate test inputs (#304)
Browse files Browse the repository at this point in the history
  • Loading branch information
oxinabox committed Nov 10, 2020
1 parent 43d4a3d commit d40e3e1
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions dev/ChainRulesTestUtils
Submodule ChainRulesTestUtils added at 6f5cd3
4 changes: 2 additions & 2 deletions test/rulesets/LinearAlgebra/dense.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
M, N = 3, 4
x, A, y = randn(T, M), randn(T, M, N), randn(T, N)
ẋ, Adot, ẏ = randn(T, M), randn(T, M, N), randn(T, N)
x̄, Abar, ȳ = similar(x), similar(A), similar(y)
x̄, Abar, ȳ = randn(T, M), randn(T, M, N), randn(T, N)
frule_test(dot, (x, ẋ), (A, Adot), (y, ẏ))
rrule_test(dot, randn(T), (x, x̄), (A, Abar), (y, ȳ))
end
Expand All @@ -37,7 +37,7 @@
M, N = 3, 4
x, A, y = rand(T, M), F(rand(T, N, M)), rand(T, N)
ẋ, Adot, ẏ = rand(T, M), F(rand(T, N, M)), rand(T, N)
x̄, Abar, ȳ = similar(x), F(rand(T, N, M)), similar(y)
x̄, Abar, ȳ = rand(T, M), F(rand(T, N, M)), rand(T, N)
frule_test(dot, (x, ẋ), (A, Adot), (y, ẏ); rtol=1f-3)
rrule_test(dot, float(rand(T)), (x, x̄), (A, Abar), (y, ȳ); rtol=1f-3)
end
Expand Down
4 changes: 3 additions & 1 deletion test/rulesets/LinearAlgebra/structured.jl
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@
@testset "dot(x, ::Diagonal, y)" begin
N = 4
x, d, y = randn(ComplexF64, N), randn(ComplexF64, N), randn(ComplexF64, N)
x̄, d̄, ȳ = randn(ComplexF64, N), randn(ComplexF64, N), randn(ComplexF64, N)
D = Diagonal(d)
rrule_test(dot, rand(ComplexF64), (x,similar(x)), (D,similar(D)), (y,similar(y)))
= Diagonal(d̄)
rrule_test(dot, rand(ComplexF64), (x, x̄), (D, D̄), (y, ȳ))
end
@testset "::Diagonal * ::AbstractVector" begin
N = 3
Expand Down

0 comments on commit d40e3e1

Please sign in to comment.