stan-dev / stan-dev/stanc3

[Q] A few questions on additional variable metadata and C++ codegen

Open
#812 21 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

question
Dominant language
OCaml
Stars
160
Forks
59
Avg merge
21h 45m
Merged PRs (30d)
26

Description

I have a few questions on how to improve the implementations for the upcoming varmat and OpenCL PRs and make them more maintainable. This would also cleanup how we do the transform MIR with OpenCL.

  • how to store metadata for the variable to change the C++ codegen?

Example:

For matrix[N, N] a; in the parameters/TP/model block the default codegen is

Eigen::Matrix<local_scalar_t__, -1, -1> a;

but with "varmat" we may want to generate that as

conditional_var_value_t<local_scalar_t__, Eigen::MatrixXd> a;

if applicable (conditional_var_value becomes var_value<Eigen::MatrixXd> if local_scalar_t__ = var.
Additionally if we want this parameter to reside on the GPU, that would be

conditional_var_value_t<local_scalar_t__, matrix_cl<double>> a;

We need info on what the underlying C++ type will be in the codegen as well as in the transform MIR passes where we try to figure out if varmat/opencl is applicable for a variable. Current OpenCL implementation and also my development branches rely un suffixes (opencl_ and varmat__) to store this info during transform MIR phase and to generate the different C++. But that is not ideal and also not maintainable I guess.

  • how to best represent if a given Stan Math function signature is supported by varmat and OpenCL

We need lists of supported functions for both varmat and OpenCL. One idea would be to just have separate lists but I was hoping we could add this to the Stan Math signatures somehow.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue names no files, tests, or entry points. Start by locating the transform MIR and C++ codegen components, then identify where variable metadata and Stan Math function signatures are represented; done requires an agreed maintainable approach for varmat and OpenCL support.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, ocaml
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.