Skip to content

All make_partials_propagator to return its input args as a tuple #3423

Description

@SteveBronder

When a user calls something like normal_lpdf(std::move(y), std::move(mu), std::move(sigma)) nothing really happens with the moved memory. But we could actually move those objects into the partials_propagator so that the partials_propagator does not have to make a hard copy of the inputs. A nice piece would be if make_partials_propagator returned a tuple of the partials propagator and references to the moved memory so that the functions would reuse that local memory.

auto [partials_prop, y_ref, mu_ref, sigma_ref] = make_partials_propagator(
  std::move(y), std::move(mu), std::move(sigma));

For autodiff types the inputs would be moved into the partials propagator and then references to the object would be the return. For non-autodiff types the object would just be passed back

This would replace a lot of the ref_type_t boilerplate inside of the distributions since the values would then sit inside of the partials propagator.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions