vinx13 commented on code in PR #70:
URL: https://github.com/apache/tvm-rfcs/pull/70#discussion_r893900504


##########
rfcs/0070-introducing-decl-buffer.md:
##########
@@ -136,11 +138,26 @@ def elemwise(A: T.Buffer[(16, 16), "float32"], C: 
T.Buffer[(16, 16), "float32"])
         C_flattened[i * 16 + j] = A[i * 16 + j]
 ```
 
+Specifically, the updated flow of buffer flattening using `DeclBuffer` will be:
+1. Before `FlattenBuffer/StorageFlatten`: Buffers are declared in the 
`buffer_map`, and are not flattened. Buffer access is done using N-d 
unflattened indices.
+2. After `FlattenBuffer/StorageFlatten`, but before `MakePackedAPI`: Buffers 
are declared in the `buffer_map`, and are not flattened. Buffer access is done 
through a buffer alias explicitly created via `DeclBuffer`, where the alias 
shares the same data pointer, but has a flattened shape and is accessed with 
flattened indices.

Review Comment:
   It is not changed. The buffer in `buffer_map` is always unflattened. After 
`FlattenBuffer/StorageFlatten`, we will create a flattened view of the buffer 
using buffer alias, and in IR all accesses to the buffer will be done via the 
flattened view. This is because from the perspective of the calling convention 
of `PrimFunc`, we always expect the input to have unflattened shape (e.g. the 
shape of `DLTensor`). But internally in the IR, we need to flatten to physical 
shape and indices which is how it is done in  codegen and runtime



-- 
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]

Reply via email to