Conversation
Contributor
|
Your PR requires formatting changes to meet the project's style guidelines. Click here to view the suggested changes.diff --git a/lib/EnzymeTestUtils/src/test_approx.jl b/lib/EnzymeTestUtils/src/test_approx.jl
index 2a5684b6..62e3f96d 100644
--- a/lib/EnzymeTestUtils/src/test_approx.jl
+++ b/lib/EnzymeTestUtils/src/test_approx.jl
@@ -1,9 +1,9 @@
test_approx(x, y; kwargs...) = test_approx(x, y, ""; kwargs...)
-function test_approx(x::Number, y::Number, msg; seen=Base.IdSet(), kwargs...)
+function test_approx(x::Number, y::Number, msg; seen = Base.IdSet(), kwargs...)
@test_msg msg isapprox(x, y; kwargs...)
return nothing
end
-function test_approx(x::Array{<:Number}, y::Array{<:Number}, msg; seen=Base.IdSet(), kwargs...)
+function test_approx(x::Array{<:Number}, y::Array{<:Number}, msg; seen = Base.IdSet(), kwargs...)
@test_msg msg isapprox(x, y; kwargs...)
return nothing
end
@@ -13,7 +13,7 @@ function zero_copy(x)
copyto!(x.uplo == 'U' ? UpperTriangular(y) : LowerTriangular(y), x.uplo == 'U' ? UpperTriangular(x) : LowerTriangular(x))
y
end
-function test_approx(x::LinearAlgebra.HermOrSym{<:Number}, y::LinearAlgebra.HermOrSym{<:Number}, msg; seen=Base.IdSet(), kwargs...)
+function test_approx(x::LinearAlgebra.HermOrSym{<:Number}, y::LinearAlgebra.HermOrSym{<:Number}, msg; seen = Base.IdSet(), kwargs...)
x in seen && return nothing
push!(seen, x)
# on 1.11+ similar of a hermitian or symmetric leaves the other part of the array undefined
@@ -24,13 +24,13 @@ function test_approx(x::LinearAlgebra.HermOrSym{<:Number}, y::LinearAlgebra.Herm
test_approx(x2, y2, msg; seen, kwargs...)
return nothing
end
-function test_approx(x::AbstractArray{<:Number}, y::AbstractArray{<:Number}, msg; seen=Base.IdSet(), kwargs...)
+function test_approx(x::AbstractArray{<:Number}, y::AbstractArray{<:Number}, msg; seen = Base.IdSet(), kwargs...)
@test_msg msg isapprox(x, y; kwargs...)
# for custom array types, fields should also match
_test_fields_approx(x, y, msg; seen, kwargs...)
return nothing
end
-function test_approx(x::AbstractArray, y::AbstractArray, msg; seen=Base.IdSet(), kwargs...)
+function test_approx(x::AbstractArray, y::AbstractArray, msg; seen = Base.IdSet(), kwargs...)
x in seen && return nothing
push!(seen, x)
@test_msg "$msg: indices must match" eachindex(x) == eachindex(y)
@@ -40,7 +40,7 @@ function test_approx(x::AbstractArray, y::AbstractArray, msg; seen=Base.IdSet(),
end
return nothing
end
-function test_approx(x::Tuple, y::Tuple, msg; seen=Base.IdSet(), kwargs...)
+function test_approx(x::Tuple, y::Tuple, msg; seen = Base.IdSet(), kwargs...)
@test_msg "$msg: lengths must match" length(x) == length(y)
for i in eachindex(x)
msg_new = "$msg: ::$(typeof(x))[$i]"
@@ -48,7 +48,7 @@ function test_approx(x::Tuple, y::Tuple, msg; seen=Base.IdSet(), kwargs...)
end
return nothing
end
-function test_approx(x::Dict, y::Dict, msg; seen=Base.IdSet(), kwargs...)
+function test_approx(x::Dict, y::Dict, msg; seen = Base.IdSet(), kwargs...)
x in seen && return nothing
push!(seen, x)
@test_msg "$msg: keys must match" issetequal(keys(x), keys(y))
@@ -58,13 +58,13 @@ function test_approx(x::Dict, y::Dict, msg; seen=Base.IdSet(), kwargs...)
end
return nothing
end
-function test_approx(x::Type, y::Type, msg; seen=Base.IdSet(), kwargs...)
+function test_approx(x::Type, y::Type, msg; seen = Base.IdSet(), kwargs...)
@test_msg "$msg: types must match" x === y
return nothing
end
-test_approx(x, y, msg; seen=Base.IdSet(), kwargs...) = _test_fields_approx(x, y, msg; seen, kwargs...)
+test_approx(x, y, msg; seen = Base.IdSet(), kwargs...) = _test_fields_approx(x, y, msg; seen, kwargs...)
-function _test_fields_approx(x, y, msg; seen=Base.IdSet(), kwargs...)
+function _test_fields_approx(x, y, msg; seen = Base.IdSet(), kwargs...)
@test_msg "$msg: types must match" typeof(x) == typeof(y)
if ismutable(x)
x in seen && return nothing
diff --git a/lib/EnzymeTestUtils/src/to_vec.jl b/lib/EnzymeTestUtils/src/to_vec.jl
index 47180127..a94c5644 100644
--- a/lib/EnzymeTestUtils/src/to_vec.jl
+++ b/lib/EnzymeTestUtils/src/to_vec.jl
@@ -193,7 +193,7 @@ function to_vec(x::GenericMemory, seen_vecs::AliasDict)
if has_seen || is_const
x_vec = Float32[]
else
- seen_vecs[x] = Float32[]
+ seen_vecs[x] = Float32[]
from_vecs = []
subvec_inds = UnitRange{Int}[]
l = 0
@@ -220,14 +220,14 @@ function to_vec(x::GenericMemory, seen_vecs::AliasDict)
has_seen && return reshape(seen_xs[x], size(x))
is_const && return x
x_new = typeof(x)(undef, size(x))
- seen_xs[x] = x_new
+ seen_xs[x] = x_new
k = 1
for i in eachindex(x)
isassigned(x, i) || continue
xi = from_vecs[k](@view(x_vec_new[subvec_inds[k]]), seen_xs)
x_new[i] = xi
k += 1
- end
+ end
return x_new
end
return x_vec, Memory_from_vec |
Contributor
Benchmark Results
Benchmark PlotsA plot of the benchmark results has been uploaded as an artifact at https://github.com/EnzymeAD/Enzyme.jl/actions/runs/27852966542/artifacts/7759894083. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fixes #3116