I’ve been getting odd compilation errors with cmdstanr when using higher-order functions. I just downloaded a new version of cmdstan today.
First with integrate_ode_rk45
, I get the following message:
> mod <- cmdstan_model(paste0("model/", modelName))
Compiling Stan program...
Uncaught exception:
(Invalid_argument "length mismatch in map2_exn: 5 <> 4 ")
Raised at file "stdlib.ml", line 34, characters 20-45
Called from file "src/list.ml", line 130, characters 13-76
Called from file "src/list.ml" (inlined), line 378, characters 2-36
Called from file "src/middle/UnsizedType.ml", line 68, characters 13-165
Called from file "src/middle/UnsizedType.ml", line 86, characters 12-68
Called from file "list.ml", line 134, characters 35-42
Called from file "src/list0.ml" (inlined), line 32, characters 40-75
Called from file "src/list.ml" (inlined), line 373, characters 27-49
Called from file "src/list.ml" (inlined), line 379, characters 2-18
Called from file "src/middle/UnsizedType.ml", line 84, characters 7-212
Called from file "src/list.ml", line 204, characters 19-22
Called from file "src/list.ml" (inlined), line 209, characters 22-39
Called from file "src/middle/Stan_math_signatures.ml", line 249, characters 4-128
Called from file "src/frontend/Semantic_check.ml", line 322, characters 4-121
Called from file "src/frontend/Semantic_check.ml", line 334, characters 8-38
Called from file "src/frontend/Semantic_check.ml", line 695, characters 4-57
Called from file "src/frontend/Semantic_check.ml", line 931, characters 12-51
Called from file "src/frontend/Semantic_check.ml", line 1406, characters 9-80
Called from file "src/frontend/Semantic_check.ml", line 1434, characters 4-58
Called from file "src/frontend/Semantic_check.ml", line 1667, characters 18-51
Called from file "list.ml", line 117, characters 24-34
Called from file "src/list0.ml" (inlined), line 22, characters 40-81
Called from file "src/frontend/Semantic_check.ml", line 1666, characters 6-128
Called from file "src/frontend/Semantic_check.ml", line 1728, characters 13-63
Called from file "src/frontend/Frontend_utils.ml", line 24, characters 10-51
Called from file "src/stanc/stanc.ml", line 187, characters 18-53
Called from file "src/stanc/stanc.ml", line 244, characters 9-16
make: *** No rule to make target `/var/folders/ty/36ws994x4l33ksszcdwjtrv40000gp/T/RtmpEluPgF/model-47401e5c31e2.d', needed by `/var/folders/ty/36ws994x4l33ksszcdwjtrv40000gp/T/RtmpEluPgF/model-47401e5c31e2'. Stop.
Error in processx::run(command = make_cmd(), args = c(tmp_exe, include_paths, :
System command 'make' failed, exit status: 2, stderr (last 10 lines):
E> Called from file "src/frontend/Semantic_check.ml", line 1434, characters 4-58
E> Called from file "src/frontend/Semantic_check.ml", line 1667, characters 18-51
E> Called from file "list.ml", line 117, characters 24-34
E> Called from file "src/list0.ml" (inlined), line 22, characters 40-81
E> Called from file "src/frontend/Semantic_check.ml", line 1666, characters 6-128
E> Called from file "src/frontend/Semantic_check.ml", line 1728, characters 13-63
E> Called from file "src/frontend/Frontend_utils.ml", line 24, characters 10-51
E> Called from file "src/stanc/stanc.ml", line 187, characters 18-53
E> Called from file "src/stanc/stanc.ml", line 244, characters 9-16
E> make: *** No rule to make target `/var/folders/ty/36ws994x4l33ksszcdwjtrv40000gp/T/RtmpEluPgF/model-47401e5c31e2.d', needed by `/var/folders/ty/36ws994x4l33ksszcdwjtrv40000gp
[...]
Type .Last.error.trace to see where the error occured
Really not quite sure what causes this error. Also, I don’t think the unit tests would catch this.
Next, when I try using a prototype function, laplace_marginal_poisson_log()
, from the branch try_laplace-approximation2
(note the 2
) I get the following:
../model/disease_map_ela.hpp:422:19: error: no matching function for call to
'laplace_marginal_poisson_log'
density = laplace_marginal_poisson_log<false>(y, n_samples, ye,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../model/disease_map_ela.hpp:661:14: note: in instantiation of function template
specialization
'disease_map_ela_model_namespace::disease_map_ela_model::log_prob<false,
false, double>' requested here
return log_prob<propto__,jacobian__,T_>(vec_params_r, vec_params_i...
^
/Users/charlesm/Desktop/Code/laplace_approximation/writeup/StanCon2020/script/cmdstan/stan/src/stan/model/model_base_crtp.hpp:90:50: note:
in instantiation of function template specialization
'disease_map_ela_model_namespace::disease_map_ela_model::log_prob<false,
false, double>' requested here
return static_cast<const M*>(this)->template log_prob<false, false, double>(
^
../model/disease_map_ela.hpp:162:3: note: in instantiation of member function
'stan::model::model_base_crtp<disease_map_ela_model_namespace::disease_map_ela_model>::log_prob'
requested here
~disease_map_ela_model() final { }
^
/Users/charlesm/Desktop/Code/laplace_approximation/writeup/StanCon2020/script/cmdstan/stan/lib/stan_math/stan/math/laplace/laplace_marginal_poisson_log.hpp:39:6: note:
candidate template ignored: invalid explicitly-specified argument for
template parameter 'T0'
T1 laplace_marginal_poisson_log
^
/Users/charlesm/Desktop/Code/laplace_approximation/writeup/StanCon2020/script/cmdstan/stan/lib/stan_math/stan/math/laplace/laplace_marginal_poisson_log.hpp:58:6: note:
candidate template ignored: invalid explicitly-specified argument for
template parameter 'T0'
T1 laplace_marginal_poisson_log
A look at the created C++ file shows the call to laplace_marginal_poisson_log
is the following
density = laplace_marginal_poisson_log<false>(y, n_samples, ye,
K_functor__(), phi, x, delta, delta_int, theta_0,
pstream__);
Everything here is fine except the <false>
part. The C++ code I wrote is not designed to handle such a boolean. The code exposing the function to the parser is at line 1600 of stan_math_signature.ml. The unit tests I wrote pass, but obviously they wouldn’t catch such a mistranslation.