Optimize code by merging expressions

オープン
#860 コメント 1 件 リアクション 2 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
35/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
cpp, ocaml

調査の方向性

matrix、vector、row_vector の例で示されている Stan-to-C++ の式生成パスから始め、単一使用変数がどのように表現されるかを追跡します。適格な代入が後続の式に統合されてメモリアクセスが削減され、複数の場所で使用される変数は引き続き利用可能な状態に保たれれば完了です。

索引モデルが issue の本文から書いたものです。

説明

optimization

Now that we are using Eigen expressions in Stan Math it makes sense for compiler to merge multiple expressions into singe one where possible to avoid unnecessary memory accesses. This is possible where we have a variable of matrix, vector or row_vector type (or if using OpenCL any type that is replaced with a matrix_cl) that is used in exactly one place in further code. Such a variable can be removed and its use case replaced with the expression that was assigned to the variable.

For example from stan code:

matrix a, b;
matrix c = a + b;
matrix d = c * 3;

We want to generate (assuming c is not used anywhere else):

Eigen::MatrixXd a, b;
Eigen::MatrixXd d = (a + b) * 3;

instead of:

Eigen::MatrixXd a, b;
Eigen::MatrixXd c = a + b;
Eigen::MatrixXd d = c * 3;
主要言語
OCaml
スター
162
フォーク
60
平均マージ
2日 22時間
マージ済み PR(30日)
14

環境構築

  • Dockerfile・Docker Compose ファイルなし
  • プルリクエストのテンプレートあり
  • コントリビューションガイドなし

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

stan-dev/stanc3 のほかの issue

stan-dev/stanc3 の issue をすべて見る

似ている issue

Compilers の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。