stan-dev / stanc3

The Stan transpiler (from Stan to C++ and beyond).
BSD 3-Clause "New" or "Revised" License
140 stars 44 forks source link

Disable inlining for transformed data #1218

Closed WardBrian closed 2 years ago

WardBrian commented 2 years ago

This is related to #1097. The 0-size objects created by the function inliner fail in transformed data at runtime. The error looks like:

 stan/lib/stan_math/lib/eigen_3.3.9/Eigen/src/Core/DenseBase.h:256: void Eigen::DenseBase<Derived>::resize(Eigen::Index, Eigen::Index) [with Derived = Eigen::Map<Eigen::Matrix<double, -1, -1> >; Eigen::Index = long int]: Assertion `rows == this->rows() && cols == this->cols() && "DenseBase::resize() does not actually allow to resize."' failed.
Aborted (core dumped)

For now this PR simply disables the function inliner in the prepare_data section. @SteveBronder might have a more clever fix, but this is low priority since optimizing transformed data is less useful than most of the rest of the model which gets called repeatedly.

I added a test test/integration/good/compiler-optimizations/inline-tdata.stan, but since the failure is at runtime we should really put this in something used by performance-tests-cmdstan (@rok-cesnovar). I've confirmed locally that the model fails against master but works after this PR.

Submission Checklist

Release notes

Function in-lining fails at runtime in transformed data and has been disabled in that block for now.

Copyright and Licensing

By submitting this pull request, the copyright holder is agreeing to license the submitted work under the BSD 3-clause license (https://opensource.org/licenses/BSD-3-Clause)