Skip to content

gradient returns nothing for sum(abs2, x) with a complex CuArray #1121

@LexaLutyi

Description

@LexaLutyi

gradient returns nothing for CuArrays{ComplexF32}, but works fine with Arrays{ComplexF32}:

julia> a = CUDA.rand(ComplexF32, 2)
2-element CuArray{ComplexF32, 1, CUDA.Mem.DeviceBuffer}:
  0.040781975f0 + 0.31357694f0im
 0.0050712824f0 + 0.464033f0im

julia> gradient(t -> sum(abs2, t), a)
(nothing,)

julia> a = rand(ComplexF32, 2)
2-element Vector{ComplexF32}:
 0.6999197f0 + 0.343145f0im
 0.4877541f0 + 0.47177994f0im

julia> gradient(t -> sum(abs2, t), a)
(ComplexF32[1.3998394f0 + 0.68629f0im, 0.9755082f0 + 0.9435599f0im],)

real and imag behave similarly to abs2

Metadata

Metadata

Assignees

No one assigned

    Labels

    CUDAAll things GPU

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions