Lunderberg commented on a change in pull request #9727:
URL: https://github.com/apache/tvm/pull/9727#discussion_r780353202



##########
File path: include/tvm/tir/buffer.h
##########
@@ -55,8 +55,48 @@ class BufferNode : public Object {
   Var data;
   /*! \brief data type in the content of the tensor */
   DataType dtype;
-  /*! \brief The shape of the buffer */
+  /*! \brief The shape of the buffer
+   *
+   * This contains the shape as it is accessed by
+   * BufferLoad/BufferStore nodes, and used by the low-level code
+   * generators.
+   */
   Array<PrimExpr> shape;
+  /*! \brief The shape of the buffer prior to flattening
+   *
+   * This contains the shape as it exists prior to flattening, and is
+   * used for validating the shape of the tensor passed into the
+   * packed API.
+   *
+   * TODO(Lunderberg): Should this be a reference to the entire

Review comment:
       I've changed my mind, and agree that keeping a reference to the 
pre-flattened Buffer would be much cleaner.  I needed to add a third similar 
parameter for the preflattened type, since the post-flattening type of a 
boolean array is int8, and three similar parameters is too much.
   
   Unfortunately, having a `Optional<Buffer> pre_flattened_buffer` parameter 
causes some compilation issues.  `BufferNode` cannot be declared before 
`Buffer`, because `Optional<Buffer>` cannot use a forward declaration.   
`Buffer` cannot be declared before `BufferNode`, because 
`TVM_DEFINE_OBJECT_REF_METHODS` nor the `TVM_DEFINE_OBJECT_REF_COW_METHODS` 
macros work with a forward declaration.  It is possible to copy-paste declare 
the methods defined by these macros, then move the definitions themselves into 
`buffer.cc`, but that has more copy-paste code than I'd like.  I have a rough 
draft of the changes required, but I think it should be a follow-up PR instead.




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