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

Complex image gradient rotation fails #3

Open
roflmaostc opened this issue Dec 15, 2023 · 1 comment
Open

Complex image gradient rotation fails #3

roflmaostc opened this issue Dec 15, 2023 · 1 comment

Comments

@roflmaostc
Copy link
Owner

julia> Zygote.gradient(x -> sum(abs.(DiffImageRotation.imrotate(x, deg2rad(0.1)))), randn(ComplexF32, (32,32,1)))
ERROR: TaskFailedException

    nested task error: MethodError: no method matching modify!(::Ptr{ComplexF32}, ::typeof(+), ::ComplexF32, ::UnsafeAtomics.Internal.LLVMOrdering{:seq_cst})
    
    Closest candidates are:
      modify!(::Core.LLVMPtr, ::OP, ::Any, ::UnsafeAtomics.Ordering) where OP
       @ UnsafeAtomicsLLVM ~/.julia/packages/UnsafeAtomicsLLVM/6HZfV/src/internal.jl:20
      modify!(::Ptr{T}, ::typeof(UnsafeAtomics.right), ::T, ::Any) where T
       @ UnsafeAtomics ~/.julia/packages/UnsafeAtomics/ugwrA/src/core.jl:197
      modify!(::Any, ::Any, ::Any)
       @ UnsafeAtomics ~/.julia/packages/UnsafeAtomics/ugwrA/src/core.jl:4
      ...
    
    Stacktrace:
     [1] modify!
       @ ~/.julia/packages/Atomix/F9VIX/src/core.jl:33 [inlined]
     [2] macro expansion
       @ ~/.julia/dev/DiffImageRotation.jl/src/DiffImageRotation.jl:230 [inlined]
     [3] cpu_imrotate_kernel_adj!
       @ ~/.julia/packages/KernelAbstractions/mS4kn/src/macros.jl:287 [inlined]
     [4] cpu_imrotate_kernel_adj!(__ctx__::KernelAbstractions.CompilerMetadata{KernelAbstractions.NDIteration.DynamicSize, KernelAbstractions.NDIteration.DynamicCheck, CartesianIndex{3}, CartesianIndices{3, Tuple{Base.OneTo{Int64}, Base.OneTo{Int64}, Base.OneTo{Int64}}}, KernelAbstractions.NDIteration.NDRange{3, KernelAbstractions.NDIteration.DynamicSize, KernelAbstractions.NDIteration.DynamicSize, CartesianIndices{3, Tuple{Base.OneTo{Int64}, Base.OneTo{Int64}, Base.OneTo{Int64}}}, CartesianIndices{3, Tuple{Base.OneTo{Int64}, Base.OneTo{Int64}, Base.OneTo{Int64}}}}}, out::Array{ComplexF32, 3}, arr::Array{ComplexF32, 3}, sinθ::Float32, cosθ::Float32, midpoint::Tuple{Float32, Float32, Float32}, imax::Int64, jmax::Int64)
       @ DiffImageRotation ./none:0
     [5] __thread_run(tid::Int64, len::Int64, rem::Int64, obj::KernelAbstractions.Kernel{KernelAbstractions.CPU, KernelAbstractions.NDIteration.DynamicSize, KernelAbstractions.NDIteration.DynamicSize, typeof(DiffImageRotation.cpu_imrotate_kernel_adj!)}, ndrange::Tuple{Int64, Int64, Int64}, iterspace::KernelAbstractions.NDIteration.NDRange{3, KernelAbstractions.NDIteration.DynamicSize, KernelAbstractions.NDIteration.DynamicSize, CartesianIndices{3, Tuple{Base.OneTo{Int64}, Base.OneTo{Int64}, Base.OneTo{Int64}}}, CartesianIndices{3, Tuple{Base.OneTo{Int64}, Base.OneTo{Int64}, Base.OneTo{Int64}}}}, args::Tuple{Array{ComplexF32, 3}, Array{ComplexF32, 3}, Float32, Float32, Tuple{Float32, Float32, Float32}, Int64, Int64}, dynamic::KernelAbstractions.NDIteration.DynamicCheck)
       @ KernelAbstractions ~/.julia/packages/KernelAbstractions/mS4kn/src/cpu.jl:115
     [6] (::KernelAbstractions.var"#18#21"{KernelAbstractions.Kernel{KernelAbstractions.CPU, KernelAbstractions.NDIteration.DynamicSize, KernelAbstractions.NDIteration.DynamicSize, typeof(DiffImageRotation.cpu_imrotate_kernel_adj!)}, Tuple{Int64, Int64, Int64}, KernelAbstractions.NDIteration.NDRange{3, KernelAbstractions.NDIteration.DynamicSize, KernelAbstractions.NDIteration.DynamicSize, CartesianIndices{3, Tuple{Base.OneTo{Int64}, Base.OneTo{Int64}, Base.OneTo{Int64}}}, CartesianIndices{3, Tuple{Base.OneTo{Int64}, Base.OneTo{Int64}, Base.OneTo{Int64}}}}, Tuple{Array{ComplexF32, 3}, Array{ComplexF32, 3}, Float32, Float32, Tuple{Float32, Float32, Float32}, Int64, Int64}, KernelAbstractions.NDIteration.DynamicCheck, Int64})()
       @ KernelAbstractions ./threadingconstructs.jl:416

...and 23 more exceptions.

