| 24 | using std::vector; |
| 25 | |
| 26 | TEST(Internal, CreateStrided) { |
| 27 | float ha[] = {1, 101, 102, 103, 104, 105, 201, 202, 203, 204, |
| 28 | 205, 301, 302, 303, 304, 305, 401, 402, 403, 404, |
| 29 | 405, |
| 30 | |
| 31 | 1010, 1020, 1030, 1040, 1050, 2010, 2020, 2030, 2040, 2050, |
| 32 | 3010, 3020, 3030, 3040, 3050, 4010, 4020, 4030, 4040, 4050}; |
| 33 | |
| 34 | dim_t offset = 1; |
| 35 | unsigned ndims = 3; |
| 36 | dim_t dims[] = {3, 3, 2}; |
| 37 | dim_t strides[] = {1, 5, 20}; |
| 38 | array a = createStridedArray((void *)ha, offset, dim4(ndims, dims), |
| 39 | dim4(ndims, strides), f32, afHost); |
| 40 | |
| 41 | dim4 astrides = getStrides(a); |
| 42 | dim4 adims = a.dims(); |
| 43 | |
| 44 | ASSERT_EQ(offset, getOffset(a)); |
| 45 | for (int i = 0; i < (int)ndims; i++) { |
| 46 | ASSERT_EQ(strides[i], astrides[i]); |
| 47 | ASSERT_EQ(dims[i], adims[i]); |
| 48 | } |
| 49 | |
| 50 | vector<float> va(a.elements()); |
| 51 | a.host(&va[0]); |
| 52 | |
| 53 | int o = offset; |
| 54 | for (int k = 0; k < dims[2]; k++) { |
| 55 | for (int j = 0; j < dims[1]; j++) { |
| 56 | for (int i = 0; i < dims[0]; i++) { |
| 57 | ASSERT_EQ( |
| 58 | va[i + j * dims[0] + k * dims[0] * dims[1]], |
| 59 | ha[i * strides[0] + j * strides[1] + k * strides[2] + o]) |
| 60 | << "at (" << i << "," << j << "," << k << ")"; |
| 61 | } |
| 62 | } |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | TEST(Internal, CheckInfo) { |
| 67 | const int xdim = 10; |
nothing calls this directly
no test coverage detected