| 32 | } |
| 33 | |
| 34 | TEST(IndexUtilTest, VectorIndexing) { |
| 35 | // Vectors are trivially laid out and the linear index should always be the |
| 36 | // same as the "multidimensional" index. |
| 37 | Shape vector_shape = ShapeUtil::MakeShape(F32, {100}); |
| 38 | EXPECT_EQ(42, |
| 39 | IndexUtil::MultidimensionalIndexToLinearIndex(vector_shape, {42})); |
| 40 | std::vector<int64> multi_index = |
| 41 | IndexUtil::LinearIndexToMultidimensionalIndex(vector_shape, 42); |
| 42 | EXPECT_EQ(1, multi_index.size()); |
| 43 | EXPECT_EQ(42, multi_index[0]); |
| 44 | } |
| 45 | |
| 46 | TEST(IndexUtilTest, MatrixIndexingRowMajor) { |
| 47 | // Set layout to [0, 1]. That is, row major. |
nothing calls this directly
no test coverage detected