|  | 
| 14 | 14 | # KIND, either express or implied.  See the License for the | 
| 15 | 15 | # specific language governing permissions and limitations | 
| 16 | 16 | # under the License. | 
|  | 17 | +import pytest | 
| 17 | 18 | import tvm | 
| 18 | 19 | import tvm.testing | 
| 19 | 20 | from tvm.script import tir as T | 
| @@ -46,5 +47,30 @@ def load_vec(A: T.Buffer((N,), "int8")): | 
| 46 | 47 |         check_rvv_presence(16, 32) | 
| 47 | 48 | 
 | 
| 48 | 49 | 
 | 
|  | 50 | +@tvm.testing.requires_llvm_minimum_version(14) | 
|  | 51 | +@tvm.testing.parametrize_targets( | 
|  | 52 | +    "llvm -device=riscv_cpu -mtriple=riscv32-linux-gnu -mcpu=generic-rv32 -mattr=+i,+m,+v", | 
|  | 53 | +    "llvm -device=riscv_cpu -mtriple=riscv64-linux-gnu -mcpu=generic-rv64 -mattr=+64bit,+a,+c,+d,+f,+m,+v", | 
|  | 54 | +) | 
|  | 55 | +def test_rvv_vscale_llvm_dbginfo(target): | 
|  | 56 | +    # fmt: off | 
|  | 57 | +    @T.prim_func | 
|  | 58 | +    def rvv_with_vscale(A_handle: T.handle, B_handle: T.handle, C_handle: T.handle): | 
|  | 59 | +        A = T.match_buffer(A_handle, (8,), dtype="float32", align=4, offset_factor=1) | 
|  | 60 | +        B = T.match_buffer(B_handle, (4, 8), dtype="float32", align=4, offset_factor=1, strides=[8, 1]) | 
|  | 61 | +        C = T.match_buffer(C_handle, (4,), dtype="float32", align=4, offset_factor=1) | 
|  | 62 | +        with T.block("root"): | 
|  | 63 | +            T.reads(A[0:8], B[0:4, 0:8]) | 
|  | 64 | +            zero = T.call_llvm_intrin("float32xvscalex2", "llvm.riscv.vfmv.v.f", T.Broadcast(T.float32(0.0), T.vscale() * 2), C[0], T.uint64(1)) | 
|  | 65 | +            vec_A = T.call_llvm_intrin("float32xvscalex4", "llvm.riscv.vle", T.Broadcast(T.float32(0.0), T.vscale() * 4), T.tvm_access_ptr(T.type_annotation("float32"), A.data, 0, 8, 1), T.int64(8)) | 
|  | 66 | +            vec_B = T.call_llvm_intrin("float32xvscalex4", "llvm.riscv.vle", T.Broadcast(T.float32(0.0), T.vscale() * 4), T.tvm_access_ptr(T.type_annotation("float32"), B.data, 0 * 8, 8, 1), T.int64(8)) | 
|  | 67 | +            prod = T.call_llvm_intrin("float32xvscalex4", "llvm.riscv.vfmul", T.Broadcast(T.float32(0.0), T.vscale() * 4), vec_A, vec_B, T.uint64(7), T.uint64(8)) | 
|  | 68 | +            redsum = T.call_llvm_intrin("float32xvscalex2", "llvm.riscv.vfredusum", T.Broadcast(T.float32(0.0), T.vscale() * 2), prod, zero, T.uint64(7), T.uint64(8)) | 
|  | 69 | +    # fmt: on | 
|  | 70 | + | 
|  | 71 | +    # tvm.error.InternalError: Can't fetch the lanes of a scalable vector at a compile time. | 
|  | 72 | +    with tvm.target.Target(target): | 
|  | 73 | +        f = tvm.tir.build(rvv_with_vscale, target) | 
|  | 74 | + | 
| 49 | 75 | if __name__ == "__main__": | 
| 50 | 76 |     tvm.testing.main() | 
0 commit comments