[BUG][TIR] Symbolic floormod

compact_buffer_region PASS modify shared buffer stride[0] to

T.int64(72) * T.min((n + T.int64(63)) // T.int64(64) * T.int64(64), T.int64(96)) and stride[1] is T.int64(72) but in LowerOpaqueBlock PASS it report error: InternalError: Check failed: (is_zero(floormod(buffer->strides[i - 1], buffer->strides[i]))) is false:

is_zero(floormod(buffer->strides[i - 1], buffer->strides[i])) is not true.

Any solution?

Hi~ thanks for the finding! Could you kindly provide the workload(eg, the tir script) to reproduce the issue?

Thank u for your reply! Please check the script i uploaded to reproduce the problem. BTW, i am using mlc/relax branch would that make a difference?

Hi, could you try following changes?

--- a/src/tir/transforms/ir_utils.cc
+++ b/src/tir/transforms/ir_utils.cc
@@ -417,7 +417,8 @@ Array<PrimExpr> GetBufferAllocationShape(const Buffer& buffer) {
   if (buffer->strides.size()) {
     ICHECK_EQ(buffer->shape.size(), buffer->strides.size());
     for (size_t i = buffer->strides.size() - 1; i > 0; --i) {
-      ICHECK(is_zero(floormod(buffer->strides[i - 1], buffer->strides[i])));
+      ICHECK(
+          arith::Analyzer().CanProveEqual(floormod(buffer->strides[i - 1], buffer->strides[i]), 0));
       alloc_shape.Set(i, buffer->strides[i - 1] / buffer->strides[i]);
     }
   }

Generally not. The TIR part is shared. It would not be a surprise that current TIR handling encounter certain issue on dynamic shape workloads from unity. For this case, it just do not know c * some_index is divisible by c :slight_smile: . If it works, do you mind send this quick fix for the TVM repo? Thank you!

That works fine, i will send this quick fix for the TVM repo soon!

could u please to do code review ? There is one more bug i found in PASS InjectPTXAsyncCopy . that is dst_offset.dtype could be int64, the dtype of PrimExpr(index_factor) would be set to default to int32 . cause dtype inconsistent when calling tir::Mul . quick fix