| 22 | } |
| 23 | |
| 24 | std::vector<float> roll_reference( |
| 25 | const float * src, std::array<int64_t, 4> ne, std::array<int, 4> shift) { |
| 26 | |
| 27 | const int64_t ne0 = ne[0], ne1 = ne[1], ne2 = ne[2], ne3 = ne[3]; |
| 28 | std::vector<float> dst(ne0 * ne1 * ne2 * ne3); |
| 29 | |
| 30 | for (int64_t i3 = 0; i3 < ne3; ++i3) { |
| 31 | for (int64_t i2 = 0; i2 < ne2; ++i2) { |
| 32 | for (int64_t i1 = 0; i1 < ne1; ++i1) { |
| 33 | for (int64_t i0 = 0; i0 < ne0; ++i0) { |
| 34 | const int64_t i03 = wrap(i3 - shift[3], ne3); |
| 35 | const int64_t i02 = wrap(i2 - shift[2], ne2); |
| 36 | const int64_t i01 = wrap(i1 - shift[1], ne1); |
| 37 | const int64_t i00 = wrap(i0 - shift[0], ne0); |
| 38 | |
| 39 | dst[i3 * (ne2*ne1*ne0) + i2 * (ne1*ne0) + i1 * ne0 + i0] = |
| 40 | src[i03 * (ne2*ne1*ne0) + i02 * (ne1*ne0) + i01 * ne0 + i00]; |
| 41 | } |
| 42 | } |
| 43 | } |
| 44 | } |
| 45 | return dst; |
| 46 | } |
| 47 | |
| 48 | std::vector<float> f32_range(int64_t n) { |
| 49 | std::vector<float> values(n); |