Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update EnzymeCoreExt.jl #2565

Merged
merged 4 commits into from
Dec 11, 2024
Merged
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
2 changes: 1 addition & 1 deletion ext/EnzymeCoreExt.jl
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code should test the change

@testset "Reverse sum abs2" begin
    x = CuArray([1.0, 2.0, 3.0, 4.0])
    dx = CuArray([0., 0.0, 0.0, 0.0])
    f(x) = sum(abs2.(x))
    Enzyme.autodiff(Reverse, f, Active, Duplicated(x, dx))
    @test all(dx .≈ 2.*x)
end

Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ end
function EnzymeCore.EnzymeRules.inactive_noinl(::typeof(CUDA.is_pinned), args...)
return nothing
end
function EnzymeCore.EnzymeRules.inactive_noinl(::typeof(CUDA.launch_configuration), args...; kwargs...)
function EnzymeCore.EnzymeRules.inactive(::typeof(CUDA.launch_configuration), args...; kwargs...)
return nothing
end

Expand Down
10 changes: 10 additions & 0 deletions test/extensions/enzyme.jl
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,16 @@ end
@test all(dx .≈ 1)
@test all(dy .≈ 1)
end

sumabs2(x) = sum(abs2.(x))

@testset "Reverse sum abs2" begin
x = CuArray([1.0, 2.0, 3.0, 4.0])
dx = CuArray([0., 0.0, 0.0, 0.0])
Enzyme.autodiff(Reverse, sumabs2, Active, Duplicated(x, dx))
@test all(dx .≈ 2 .* x)
end

# TODO once reverse kernels are in
# function togpu(x)
# x = CuArray(x)
Expand Down