You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by GitBox <gi...@apache.org> on 2020/09/09 17:17:29 UTC

[GitHub] [incubator-tvm] anijain2305 commented on pull request #6430: [ConvertLayout] Use a packed function to decide layout based on operator attributes

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:
users@infra.apache.org