From 821b263100823e8f28f92a3869ed4f4b124baf1c Mon Sep 17 00:00:00 2001 From: Yaxing Cai Date: Sun, 14 Aug 2022 17:06:51 -0700 Subject: [PATCH 1/2] update --- python/tvm/tir/__init__.py | 1 + python/tvm/tir/op.py | 68 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+) diff --git a/python/tvm/tir/__init__.py b/python/tvm/tir/__init__.py index c64b7dfe713d..962defe4c342 100644 --- a/python/tvm/tir/__init__.py +++ b/python/tvm/tir/__init__.py @@ -47,6 +47,7 @@ from .op import call_packed, call_cpacked, call_intrin, call_pure_extern, call_extern from .op import call_llvm_intrin, call_llvm_pure_intrin, ret, all, any, min_value, max_value, trace +from .op import tvm_stack_alloca, tvm_stack_make_shape, tvm_stack_make_array from .op import exp, exp2, exp10, log, log2, log10, log1p, ldexp, clz from .op import sin, sinh, asin, asinh from .op import cos, cosh, acos, acosh diff --git a/python/tvm/tir/op.py b/python/tvm/tir/op.py index 17005b04a482..fc80f857e9b5 100644 --- a/python/tvm/tir/op.py +++ b/python/tvm/tir/op.py @@ -250,6 +250,74 @@ def call_llvm_pure_intrin(dtype, name, *args, span=None): ) +def tvm_stack_alloca(dtype_str, num): + """Return new on stack dtype[num] + + Parameters + ---------- + dtype_str : str + The data type of array + + num : int + The size of array + + Returns + ------- + call : PrimExpr + The call expression. + """ + return call_intrin("handle", "tir.tvm_stack_alloca", dtype_str, num) + + +def tvm_stack_make_shape(*args): + """Allocate a shape tuple on stack, return the handle + + Parameters + ---------- + args : int + The tuple shape + + Returns + ------- + call : PrimExpr + The call expression. + """ + return call_intrin("handle", "tir.tvm_stack_make_shape", *args) + + +def tvm_stack_make_array(data, shape, strides, ndim, arr_dtype, elem_offset): + """Allocate a NDArray(DLTensor) on stack, return the handle + + Parameters + ---------- + data : Expr + The data of array + + shape : Expr + The shape of array + + strides : Expr + The strides of array + + ndim : Expr + The dimensions of array + + arr_dtype : Expr + The data type of array + + elem_offse : Expr + The element offset of array + + Returns + ------- + call : PrimExpr + The call expression. + """ + return call_intrin( + "handle", "tir.tvm_stack_make_array", data, shape, strides, ndim, arr_dtype, elem_offset + ) + + def ret(val): """Create a tir return expression From 54663f1748af6300a6de80f06dafff24c8717216 Mon Sep 17 00:00:00 2001 From: Yaxing Cai Date: Sun, 14 Aug 2022 17:25:18 -0700 Subject: [PATCH 2/2] update --- python/tvm/tir/op.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/python/tvm/tir/op.py b/python/tvm/tir/op.py index fc80f857e9b5..33e077c64d4d 100644 --- a/python/tvm/tir/op.py +++ b/python/tvm/tir/op.py @@ -256,10 +256,10 @@ def tvm_stack_alloca(dtype_str, num): Parameters ---------- dtype_str : str - The data type of array + The data type of array. num : int - The size of array + The size of array. Returns ------- @@ -275,7 +275,7 @@ def tvm_stack_make_shape(*args): Parameters ---------- args : int - The tuple shape + The tuple shape. Returns ------- @@ -291,22 +291,22 @@ def tvm_stack_make_array(data, shape, strides, ndim, arr_dtype, elem_offset): Parameters ---------- data : Expr - The data of array + The data of array. shape : Expr - The shape of array + The shape of array. strides : Expr - The strides of array + The strides of array. ndim : Expr - The dimensions of array + The dimensions of array. arr_dtype : Expr - The data type of array + The data type of array. elem_offse : Expr - The element offset of array + The element offset of array. Returns -------