sxjscience commented on issue #11061:
URL: 
https://github.com/apache/incubator-mxnet/issues/11061#issuecomment-701217514


   Even in the latest MXNet 2.0, this performance issue was not solved:
   
   - Speed of topk(k=1)
   
   ```python
   import time
   import mxnet as mx
   import numpy as np
   import os
   tmp = mx.np.random.normal(-1, 1, (64,300000), ctx=mx.gpu())
   tic = time.time()
   for i in range(20):
      if (i == 5):
           begin = time.time();
      elif (i == 15):
           end = time.time();
      tic = time.time()
      out = mx.npx.topk(tmp, k=1, ret_typ='indices', axis=1, dtype=np.int32)
      out.wait_to_read()
      toc = time.time() - tic
      print ("used time %f:"%toc)
   avg = (end - begin) / 10
   print("avg time %f"%avg)
   ```
   
   
   Output:
   ```
   used time 0.001522:
   used time 0.001141:
   used time 0.001141:
   used time 0.001094:
   used time 0.001081:
   used time 0.001080:
   used time 0.001086:
   used time 0.001089:
   used time 0.001075:
   used time 0.001085:
   used time 0.00108
   ```
   
   - Speed of argmax:
   ```python
   import time
   import mxnet as mx
   import numpy as np
   import os
   tmp = mx.np.random.normal(-1, 1, (64,300000), ctx=mx.gpu())
   tic = time.time()
   for i in range(20):
      if (i == 5):
           begin = time.time();
      elif (i == 15):
           end = time.time();
      tic = time.time()
      out = mx.np.argmax(tmp, axis=1)
      out.wait_to_read()
      toc = time.time() - tic
      print ("used time %f:"%toc)
   avg = (end - begin) / 10
   print("avg time %f"%avg)
   ```
   
   Output
   ```
   used time 0.063610:
   used time 0.060543:
   used time 0.059911:
   used time 0.059865:
   used time 0.055048:
   used time 0.054780:
   used time 0.054773:
   used time 0.054817:
   used time 0.054653:
   used time 0.054758:
   used time 0.054723:
   used time 0.054765:
   used time 0.054680:
   used time 0.054769:
   ```


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



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to