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



##########
File path: src/tir/transforms/arg_binder.cc
##########
@@ -184,38 +194,41 @@ void ArgBinder::BindDLTensor(const Buffer& buffer, const 
PrimExpr& device_type,
                                      IntImm(DataType::Int(32), 
buffer->data_alignment), nop));
   }
 
+  // shape field
+  Buffer buf_shape = decl_buffer({IntImm(DataType::Int(32), 
pre_flattened_shape.size())},
+                                 tvm_shape_type, arg_name + ".shape");
   Var v_shape(arg_name + ".shape", DataType::Handle());
   def_handle_dtype_.Set(v_shape, make_const(tvm_shape_type, 0));
   init_nest_.emplace_back(
-      LetStmt(v_shape, TVMArrayGet(DataType::Handle(), handle, 
builtin::kArrShape), nop));
-  for (size_t k = 0; k < buffer->shape.size(); ++k) {
+      LetStmt(buf_shape->data, TVMArrayGet(DataType::Handle(), handle, 
builtin::kArrShape), nop));
+  for (size_t k = 0; k < pre_flattened_shape.size(); ++k) {
     if (dtype == DataType::Int(4) || dtype == DataType::UInt(4) || dtype == 
DataType::Int(1)) {
       break;
     }
     std::ostringstream field_name;
     field_name << v_shape->name_hint << '[' << k << ']';
-    Bind_(buffer->shape[k],
-          cast(buffer->shape[k].dtype(),
-               Load(tvm_shape_type, v_shape, IntImm(DataType::Int(32), k), 
const_true(1))),
-          field_name.str(), true);
+    Bind_(
+        pre_flattened_shape[k],
+        cast(pre_flattened_shape[k].dtype(), BufferLoad(buf_shape, 
{IntImm(DataType::Int(32), k)})),
+        field_name.str(), true);
   }
   // strides field
-  Var v_strides(arg_name + ".strides", DataType::Handle());
-  def_handle_dtype_.Set(v_strides, tir::TypeAnnotation(tvm_shape_type));
-  init_nest_.emplace_back(
-      LetStmt(v_strides, TVMArrayGet(DataType::Handle(), handle, 
builtin::kArrStrides), nop));
-  PrimExpr v_strides_is_null = Call(DataType::Bool(1), builtin::isnullptr(), 
{v_strides});
-  if (buffer->strides.size() == 0) {
+  Buffer buf_strides = decl_buffer({IntImm(DataType::Int(32), 
pre_flattened_strides.size())},
+                                   tvm_shape_type, arg_name + ".strides");

Review comment:
       Certainly, and helper function added to generate the names of the 
handles and elements of the shapes and strides arrays.




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