aksnzhy opened a new pull request #12809: Add index_copy() tensor operator
URL: https://github.com/apache/incubator-mxnet/pull/12809
 
 
   This is a PR to add a index_copy() tensor operator, which will be used in 
the DGL project.
   
   `output = mx.nd.contrib.index_copy(old_tensor, index, new_tensor)`
   
   This op copies the elements of a `new_tensor` into the `old_tensor` by 
   selecting the indices in the order given in `index`. The output will be a 
new tensor 
   contains the rest elements of old tensor and the copied elements of new 
tensor. 
   For example, if `index[i] == j`, then the `i`th row of `new_tensor` is 
copied to the 
   `j`th row of output.
   
   The `index` must be a vector and it must have the same size with the `0`th 
dimimention of 
   `new_tensor`. Also, the `0`th dimimention of old_tensor must `>=` the `0`th 
dimimention of 
   `new_tensor`, or an error will be raised.
   
   Examples::
   
   x = mx.nd.zeros((5,3))
   t = mx.nd.array([[1,2,3],[4,5,6],[7,8,9]])
   index = mx.nd.array([0,4,2])
   
   mx.nd.contrib.index_copy(x, index, t)
   
   [[1. 2. 3.]
    [0. 0. 0.]
    [7. 8. 9.]
    [0. 0. 0.]
    [4. 5. 6.]]
   <NDArray 5x3 @cpu(0)>
   
   Note that, so far we don't need the backward function for this operator.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to