@@ -1118,6 +1118,40 @@ TEST_F(PolyhedralMapperTest, EmptyMappingFilter) {
11181118 mscop->codegen (specializedName);
11191119}
11201120
1121+ TEST_F (PolyhedralMapperTest, ModulusConstantRHS) {
1122+ string tc = R"TC(
1123+ def fun(float(N) a) -> (b) { b(i) = a(i % 3) where i in 0:N }
1124+ )TC" ;
1125+ // This triggers tc2halide conversion and should not throw.
1126+ auto scop = Prepare (tc);
1127+ auto ctx = scop->domain ().get_ctx ();
1128+ for (auto r : scop->reads .wrap ().get_set_list ()) {
1129+ auto read = r.unwrap ();
1130+ // skip irrelevant reads, if any
1131+ if (read.range ().get_tuple_name () != std::string (" a" )) {
1132+ continue ;
1133+ }
1134+ EXPECT_EQ (r.get_stride (0 ), 3 );
1135+ }
1136+ }
1137+
1138+ TEST_F (PolyhedralMapperTest, ModulusVariableRHS) {
1139+ string tc = R"TC(
1140+ def local_sparse_convolution(float(N, C, H, W) I, float(O, KC, KH, KW) W1) -> (O1) {
1141+ O1(n, o, h, w) +=! I(n, kc % c, h + kh, w + kw) * W1(o, kc, kh, kw) where c in 1:C
1142+ }
1143+ )TC" ;
1144+ // This triggers tc2halide conversion and should not throw.
1145+ auto scop = Prepare (tc);
1146+ for (auto r : scop->reads .range ().get_set_list ()) {
1147+ // skip irrelevant reads, if any
1148+ if (r.get_tuple_name () != std::string (" I" )) {
1149+ continue ;
1150+ }
1151+ EXPECT_TRUE (r.plain_is_universe ());
1152+ }
1153+ }
1154+
11211155int main (int argc, char ** argv) {
11221156 ::testing::InitGoogleTest (&argc, argv);
11231157 ::gflags::ParseCommandLineFlags (&argc, &argv, true );
0 commit comments