• I am trying to port an application from uBlas to ViennaCL.
    I just replaced uBlas vectors and matrices with vienna::vector and vienna::matrix.

    I get an error during the initialization of a class that contains a matrix:

    struct Mlp {
    viennacl::matrix<double, viennacl::row_major>    w1, w2;
    viennacl::vector<double> b1, b2;


    Just when initializing the structure, viennacl::linalg::am throws an exception

    throw "not implemented";

    as it appears it gets called within matrix::operator=() with parameter other having the value:

    $21 = (const viennacl::matrix_base<double, viennacl::row_major, unsigned long, long>::self_type &) @0x7fffffffd828: {size1_ = 0, size2_ = 0, start1_ = 0, start2_ = 0, stride1_ = 1, stride2_ = 1, internal_size1_ = 0, internal_size2_ = 0, elements_ = {active_handle_ = viennacl::MEMORY_NOT_INITIALIZED, ram_handle_ = {pa = 0x0, pt = 0x0}, size_in_bytes_ = 0}}

    This is the gdb stack trace:

    #0  viennacl::linalg::am<double, viennacl::row_major, double> (mat1=…, mat2=…, alpha=@0x7fffffffd718: 1, len_alpha=1, reciprocal_alpha=false, flip_sign_alpha=false) at ../viennacl/linalg/matrix_operations.hpp:57
    #1  0x000000000044714a in viennacl::matrix_base<double, viennacl::row_major, unsigned long, long>::operator= (this=0x728b40, other=…) at ../viennacl/matrix.hpp:235
    #2  0x00000000004438bf in viennacl::matrix<double, viennacl::row_major, 1u>::operator= (this=0x728b40) at ../viennacl/matrix.hpp:728
    #3  0x0000000000443904 in Parser::MlpModel::operator= (this=0x728ac8) at Mlp.cpp:146

    Is there a way to get te memory initialized?

    I am using release 1.4.2 with gcc 4.6.3 on ubuntu 12.04.

    Thank you

    Beppe Attardi

  • I forgot to mention a way to replicate the problem; just use:

    Mlp m;
    m = Mlp();

  • Karl Rupp
    Karl Rupp


    thanks for reporting!. Looks like the copy-constructor has a flaw. I see two possible remedies:

    a) Initialize the matrices with nonzero size. For example

      struct Mlp {
        Mlp() : w1(1,1), w2(1,1), b1(1), b2(1) {}

    Resize w1, w2, b1, b2 later to the actual size you need.

    b) Use version 1.4.1. We had to refactor the code base quite a lot from 1.4.1 to 1.4.2 in order to circumvent a bug in VS 2012, so I guess this how this issue slipped in.

    In any case, we will fix this in the next release. Thanks again for letting us know.

    Best regards,

  • Thanks, that worked.