|
| 1 | +#include "kernel/attributes/slice_info.h" |
| 2 | +#include <gtest/gtest.h> |
| 3 | + |
| 4 | +using namespace refactor; |
| 5 | +using namespace kernel; |
| 6 | + |
| 7 | +TEST(kernel, SliceInfo) { |
| 8 | + auto input = Tensor::share(DataType::F32, Shape{7, 6, 5, 1, 2, 3}); |
| 9 | + Dimensions dims{ |
| 10 | + {5, -2, 3},// 7 -> {5, 3, 1} -> {108, 900, -360} |
| 11 | + {2, 3, 2}, // 6 -> {2, 5} -> { 36, 60, 90} |
| 12 | + {1, 1, 3}, // 5 -> {1, 2, 3} -> { 18, 6, 30} |
| 13 | + {0, 1, 1}, // 1 -> {0} |
| 14 | + {0, 1, 2}, // 2 -> {0, 1} |
| 15 | + {0, 1, 3}, // 3 -> {0, 1, 2} |
| 16 | + }; |
| 17 | + SliceInfo info(dims, *input); |
| 18 | + EXPECT_EQ(info.blockSize, 72); |
| 19 | + EXPECT_EQ(info.dims, |
| 20 | + // clang-format off |
| 21 | + (decltype(info.dims){ |
| 22 | + {108 / 18, 900 * 4, -360 * 4}, |
| 23 | + { 36 / 18, 60 * 4, 90 * 4}, |
| 24 | + { 18 / 18, 6 * 4, 30 * 4}, |
| 25 | + }) |
| 26 | + // clang-format on |
| 27 | + ); |
| 28 | +} |
0 commit comments