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



##########
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:
       ok I took a look at this issue again, and I still don't see a way to 
make use of `InferCorrectLayout` in this context. I added
   ```
   InferCorrectLayoutOutput DenseInferCorrectLayout(const Attrs& attrs,
                                                    const Array<Layout>& 
new_in_layouts,
                                                    const Array<Layout>& 
old_in_layouts,
                                                    const 
Array<tvm::relay::Type>& old_in_types) {
     return InferCorrectLayoutOutput({"NC", "NK"}, {"NC"}, attrs);
   }
   ```
   I think this is the only reasonable definition. I was hoping that this would 
insert "NC8c -> NC" transform on the first input and thus force the input 
layout  be 2D, but in the callback at 
https://github.com/apache/tvm/blob/95a32995c9c50b3dfc63eca0ff0d5bcd92b01816/python/tvm/topi/x86/dense_alter_op.py#L31
 I still get 3D packed input.
   
   I didn't look at the details of how `LayoutRewriter` and the call back are 
supposed to interact, but my impression is that in the AlterOpLayout case, we 
cannot rely on `LayoutRewriter` to insert layout transform on the inputs of 
conv/dense, and we need to do EVERYTHING inside the call back. That includes 
adding necessary layout transform, generating new attributes and contrib op. So 
I believe `InferCorrectLayout` has no role to play here. 




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