@@ -160,6 +160,45 @@ TEST(UtilsTest, SquatDiagonalLayout) {
160160 }
161161}
162162
163+ TEST (UtilsTest, BicyclicLayout3x5) {
164+ MLIRContext context;
165+ int64_t numSlots = 15 ;
166+ RankedTensorType matrixType =
167+ RankedTensorType::get ({3 , 5 }, IndexType::get (&context));
168+ IntegerRelation bicyclicRelation =
169+ getBicyclicLayoutRelation (matrixType, numSlots);
170+
171+ std::vector<std::vector<int >> matrix = {
172+ {1 , 2 , 3 , 4 , 5 }, {6 , 7 , 8 , 9 , 10 }, {11 , 12 , 13 , 14 , 15 }};
173+ std::vector<std::vector<int >> packedMatrix =
174+ evaluateLayoutOnMatrix (bicyclicRelation, matrix);
175+
176+ std::vector<std::vector<int >> expected = {
177+ {1 , 7 , 13 , 4 , 10 , 11 , 2 , 8 , 14 , 5 , 6 , 12 , 3 , 9 , 15 }};
178+ EXPECT_EQ (packedMatrix, expected);
179+ }
180+
181+ TEST (UtilsTest, BicyclicLayout3x5Repeated) {
182+ MLIRContext context;
183+
184+ int64_t numSlots = 32 ;
185+ RankedTensorType matrixType =
186+ RankedTensorType::get ({3 , 5 }, IndexType::get (&context));
187+ IntegerRelation bicyclicRelation =
188+ getBicyclicLayoutRelation (matrixType, numSlots);
189+
190+ std::vector<std::vector<int >> matrix = {
191+ {1 , 2 , 3 , 4 , 5 }, {6 , 7 , 8 , 9 , 10 }, {11 , 12 , 13 , 14 , 15 }};
192+ std::vector<std::vector<int >> packedMatrix =
193+ evaluateLayoutOnMatrix (bicyclicRelation, matrix);
194+
195+ std::vector<std::vector<int >> expected = {
196+ {1 , 7 , 13 , 4 , 10 , 11 , 2 , 8 , 14 , 5 , 6 , 12 , 3 , 9 , 15 ,
197+ // Cyclically repeated to fill 32 slots
198+ 1 , 7 , 13 , 4 , 10 , 11 , 2 , 8 , 14 , 5 , 6 , 12 , 3 , 9 , 15 , 1 , 7 }};
199+ EXPECT_EQ (packedMatrix, expected);
200+ }
201+
163202TEST (UtilsTest, TestGetRangePoints) {
164203 MLIRContext context;
165204 auto rel = getIntegerRelationFromIslStr (
0 commit comments