cjolivier01 commented on issue #8219: Broadcasting ops are slow
URL: 
https://github.com/apache/incubator-mxnet/issues/8219#issuecomment-349509376
 
 
   By the way, I ran this script several times:
   
   import mxnet as mx
   import time
   
   a = mx.sym.var('a')
   b = mx.sym.var('b')
   
   a_ = mx.nd.ones((2**20,))
   b1 = mx.nd.ones((2**20,))
   b2 = mx.nd.ones((1,))
   
   func1 = (a + b).bind(mx.cpu(), {'a': a_, 'b': b1})
   func2 = mx.sym.broadcast_add(a, b).bind(mx.cpu(), {'a': a_, 'b': b2})
   func3 = (a + 1.).bind(mx.cpu(), {'a': a_})
   
   for x in range(4):
     print("PASS: {}...", x)
   
     # array + array
     start = time.time()
     for i in range(1000):
       func1.forward()[0].wait_to_read()
     print("func1: {}".format(time.time() - start))
   
   
     # boadcast_add(scalar, array)
     start = time.time()
     for i in range(1000):
       func2.forward()[0].wait_to_read()
     print("func2: {}".format(time.time() - start))
   
   
     # array + scalar
     start = time.time()
     for i in range(1000):
       func3.forward()[0].wait_to_read()
     print("func3: {}".format(time.time() - start))
   
     print(" ")

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