anijain2305 commented on pull request #6430:
URL: https://github.com/apache/incubator-tvm/pull/6430#issuecomment-689703548


   Hi @lhutton1 Thanks for the PR! I am trying to understand the need for this 
PR.
   
   We can always overwrite the existing convert_op_layout for each operator. 
So, I don't think I fully understand that need and usage.
   
   For example, I can use the following code to perform the same operation (see 
that I am using a higher level - **plevel = 11**). This will be set by the TVM 
user and don't need to be the part of TVM codebase (similar to your usage).
   
   
   ~~~
      @reg.register_convert_op_layout("nn.conv2d", level=11)
      def custom_layouts(op_name, attrs, args):
           if op_name == "nn.conv2d":
               data = args[0].checked_type
               weight = args[1].checked_type
               is_depthwise = is_depthwise_conv2d(data.shape,
                                                  attrs['data_layout'],
                                                  weight.shape,
                                                  attrs['kernel_layout'],
                                                  attrs['groups'])
               return ['NHWC', 'IHWO'] if is_depthwise else ['NHWC', 'OHWI']
           raise ValueError(f'No custom layout defined for {op_name}')
   ~~~
   
   Does that make sense?
   


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

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


Reply via email to