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.
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 thepartials_propagatorso that thepartials_propagatordoes not have to make a hard copy of the inputs. A nice piece would be ifmake_partials_propagatorreturned a tuple of the partials propagator and references to the moved memory so that the functions would reuse that local memory.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_tboilerplate inside of the distributions since the values would then sit inside of the partials propagator.