tvm
tvm copied to clipboard
Cannot prove ... when generating the post doubt loop
If TVM is built with the latest github code, the "Getting Started" tutorial {link} now raises the following warning when generating CUDA code:
loop_partition.cc:345: Cannot prove: (((((n + 63)/64) - 1) - ((((n - 1) - 63)/64) + 1)) >= 0), when generating the post doubt loop
Additionally, the generated kernel now looks like this:
extern "C" __global__ void myadd__kernel0(float* __restrict__ C, float* __restrict__ A, float* __restrict__ B, int n) {
if (((int)blockIdx.x) < ((n + -1) / 64)) {
C[(((int)threadIdx.x) + (((int)blockIdx.x) * 64))] = (A[(((int)threadIdx.x) + (((int)blockIdx.x) * 64))] + B[(((int)threadIdx.x) + (((int)blockIdx.x) * 64))]);
} else {
if (((int)threadIdx.x) < (n - (((int)blockIdx.x) * 64))) {
C[(((int)threadIdx.x) + (((int)blockIdx.x) * 64))] = (A[(((int)threadIdx.x) + (((int)blockIdx.x) * 64))] + B[(((int)threadIdx.x) + (((int)blockIdx.x) * 64))]);
}
}
}
When previously the generated code was:
extern "C" __global__ void myadd__kernel0(float* __restrict__ C, float* __restrict__ A, float* __restrict__ B, int n) {
if (((int)blockIdx.x) < ((n + -127) / 64)) {
C[((((int)blockIdx.x) * 64) + ((int)threadIdx.x))] = (A[((((int)blockIdx.x) * 64) + ((int)threadIdx.x))] + B[((((int)blockIdx.x) * 64) + ((int)threadIdx.x))]);
} else {
if ((((int)blockIdx.x) * 64) < (n - ((int)threadIdx.x))) {
C[((((int)blockIdx.x) * 64) + ((int)threadIdx.x))] = (A[((((int)blockIdx.x) * 64) + ((int)threadIdx.x))] + B[((((int)blockIdx.x) * 64) + ((int)threadIdx.x))]);
}
}
}
Is this intended behavior for the LoopPartition pass?
should be fixed by https://github.com/dmlc/tvm/pull/766 the new condition is due to #https://github.com/dmlc/tvm/pull/755 which introduce tighter bound deduction