You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With a slightly modified version of #1004, where part of the loop body is put into a function, we get an error "Enzyme compilation failed due to illegal type analysis.", on Enzyme.jl master. Note that manually inlining mymul! resolves the error. (Edit: also, using mul! rather than the gemv call directly also resolves the error.) MWE:
using Enzyme, LinearAlgebra
LinearAlgebra.BLAS.set_num_threads(1)
Enzyme.Compiler.bitcode_replacement!(true)
@inlinefunctioncoupled_springs(K, m, x0, v0, T)
Ktmp =copy(K)
xtmp =copy(x0)
vtmp =copy(v0)
N =length(m)
pX =pointer(xtmp)
pY =pointer(vtmp)
pA =pointer(Ktmp)
for j in1:5000mymul!(vtmp, Ktmp, xtmp, pX, pY, pA)
xtmp .+= vtmp ./5000endreturn@inbounds xtmp[1]
end@inlinefunctionmymul!(vtmp, Ktmp, xtmp, pX, pY, pA)
sX =1
sY =1
GC.@preserve vtmp Ktmp xtmp ccall((:dgemv_64_, LinearAlgebra.BLAS.libblastrampoline), Cvoid,
(Ref{UInt8}, Ref{LinearAlgebra.BLAS.BlasInt}, Ref{LinearAlgebra.BLAS.BlasInt}, Ref{Float64},
Ptr{Float64}, Ref{LinearAlgebra.BLAS.BlasInt}, Ptr{Float64}, Ref{LinearAlgebra.BLAS.BlasInt},
Ref{Float64}, Ptr{Float64}, Ref{LinearAlgebra.BLAS.BlasInt}, Clong),
'N', N, N, 1/5000,
pA, N, pX, sX,
1.0, pY, sY, 1)
endfunctionmake_args(N)
K =ones(N, N)#collect(reshape(1:N^2, N, N))
K[diagind(K)] .=0
m =0.5.+0.5*rand(N)
x0 =float.(collect(1:N)) ./ N
v0 =zeros(N)
T =1.0return K, m, x0, v0, T
endfunctionenzyme_inputs(K, m, x0, v0, T)
dK =zero(K)
dm =zero(m)
dx0 =zero(x0)
dv0 =zero(v0)
returnDuplicated(K, dK), Duplicated(m, dm), Duplicated(x0, dx0), Duplicated(v0, dv0), Const(T)
endfunctionenzyme_gradient(args...)
inputs =enzyme_inputs(args...)
dK = inputs[1].dval
Enzyme.autodiff(Reverse, Const(coupled_springs), inputs...)
return dK
end
N =200
args =make_args(N)
coupled_springs(args...)
enzyme_gradient(args...)
With a slightly modified version of #1004, where part of the loop body is put into a function, we get an error "Enzyme compilation failed due to illegal type analysis.", on Enzyme.jl master. Note that manually inlining
mymul!
resolves the error. (Edit: also, usingmul!
rather than the gemv call directly also resolves the error.) MWE:Error:
error.ll.txt
The text was updated successfully, but these errors were encountered: