comaniac commented on a change in pull request #8669:
URL: https://github.com/apache/tvm/pull/8669#discussion_r685356175



##########
File path: python/tvm/topi/x86/dense_alter_op.py
##########
@@ -39,6 +40,17 @@ def _alter_dense_layout(attrs, inputs, tinfos, out_type):
         relay.op.get("nn.dense"), attrs, tinfos, out_type, target
     )
     workload = autotvm.task.get_workload(outs)
+
+    data_type = 
relay.transform.InferType()(IRModule.from_expr(inputs[0]))["main"].body.checked_type
+    assert len(data_type.shape) in [2, 3], "Input data must be a 2D or 3D 
tensor."
+
+    if len(data_type.shape) == 3:
+        # Only supports 2D input
+        in_layout = "NC%dc" % data_type.shape[2]
+        data = relay.layout_transform(inputs[0], in_layout, "NC")

Review comment:
       I took some time to think about the overhead of implicitly inserted 
layout_transform when input data is NC[x]c, but I didn't have a better 
solution, so I guess this is the right one we're looking for.

##########
File path: python/tvm/topi/x86/dense_alter_op.py
##########
@@ -39,6 +40,17 @@ def _alter_dense_layout(attrs, inputs, tinfos, out_type):
         relay.op.get("nn.dense"), attrs, tinfos, out_type, target
     )
     workload = autotvm.task.get_workload(outs)
+
+    data_type = 
relay.transform.InferType()(IRModule.from_expr(inputs[0]))["main"].body.checked_type

Review comment:
       Does this work for multi-functions? Something like
   ```
   %1 = %global_var(...);
   %2 = nn.dense(%1, %weight);
   ```




-- 
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: commits-unsubscr...@tvm.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to