Stacktrace:
  [1] sync_end(c::Channel{Any})
    @ Base ./task.jl:445
  [2] macro expansion
    @ ./task.jl:477 [inlined]
  [3] __run(obj::KernelAbstractions.Kernel{KernelAbstractions.CPU, KernelAbstractions.NDIteration.DynamicSize, KernelAbstractions.NDIteration.DynamicSize, typeof(DiffImageRotation.cpu_imrotate_kernel_adj!)}, ndrange::Tuple{Int64, Int64, Int64}, iterspace::KernelAbstractions.NDIteration.NDRange{3, KernelAbstractions.NDIteration.DynamicSize, KernelAbstractions.NDIteration.DynamicSize, CartesianIndices{3, Tuple{Base.OneTo{Int64}, Base.OneTo{Int64}, Base.OneTo{Int64}}}, CartesianIndices{3, Tuple{Base.OneTo{Int64}, Base.OneTo{Int64}, Base.OneTo{Int64}}}}, args::Tuple{Array{ComplexF32, 3}, Array{ComplexF32, 3}, Float32, Float32, Tuple{Float32, Float32, Float32}, Int64, Int64}, dynamic::KernelAbstractions.NDIteration.DynamicCheck, static_threads::Bool)
    @ KernelAbstractions ~/.julia/packages/KernelAbstractions/mS4kn/src/cpu.jl:89
  [4] (::KernelAbstractions.Kernel{KernelAbstractions.CPU, KernelAbstractions.NDIteration.DynamicSize, KernelAbstractions.NDIteration.DynamicSize, typeof(DiffImageRotation.cpu_imrotate_kernel_adj!)})(::Array{ComplexF32, 3}, ::Vararg{Any}; ndrange::Tuple{Int64, Int64, Int64}, workgroupsize::Nothing)
    @ KernelAbstractions ~/.julia/packages/KernelAbstractions/mS4kn/src/cpu.jl:44
  [5] Kernel
    @ ~/.julia/packages/KernelAbstractions/mS4kn/src/cpu.jl:37 [inlined]
  [6] imrotate(arr::Array{ComplexF32, 3}, θ::Float64; method::Symbol, midpoint::Tuple{Int64, Int64, Int64}, adjoint::Bool)
    @ DiffImageRotation ~/.julia/dev/DiffImageRotation.jl/src/DiffImageRotation.jl:156
  [7] imrotate
    @ ~/.julia/dev/DiffImageRotation.jl/src/DiffImageRotation.jl:120 [inlined]
  [8] pb_rotate
    @ ~/.julia/dev/DiffImageRotation.jl/src/DiffImageRotation.jl:245 [inlined]
  [9] ZBack
    @ ~/.julia/packages/Zygote/YYT6v/src/compiler/chainrules.jl:211 [inlined]
 [10] Pullback
    @ ./REPL[3]:1 [inlined]
 [11] (::Zygote.var"#75#76"{Zygote.Pullback{Tuple{var"#7#8", Array{ComplexF32, 3}}, Tuple{Zygote.Pullback{Tuple{typeof(Base.Broadcast.materialize), Array{Float32, 3}}, Tuple{}}, Zygote.ZBack{DiffImageRotation.var"#pb_rotate#4"{Symbol, Tuple{Int64, Int64, Int64}, Float64}}, Zygote.ZBack{ChainRules.var"#deg2rad_pullback#1178"{Float64, ChainRulesCore.ProjectTo{Float64, NamedTuple{(), Tuple{}}}}}, Zygote.var"#2995#back#766"{Zygote.var"#760#764"{Array{Float32, 3}}}, Zygote.Pullback{Tuple{typeof(Base.Broadcast.broadcasted), typeof(abs), Array{ComplexF32, 3}}, Tuple{Zygote.var"#2173#back#293"{Zygote.var"#291#292"{Tuple{Tuple{Nothing, Nothing, Nothing}, Tuple{}}, Zygote.var"#4123#back#1360"{Zygote.var"#bc_fwd_back#1412"{1, Array{ForwardDiff.Dual{Nothing, Float32, 2}, 3}, Tuple{Array{ComplexF32, 3}}, Val{1}}}}}, Zygote.var"#2017#back#204"{typeof(identity)}, Zygote.var"#2849#back#672"{Zygote.var"#map_back#666"{typeof(Base.Broadcast.broadcastable), 1, Tuple{Tuple{}}, Tuple{Val{0}}, Tuple{}}}, Zygote.var"#2173#back#293"{Zygote.var"#291#292"{Tuple{Tuple{Nothing}, Tuple{}}, Zygote.var"#combine_styles_pullback#1166"{Tuple{Nothing, Nothing}}}}, Zygote.var"#2017#back#204"{typeof(identity)}, Zygote.Pullback{Tuple{typeof(Base.Broadcast.broadcastable), Array{ComplexF32, 3}}, Tuple{}}}}}}})(Δ::Float32)
    @ Zygote ~/.julia/packages/Zygote/YYT6v/src/compiler/interface.jl:45
 [12] gradient(f::Function, args::Array{ComplexF32, 3})
    @ Zygote ~/.julia/packages/Zygote/YYT6v/src/compiler/interface.jl:97
 [13] top-level scope
    @ REPL[3]:1

julia> Zygote.gradient(x -> sum(abs.(DiffImageRotation.imrotate(x, deg2rad(0.1)))), randn((32,32,1)))
([-0.02717124463840594 -0.973845889821095  -0.02308674449071725 0.02547169121116148; -0.026202854126445095 -0.9489623405259553  -0.9000532376557765 0.9738443667390227;  ; -0.9755912235035655 0.9000474536701528  -0.9510910514449772 -0.024455997361903854; -0.027221429335372086 0.024836328434312386  -0.9244577532533018 -0.025518829739342653;;;],)
@roflmaostc
Copy link
Owner Author

Raised here: JuliaConcurrent/Atomix.jl#37

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant