I am trying to use the GFOR construct, but I can't even make it work for basic stuff.
I suspect that the GFOR loop does not work with linear indexes, am I correct?
Here are some code samples that don't work
af::array x(100, 200);
af::array y(100, 200);
af::array xx(100, 200);
gfor(af::seq i, (100 * 200)) {
xx(i) = x(i) + y(i);
}
This one is supposed to do a simple addition element-wise (I know I can just do xx = x+y, I just want to show that gfor is not working as expected). The error is Invalid input size:203 in function seqToDims.
Another one is a more simple program, like this
af::array x(100, 200);
af::array y(100, 200);
gfor(af::seq i, (100 * 200)) {
y(i) = x(i) + 1;
}
Same error.
I have seen the documentation and what I think is that gfor does not work with linear indexes and I need to somehow work "line-by-line" or "column-by-column", because the examples in the docs always show something like A(span,i) and not A(i).
Apart from that, what I really want to do is something simple: I have: an array image(rows,cols), an array x_(8, rows*cols), an array ax(8,1); and a scalar which is found by sum(x_(span,i)*ax) (it's actually the dot product, but the dot() function is not supported in gfor), this scalar is computed by using the columns of x_ (size of 8) and the ax which is of size 8 too.
I want
e(i) = image(i) - sum<float>(ax * x_(span,i));
I can't seem to make it work because not even the simple gfor loops above work, which is unexpected, what am I doing wrong?
Thanks!