Skip to content

make value API more generic, allow arbitrary payloads #56

@tpapp

Description

@tpapp

Occasionally it is useful to return an extra "payload" along with values and gradients. Examples include

  1. generated quantities (eg in Stan),
  2. simulated interim data (eg for indirect inference)

Before fixing the API for a longer time, some thought should be given to supporting this.

Here is what I am thinking of:

  1. Define accessors get_logdensity, get_gradient, get_payload for values returned by logdensity and logdensity_and_gradient,

  2. make the latter two return some lightweight container, which has default methods for the above,

  3. with get_payload defaulting to nothing.

The accessors can be introduced at little cost, some dubious workarounds can make the rest non-breaking (dispatch on NTuple) but perhaps a deprecation cycle would be better.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions