jasonyu1996 edited a comment on issue #12327: [Feature Request] support of diag 
for N-d arrays
URL: 
https://github.com/apache/incubator-mxnet/issues/12327#issuecomment-416790602
 
 
   Hi! Thank you for your response! I just paid a visit to the numpy interfaces 
for computing the diagonal, and noticed that besides `numpy.diag` (which is 
exactly where our the design of our `diag` operator comes from) numpy provides 
a second diagonal extracting function `numpy.diagonal` 
(https://www.numpy.org/devdocs/reference/generated/numpy.diagonal.html), which 
in my opinion is a good reference for extending the functionality of our `diag` 
operator (I also noticed that `numpy.trace` also supports N-d arrays and 
accepts the same set of arguments as `numpy.diagonal`). However, I am not sure 
whether a new operator should be added or not. I wonder why numpy provides two 
functions, one strictly weaker than the other, which do the same thing.
   
   As for the implementation detail, I have to admit that I am not familiar 
with this and am therefore not sure about the possibility of further improving 
the performance by implementing it in ways other than simply fusing some 
high-level function calls together. I think it is possibly necessary to refer 
to the implementation of the 2-d case, which it seems does not depend on other 
high-level function calls (`diag` for 2-d arrays can also be implemented with 
an `arange` followed by a `pick`).

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


With regards,
Apache Git Services

Reply via email to