Skip to content

No method for prepare_gradient when the first argument is Constant or Cache #910

@albertomercurio

Description

@albertomercurio

prepare_gradient doesn't work when the first argument of f is either Constant or Cache.

function my_f(a, x)
  return a * sum(abs2, x)
end

function my_f2(x, a)
  return a * sum(abs2, x)
end

a = 0.1
x = rand(100)

backend = AutoMooncake(; config=nothing)

prep = prepare_gradient(my_f, backend, Constant(a), x)  # doesn't work

prep2 = prepare_gradient(my_f2, backend, x, Constant(a)) # works

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions