Comments (7)
This appears to be an issue with assigning to the SoA matrix type.
The specific error is a segmentation fault in
void stan::model::internal::assign_impl<stan::math::var_value<Eigen::Matrix<double, -1, 1, 0, -1, 1>, void>&, stan::math::var_value<Eigen::VectorBlock<Eigen::Map<Eigen::Matrix<double, -1, 1, 0, -1, 1>, 0, Eigen::Stride<0, 0> >, -1>, void>, (void*)0>(stan::math::var_value<Eigen::Matrix<double, -1, 1, 0, -1, 1>, void>&, stan::math::var_value<Eigen::VectorBlock<Eigen::Map<Eigen::Matrix<double, -1, 1, 0, -1, 1>, 0, Eigen::Stride<0, 0> >, -1>, void>&&, char const*)
Whether this issue should be transferred to stan-dev/stan or stan-dev/stanc3 depends on whether or not we think these vectors should be marked as SoA
. If you change the code to x = y[:]
it works fine, so I suspect this is a bug in the C++, not in the compiler's behavior
@SteveBronder thoughts?
from math.
I think this is an issue with the assign functions in the Stan repo. I can take a look tmrw. My best guess is an off by one error
from math.
I tried writing a test which exposes this in the Stan repo and found something interesting. The issue seems to be that x
is not initialized before it is assigned to. E.g, this segfaults:
var_value<Vec> x;
auto y = conditionally_generate_linear_var_vector<Vec>(3, 10);
assign(x, rvalue(y, "y", index_min_max(1,3)), "");
but this doesn't:
var_value<Vec> x = conditionally_generate_linear_var_vector<Vec>(3,1);
auto y = conditionally_generate_linear_var_vector<Vec>(3, 10);
assign(x, rvalue(y, "y", index_min_max(1,3)), "");
This seems to be to be different than the behavior for non-SOA types which allow you to assign to them if they're uninitialized, I believe. We could try to address this in the compiler (by never omitting the initialization for SoA types) or we could improve the logic in assigning these types.
@SteveBronder thoughts?
from math.
This is the specific line that segfaults in math
when the LHS is an uninitialized var matrix:
math/stan/math/rev/core/var.hpp
Line 1045 in 98117fa
This is only triggered I believe if the RHS is a expression? Otherwise, this overload of operator=
is used and no segfault occurs.
from math.
I can take a look at this today
from math.
I thought harder about this and think that this may be a bug in the compiler optimizations.
We do assume in the var_value
that the value is not a nullptr, otherwise we have to have constant checks and throws everywhere. I think this is an issue with the optimization pass that removes the NA defaults if we immediately do an assignment. I'll look into this more tmrw
from math.
I have an old compiler branch which removed that pass from SoA types, I wasn’t sure if it was the “right” fix or not, since the behavior for these overloads of operator= is very different from the normal AoS ones
from math.
Related Issues (20)
- vectorize binary log_sum_exp HOT 1
- Vectorized logical functions HOT 3
- Floating point precision loss under arm64 (FP_CONTRACT) HOT 2
- Expose integrate_1d variadic signatures HOT 1
- Aliasing issue in OpenCL `assignment_impl` HOT 5
- Add functions to write hessian vector products into an array HOT 1
- Add variadic version of `scalar_seq_view` HOT 3
- Add lower and upper bounds to ordered vector HOT 2
- Inverse Wishart Cholesky rng bug HOT 8
- Update Normal quantile function with new approximations HOT 3
- Adding 7-Parameter Drift Diffusion Model (DDM) CDF and CCDF with partial derivatives to Stan Math HOT 1
- Allow cmake users to use FetchContent_Declare HOT 3
- Allow OpenCL simplex to use softmax? HOT 2
- Improve the numerical stability of binomial_logit_lpmf / bernoulli_logit_lpmf HOT 1
- matrix power function HOT 5
- Odd interaction between `ode_adams` and threading HOT 4
- Slicing and blocking functions fail on SoA matrices
- `newton_solver` halts sampling HOT 14
- Support faster Cholesky Decomposition of Toeplitz matrices HOT 2
- Compilation failure with Clang 17 and `check_symmetric`
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from math.