Seems we all agree that introducing `DeclBuffer` is helpful. The only unresolved question is how shall the TVMScript be updated as @wrongtest mentioned. As discussed above, we have the options:
* B1: In TVMScript, `T.allocate` and `T.decl_buffer` strictly map to the corresponding TIR nodes. To allocate and declare a buffer (in lowered TIR), there will be two separate steps: ``` data = T.allocate(physical_shape) buffer = T.decl_buffer(data=data, shape=physical_shape) ``` * B2: provide some syntax sugar for `T.allocate` (adding a `returns_buffer` option), which is translated to `AllocateNode` + `DeclBufferNode` in TIR. ``` buffer = T.allocate(physical_shape, returns_buffer=True) ``` When printing them from TIR to TVMScript, we still print in unsugared form in B1. Note that in B2, it is not feasible to make `T.allocate` always return the created buffer, because 1) there might be still need to directly use the buffer var in lower level TIR 2) when printing the TIR to TVMScript, `AllocateNode` and `DeclBufferNode` do not always appear in the same place, it is difficult (and not preferred) to map two TIR nodes into one TVMScript statement would love to know what you think @wrongtest @Hzfengsy -- Reply to this email directly or view it on GitHub: https://github.com/apache/tvm-rfcs/pull/70#issuecomment-1149308146 You are receiving this because you are subscribed to this thread. Message ID: <apache/tvm-rfcs/pull/70/c1149308...@github.com>