Question about allocation with dynamic size using Tensor IR

Hi all,

I am trying do some work with the new Tensor IR using TVM.script.However, I meet some problems when I trying to alloc local buffer within the primfunc.

It seems that the T.alloc_buffer only alloc from the stack,so it’s reasonable that the buffer size is constrained to a constant in compile time.However, with the help VM or time_evaluator,the primfunc is allowed to match buffer with T.match_buffer whose shaped is determined only at runtime.Therefore,what should I do if I want to alloc some local buffer with the same/related shape of the buffer which has dynamic shape and matched by T.match_buffer?Is there any way that I can make use of heap memory like malloc in C?

Besides,can a variable used in a primfunc be passed from the argments of the function when it has nothing to do with the buffer?When I simply add a T.int32 var in the argument list like:

@T.prim_func
def foo(A: T.handle, b:T.handle, x_in: T.handle, break_condition: T.int32) -> None:

and when I use the break_condition inside the func the error come out like:

Check failed: (it != var_map_.end()) is false: cannot find variable break_condition

so what’s the right way to do this?

Thank you

Michael