wangliting-amy opened a new issue #6564:
URL: https://github.com/apache/incubator-tvm/issues/6564


   hello:
   i want to build and run the model of resnest50,which i get_model from mxnet 
model_zoo.the code is:
   model = gluoncv.model_zoo.get_model('ResNeSt50', pretrained=True)
   and i want to change the layout from NCHW to NHWC, but i find the 
adaptive_avg_pool2d can not be changed the layout.
   so according to the link of 
https://tvm.apache.org/docs/dev/convert_layout.html?highlight=convertlayout
   i add the FTVMConvertLayout register for adaptive_avg_pool2d, the code like 
this:
   
   @reg.register_convert_op_layout("nn.adaptive_avg_pool2d")
   def convert_adaptive_avg_pool2d(attrs, inputs, tinfos, desired_layouts):
       """Convert Layout pass registration for adaptive_avg_pool2d op.
   
       Parameters
       ----------
       attrs : tvm.ir.Attrs
           Attributes of current convolution
       inputs : list of tvm.relay.Expr
           The args of the Relay expr to be legalized
       tinfos : list of types
           List of input and output types
       desired_layouts : list of layout strings
           List of layouts defining our desired
           layout for the data input.
   
       Returns
       -------
       result : tvm.relay.Expr
           The transformed expr
       """
       # pylint: disable=import-outside-toplevel
       from tvm import relay
       data = inputs
       new_attrs = dict(attrs)
       assert len(desired_layouts) == 1, "A desired layout is expected for 
input data only"
       desired_data_layout = desired_layouts[0]
       assert desired_data_layout != "default", "Data layout cannot be default"
       new_attrs['layout'] = desired_data_layout
       return relay.nn.adaptive_avg_pool2d(data, **new_attrs)
   
   but when i build and run,there is a problem like this:
   /tvm/python/tvm/relay/op/nn/_nn.py", line 420, in convert_adaptive_avg_pool2d
       new_attrs = dict(attrs)
   TypeError: 'Object' object is not iterable
   i do not know the reason,can help me,thank you~


----------------------------------------------------------------
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:
[email protected]


Reply via email to