lazycal opened a new pull request #10595:
URL: https://github.com/apache/tvm/pull/10595
In the VectorizeLoop pass, when scalarizing a vectorized loop into
serialized loop (for reasons like it's not vectorizable), the for-loop is not
properly constructed to respect the loop variable's dtype. For example, the
second loop in the following code
```c
for (ax0.ax1.fused: int32, 0, 169) "parallel" {
for (ax2.inner: int64, 0i64, 4i64) "vectorized" {
T_transpose[((cast(int64, ax0.ax1.fused)*4i64) + ax2.inner)] =
@tir.if_then_else((3i64 <= ax2.inner), placeholder_1[(((ax2.inner*13i64) +
cast(int64, ax0.ax1.fused)) - 39i64)], @tir.if_then_else((2i64 <= ax2.inner),
placeholder_1[(((ax2.inner*13i64) + cast(int64, ax0.ax1.fused)) - 26i64)],
@tir.if_then_else((1i64 <= ax2.inner), placeholder_1[(((ax2.inner*13i64) +
cast(int64, ax0.ax1.fused)) - 13i64)], placeholder[((ax2.inner*13i64) +
cast(int64, ax0.ax1.fused))], dtype=int64), dtype=int64), dtype=int64)
}
}
```
is scalarized into
```c
for (ax0.ax1.fused: int32, 0, 169) "parallel" {
for (ax2.inner.s: int64, 0, 4) {
T_transpose[((cast(int64, ax0.ax1.fused)*4i64) + ax2.inner.s)] =
@tir.if_then_else((3i64 <= ax2.inner.s), placeholder_1[(((ax2.inner.s*13i64) +
cast(int64, ax0.ax1.fused)) - 39i64)], @tir.if_then_else((2i64 <= ax2.inner.s),
placeholder_1[(((ax2.inner.s*13i64) + cast(int64, ax0.ax1.fused)) - 26i64)],
@tir.if_then_else((1i64 <= ax2.inner.s), placeholder_1[(((ax2.inner.s*13i64) +
cast(int64, ax0.ax1.fused)) - 13i64)], placeholder[((ax2.inner.s*13i64) +
cast(int64, ax0.ax1.fused))], dtype=int64), dtype=int64), dtype=int64)
}
}
```
where `ax2.inner.s`'s start and extent are changed silently to int32. Later
it caused SegFault. After this PR, the above code will handle the dtype
correctly and output the following
```c
for (ax0.ax1.fused: int32, 0, 169) "parallel" {
for (ax2.inner.s: int64, 0i64, 4i64) {
T_transpose[((cast(int64, ax0.ax1.fused)*4i64) + ax2.inner.s)] =
@tir.if_then_else((3i64 <= ax2.inner.s), placeholder_1[(((ax2.inner.s*13i64) +
cast(int64, ax0.ax1.fused)) - 39i64)], @tir.if_then_else((2i64 <= ax2.inner.s),
placeholder_1[(((ax2.inner.s*13i64) + cast(int64, ax0.ax1.fused)) - 26i64)],
@tir.if_then_else((1i64 <= ax2.inner.s), placeholder_1[(((ax2.inner.s*13i64) +
cast(int64, ax0.ax1.fused)) - 13i64)], placeholder[((ax2.inner.s*13i64) +
cast(int64, ax0.ax1.fused))], dtype=int64), dtype=int64), dtype=int64)
}
}
```
An onnx model to trigger this issue:
[model.onnx.zip](https://github.com/apache/tvm/files/8241963/model.onnx.zip).
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]