arrayfire / arrayfire

ArrayFire: a general purpose GPU library.

Home Page:https://arrayfire.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[BUG] indexing the second dim with af::seq ignores step

FloopCZ opened this issue · comments

Indexing the first dimension with af::array and the second dimension with af::seq ignores the step parameter of the af::seq. Casting the af::seq to af::array is a workaround for this issue.

Minimal example:

#include <arrayfire.h>

int main() {
    af::info();

    af::array A = af::seq(10);
    A = A.T();
    af::print("A", A);

    af::array selector_x = af::constant(0, 1);
    af::seq selector_y(0, 9, 2);  // select every second element
    // af::array selector_y = af::seq(0, 9, 2);  // this is a workaround

    af::print("A select", A(selector_x, selector_y));
}

Output:

ArrayFire v3.8.3 (CUDA, 64-bit Linux, build default)
Platform: CUDA Runtime 12.0, Driver: 545.29.02
[0] NVIDIA RTX A500 Laptop GPU, 3905 MB, CUDA Compute 8.6
A
[1 10 1 1]
   Offset: 0
   Strides: [1 1 10 10]
    0.0000     1.0000     2.0000     3.0000     4.0000     5.0000     6.0000     7.0000     8.0000     9.0000
A select
[1 5 1 1]
   Offset: 0
   Strides: [1 1 5 5]
    0.0000     1.0000     2.0000     3.0000     4.0000

Expected behavior (also the workaround behavior) would be that A select is equal to:

    0.0000     2.0000     4.0000     6.0000     8.0000

Arrayfire version:

ArrayFire v3.8.3 (CUDA, 64-bit Linux, build default)