Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed Eigen assertion when testing with MKL enabled #419

Open
peddie opened this issue May 18, 2023 · 2 comments
Open

Failed Eigen assertion when testing with MKL enabled #419

peddie opened this issue May 18, 2023 · 2 comments

Comments

@peddie
Copy link
Contributor

peddie commented May 18, 2023

[ RUN      ] test_core_dataset/DatasetOperatorTester/0.test_multiply_dataset
albatross_unit_tests: albatross/third_party/eigen/Eigen/src/Core/Assign_MKL.h:132: static void Eigen::internal::Assignment<Eigen::Array<double, -1, 1, 0>, Eigen::CwiseUnaryOp<Eigen::internal::scalar_sqrt_op<double>, const Eigen::ArrayWrapper<const Eigen::Matrix<double, -1, 1, 0>>>, Eigen::internal::assign_op<double, double>, Eigen::internal::Dense2Dense>::run(DstXprType &, const Eigen::internal::Assignment<type-parameter-0-0, CwiseUnaryOp<Eigen::internal::scalar_sqrt_op<double>, type-parameter-0-1>, Eigen::internal::assign_op<double, double>, Eigen::internal::Dense2Dense, typename enable_if<vml_assign_traits<DstXprType, SrcXprNested>::EnableVml, void>::type>::SrcXprType &, const assign_op<double, double> &) [DstXprType = Eigen::Array<double, -1, 1, 0>, SrcXprType = Eigen::CwiseUnaryOp<Eigen::internal::scalar_sqrt_op<double>, const Eigen::ArrayWrapper<const Eigen::Matrix<double, -1, 1, 0>>>, Functor = Eigen::internal::assign_op<double, double>, Kind = Eigen::internal::Dense2Dense, EnableIf = void]: Assertion `dst.rows() == src.rows() && dst.cols() == src.cols()' failed.
Aborted

Looks like a mistaken assumption about sizes somewhere. This failure also occurs in:

  • test_multiply_with_matrix_joint
  • test_multiply_with_matrix_marginal
  • test_multiply_with_sparse_matrix_joint
  • test_multiply_with_sparse_matrix_marginal
  • test_multiply_with_vector
@peddie
Copy link
Contributor Author

peddie commented May 18, 2023

This is triggered by the matrix with 0 rows at https://github.com/swift-nav/albatross/blob/master/tests/test_core_dataset.cc#L193:

struct EmptyTransform {
  auto get_matrix(Eigen::Index n) {
    Eigen::SparseMatrix<double> matrix(0, n);
    return matrix;
  }
};

Not sure yet whether we are doing something wrong or Eigen is, but http://gitlab.com/libeigen/eigen/-/issues/1135 suggests that this should probably work.

peddie added a commit that referenced this issue May 18, 2023
As far as I can tell, this is mathematically and operationally
equivalent, but using Eigen's built-in functionality for producing a
diagonal matrix expression from a 1-d array solves issue
#419.
@peddie
Copy link
Contributor Author

peddie commented May 18, 2023

With the fix above, I don't get any assert failures, but I still see the warning Intel MKL ERROR: Parameter 6 was incorrect on entry to DGEMV . I'm not clear whether this is a problem for us in practice if the results for the test are still computed correctly. Here is the MKL description:

MKL_VERBOSE DGEMV(N,0,3,0x7fff24289c28,(nil),0,0x1c4f740,1,0x7fff24289c30,(nil),1) 881ns CNR:OFF Dyn:1 FastMM:1 TID:0  NThr:8

We know that we ask for a matrix with 0 rows in Eigen, but argument 6 of DGEMV is the leading dimension (which should be the number of columns). I can imagine something like: Eigen has computed the leading dimension to be 0 based on the fact that there are 0 rows and thus 0 elements, but DGEMV still expects to see 3 in there.

peddie added a commit that referenced this issue May 24, 2023
As far as I can tell, this is mathematically and operationally equivalent, but using Eigen's built-in functionality for producing a diagonal matrix expression from a 1-d array solves issue #419.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant