adstraw commented on code in PR #13613: URL: https://github.com/apache/tvm/pull/13613#discussion_r1049933426
########## src/tir/transforms/lower_async_dma.cc: ########## @@ -146,13 +153,32 @@ class AsyncDMALowerer : public StmtExprMutator { // map loop variable to zero for the store index & simplify Array<PrimExpr> store_index = bufferstorenode->indices; + + // Use DetectIterMap to detect whether store index is non-contiguous. + arith::Analyzer analyzer; + auto store_iter_map = DetectIterMap(store_index, input_iters, 1, arith::IterMapLevel::NoCheck, + &analyzer, false); + if (!store_iter_map->errors.empty()) { + LOG(FATAL) << "Unable to lower async dma for non contiguous memory access with index: " + << store_index; + } + store_index.MutateByApply([&](PrimExpr expr) { arith::Analyzer analyzer; return analyzer.Simplify(Substitute(std::move(expr), loop_var_remap)); }); // map loop variable to zero for the load index & simplify Array<PrimExpr> load_index = bufferloadnode->indices; + + // Use DetectIterMap to detect whether load index is non-contiguous. + auto load_iter_map = + DetectIterMap(load_index, input_iters, 1, arith::IterMapLevel::NoCheck, &analyzer, false); + if (!load_iter_map->errors.empty()) { + LOG(FATAL) << "Unable to lower async dma for non contiguous memory access with index: " Review Comment: Nit: Same as above. Add text indicating "buffer load" contained non contiguous access. ########## src/tir/transforms/lower_async_dma.cc: ########## @@ -146,13 +153,32 @@ class AsyncDMALowerer : public StmtExprMutator { // map loop variable to zero for the store index & simplify Array<PrimExpr> store_index = bufferstorenode->indices; + + // Use DetectIterMap to detect whether store index is non-contiguous. + arith::Analyzer analyzer; + auto store_iter_map = DetectIterMap(store_index, input_iters, 1, arith::IterMapLevel::NoCheck, + &analyzer, false); + if (!store_iter_map->errors.empty()) { + LOG(FATAL) << "Unable to lower async dma for non contiguous memory access with index: " Review Comment: Nit: You might differentiate the error message by including something text indicating that the "buffer store" contained the non contiguous access. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@tvm.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org