Beya2019 commented on a change in pull request #6443:
URL: https://github.com/apache/incubator-tvm/pull/6443#discussion_r486734730



##########
File path: python/tvm/relay/op/vision/rcnn.py
##########
@@ -24,7 +24,7 @@ def roi_align(data, rois, pooled_size, spatial_scale, 
sample_ratio=-1, layout='N
     Parameters
     ----------
     data : relay.Expr
-        4-D tensor with shape [batch, channel, height, width]
+        4-D tensor with shape [batch, channel, height, width] or [batch, 
height, width, channel]

Review comment:
       Hi @kevinthesun and @anijain2305,
   
    This NHWC layout topi implementation for roi_align is really not currently 
supported for traditional TVM targets. But in relay/frontend/mxnet.py the 
_mx_roi_align operator is fixed to NCHW(new_attrs["layout"] = "NCHW"),  that is 
only the nchw topi implemention process is called normally. For the special 
target which is only support nhwc layout, we can add extra code in mxnet.py(or 
other frontend py) as 
follows(RFC:https://tvm.apache.org/docs/dev/convert_layout.html#usage):
   ```
   desired_layouts = {'vision.roi_align': ['NHWC', `default`]}
   
   # Convert the layout to NCHW
   # RemoveUnunsedFunctions is used to clean up the graph.
   seq = tvm.transform.Sequential([relay.transform.RemoveUnusedFunctions(),
                                   
relay.transform.ConvertLayout(desired_layouts)])
   with tvm.transform.PassContext(opt_level=3):
       mod = seq(mod)
   ```
   So, it doesn't cause the compilation failure for the nhwc topi 
implementation process can not be called for traditional TVM targets. but it 
expanded the nhwc relay ir implement with their own backend code for the 
special target which is only support nhwc layout.
   
   
   Certainly, the nhwc layout topi implementation is to be realized sooner or 
later, I think it can be improved gradually in the future.




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