HyperZealot commented on issue #12997: A better take forward kernel for CPU
URL: https://github.com/apache/incubator-mxnet/pull/12997#issuecomment-433747551
 
 
   @pengzhao-intel 
   script:
   ```Python
   import mxnet as mx
   import random
   from mxnet.test_utils import rand_ndarray, check_speed
   
   num_rows = 1000000
   test_rows = 20000
   num_cols = 512
   shape = (num_rows, num_cols)
   data = rand_ndarray(shape, stype='default')
   print(data.dtype)
   x = mx.sym.Variable('data')
   idx = mx.sym.Variable('indices')
   sym = mx.sym.take(a=x, indices=idx, axis=0)
   trials = int(num_rows / test_rows)
   total_time = 0.0
   all_indices = [i for i in range(num_rows)]
   random.shuffle(all_indices)
   for i in range(trials):
       indices = mx.nd.array(all_indices[i * test_rows: (i + 1) * test_rows])
       total_time += check_speed(sym, location={'data': data, 'indices': 
indices}, ctx=mx.cpu(), N=100, typ="forward")
   print(test_rows * num_cols * 4 * trials / total_time / 1024 / 1024 / 1024, 
"GB/s")
   ```
   Before with mxnet-mkl release version: 2.0371343465121163 GB/s
   After: 12.2486153514499 GB/s
   ~6x speedup with this new one

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