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

未关闭
#3,423 4 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
35/100
Issue 类型
重构
描述清晰度
需要澄清
活跃度
活跃
技术栈
cpp
领域
backend

调研方向

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.

由索引模型根据 Issue 内容生成。

描述

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.

主要语言
C++
星标
845
派生
225
平均合并
4 天 21 小时
30 天内合并 PR
13

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

stan-dev/math 的其他 Issue

查看 stan-dev/math 的全部 Issue

相似的 Issue

更多 C++ Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。