Closed andrjohns closed 1 year ago
But it does add them if they are actually used in the model, right? I believe the listed functions are actually those that are used in the model.
Doesn't look like it unfortunately:
functions {
int rtn_int(int x) { return x; }
real rtn_real(real x) { return x; }
}
data {
int<lower=0> N;
array[N] int<lower=0,upper=1> y; // or int<lower=0,upper=1> y[N];
}
parameters {
real<lower=0,upper=1> theta;
}
model {
real x = rtn_real(theta);
theta ~ beta(1,1); // uniform prior on interval 0,1
y ~ bernoulli(theta);
}
Returns:
andrew@dhcp-100-4 cmdstan-2.31.0 % bin/stanc examples/bernoulli/bernoulli.stan --info
{
"inputs": {
"N": { "type": "int", "dimensions": 0 },
"y": { "type": "int", "dimensions": 1 }
},
"parameters": { "theta": { "type": "real", "dimensions": 0 } },
"transformed parameters": {},
"generated quantities": {},
"functions": [],
"distributions": [ "bernoulli_lupmf", "beta_lupdf" ],
"included_files": []
}
Unless there's a different criteria for including them?
It only lists Stan math library functions. I’m not sure what the original reasoning was, but this sort of makes sense to me, since those are the only function names which definitely have a meaning outside this one program
It only lists Stan math library functions. I’m not sure what the original reasoning was, but this sort of makes sense to me, since those are the only function names which definitely have a meaning outside this one program
One feature that was envisioned is checking whether the model is using map_rect/reduce_sum but not setting STAN_THREADS.
Ah got it, thanks for clarifying both! Closing as operating as intended
@andrjohns if you have a use case, we could add another list for UDFs
That would be great, if possible! It's for the process of exposing stan functions in cmdstanr
/rstan
. The current approach is based on grep
-ing for the // [[stan::function]]
attribute, but it would be more robust if we knew exactly which functions were present and should be found
Mind making a feature request for that? We can also print much more about UDFs than just the names (like their signatures) if that would be helpful, but it's worth discussing the what and how in depth
Given the model:
The
--info
flag returns nothing for thefunctions
block: