All `make_partials_propagator` to return its input args as a tuple

Ouverte
#3,423 4 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 1 jour

Personne n'a encore pris cette issue.

Évaluation

Difficulté
5/5
Temps estimé
Plus d'une semaine
Accessibilité débutants
35/100
Type d'issue
Refactorisation
Clarté
À clarifier
Activité
Active
Stack technique
cpp
Domaine
backend

Piste de recherche

Start at the make_partials_propagator entry point and inspect the distributions' ref_type_t boilerplate. Trace how autodiff and non-autodiff arguments are handled, then define the tuple-returning behavior so local references reuse the moved memory. Done means the affected distributions use this interface without unnecessary copies.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

code cleanup distributions performance

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.

This would be useful inside of the stanc compiler. We could have an optimization pass which looks at the last use of each vector/array in the log_prob function and applies std::move to the object at that point.

Langage dominant
C++
Étoiles
845
Forks
225
Merge moyen
4 j 21 h
PR mergées (30 j)
13

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de stan-dev/math

Toutes les issues de stan-dev/math

Issues similaires

Plus d'issues C++

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.