Skip to content

Dense instead of sparse matrix returned during differentiation #1537

@vboussange

Description

@vboussange

Hi there,
I found an inconsistent behaviour when differentiating a function which takes in an AbstractCuSparseArray versus the same function differentiating an AbstractSparseArray

using CUDA
using Zygote
using SparseArrays

logpos(a) = a > 0 ? log(a) : zero(a)
l(A) = sum(logpos.(A))

A = sprandn(Float32, 10,10,0.4)

dA = gradient(l, A)[1] # returns a sparse array, as expected

Acu = sparse(CuArray(A))
dAcu = gradient(l, Acu)[1] # returns a dense CuArray

Maybe someone here has an idea of where could this come from?

Metadata

Metadata

Assignees

No one assigned

    Labels

    CUDAAll things GPUChainRulesadjoint -> rrule, and further integration

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions