Re: [eigen] A not so simple product

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]


[17:42] <bschindler|deskt> test:
/home/bschindl/env/include/eigen2/Eigen/src/Core/DiagonalProduct.h:81:
Eigen::Product<LhsNested, RhsNested, 2>::Product(const Lhs&, const
Rhs&) [with Lhs =
Eigen::DiagonalMatrix<Eigen::CwiseUnaryOp<Eigen::ei_scalar_inverse_op<float>,
Eigen::Map<Eigen::Matrix<float, 10000, 1, 0, 10000, 1>, 1> > >, Rhs =
Eigen::Map<Eigen::Matrix<float, 10000, 10000, 0, 10000, 10000>, 1>,
LhsNested = Eigen::Matrix<float, 10000, 10000, 0, 10000, 10000>, Rh

[SNIP]

[17:44] <bjacob> oooooooooh, I see
[17:44] <bjacob> hehe, you found a real, bad bug in Eigen. Thank you !!
[17:44] <bschindler|deskt> well, glad to help :)
[17:44] <bjacob> See, in this product expression we have:
[17:44] <bjacob> Lhs =
Eigen::DiagonalMatrix<Eigen::CwiseUnaryOp<Eigen::ei_scalar_inverse_op<float>
[17:45] * bschindler|deskt is interested in this
[17:45] <bjacob> Lhs =
Eigen::DiagonalMatrix<Eigen::CwiseUnaryOp<Eigen::ei_scalar_inverse_op<float>
[17:45] <bjacob> oops
[17:45] <bjacob> LhsNested = Eigen::Matrix<float, 10000, 10000, 0, 10000, 10000>
[17:45] <bjacob> what does this say?
[17:45] <bjacob> that the left hand side of the product (Lhs), which
was the huge diagonal matrix, gets evaluated !
[17:46] <bjacob> so Eigen tries to allocate a 670000x670000 matrix,
which fails. Eigen doesn't catch the mem alloc failure, so the
segfault occurs on the subsequent write.
[17:46] <bschindler|deskt> uh... I thought eigen wouldn't produce that
temporary object?
[17:46] <bjacob> why did Eigen want to evaluate the Lhs here (which
was the wrong decision) ?
[17:46] <bjacob> exactly good question
[17:46] <bjacob> the answer is that:
[17:47] <bjacob> in a NORMAL matrix product, as soon as the Lhs or Rhs
is an expression involving a computation, it is an optimization to
evaluate it into a temporary, because each coefficient is used N times
[17:47] <bjacob> here things are different:
[17:47] <bjacob> this is an OPTIMIZED DIAGONAL matrix product
[17:48] <bjacob> so I need to change Eigen's logic to take this into
account, as in this case,
[17:48] <bjacob> 1) there's no point in evaluating Lhs into a temporary
[17:48] <bjacob> 2) Lhs can be so large anyway that it can't be evaluated
[17:48] <bjacob> Thank you!
[17:48] <bschindler|deskt> and what does the fix look like?
[17:49] <bjacob> For now you have to stay with your old approach,
until I fix Eigen
[17:49] <bjacob> the fix will look like changes in src/Core/Product.h
and perhaps src/Core/util/XprHelper.h (the ei_nested struct perhaps)

---


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/