honghuichao commented on issue #13759:
URL: https://github.com/apache/tvm/issues/13759#issuecomment-1443725461

   @liaojianjin
   
       @classmethod
       def _index_put(cls, inputs, attr, params):
           in_tensor = inputs[0]
           indices, values = cls._check_index(inputs[1 : len(inputs) - 2], 
inputs[len(inputs) - 2])
           accumulate = inputs[len(inputs) - 1].data.asnumpy() != 0
           if not accumulate:
               mode = "update"
           else:
               mode = "add"
           index_tensor = _op.stack(indices, axis=0)
           return _op.transform.scatter_nd(in_tensor, index_tensor, values, 
mode)
   
       def _check_index(cls, indices, values):
           def unfolding_indices(indices, values):
               n = len(indices)
               flatten_indices = []
               slices_size = []
               for index in indices:
                   flatten_indices.append(_op.reshape(index, _op.const([-1])))
                   slices_size.append(infer_shape(flatten_indices[-1])[0])
               repeat_size = [1]
               tile_size = [1]
               for i in range(1, n):
                   repeat_size.append(slices_size[-i] * repeat_size[-1])
                   tile_size.append(slices_size[i - 1] * tile_size[-1])
               repeat_size.reverse()
               unflod_slices = []
               for i in range(n):
                   unflod_slices.append(
                       fold_constant(
                           _op.repeat(_op.tile(flatten_indices[i], 
(tile_size[i],)), repeat_size[i], 0)
                       )
                   )
               return unflod_slices, _op.reshape(values, _op.const([-1]))
   
   
   
   
   
   in the  function  _check_index(cls, indices, values) ,it will call 
infer_shape to get the indices size,but the indice size cannot inference when 
shape is dynamatic.  my environment base pytorch == 1.8.0. and I think if 
torch.onnx.export base pytorch1.13.1, the aten::indexput cannot show in onnx 
graph,but maybe scatter_nd show in onnx graph.
   
    


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