Skip to content
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
4 changes: 4 additions & 0 deletions src/llvm/attributes.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
const nofreefns = Set{String}((
"jl_f__compute_sparams",
"ijl_f__compute_sparams",
"jl_genericmemory_copyto",
"jl_get_binding_value_seqcst",
"ijl_get_binding_value_seqcst",
Expand Down Expand Up @@ -215,6 +217,8 @@ const nofreefns = Set{String}((
))

const inactivefns = Set{String}((
"jl_f__compute_sparams",
"ijl_f__compute_sparams",

# The binding lookup is asserted as inactive [e.g. globals are considered constant wrt differentiation]
# If and when this changes, we need to change that here
Expand Down
17 changes: 17 additions & 0 deletions test/sparam.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using Enzyme, Test

dual_type(c::NTuple{N, Float64}) where {N} = Val{N}

function loss(x::Vector{Float64})
t = ntuple(_ -> 0.0, length(x)) # NTuple{_A, Float64} where _A — non-inferable N
return sum(x) + (dual_type(t) === Val{2} ? 0.0 : 1.0)
end

@testset "broadcast" begin
res = Enzyme.gradient(
Enzyme.set_runtime_activity(Enzyme.Reverse),
Enzyme.Const(loss),
[1.0, 2.0]
)[1]
@test res ≈ [1.0, 1.0]
end
Loading