wkcn edited a comment on issue #11913: Unexpectedly poor copy() performance
URL: 
https://github.com/apache/incubator-mxnet/issues/11913#issuecomment-409904550
 
 
   @safrooze 
   Yes. I modified the code then reported the result.
   Here is the code I modified.
   
   ```
   a = nd.empty((1, 512, 120*120))
   nd.waitall()
   
   start = time()
   for _ in range(2000):
       b = a.copy()
       nd.waitall()
   print('\tcopy: elapsed: {:.2f}'.format(time() - start))
   
   start = time()
   for _ in range(2000):
       b = a + 0.0
       nd.waitall()
   print('\tcopy via add: elapsed: {:.2f}'.format(time() - start))
   ```
   
   And I test the code you provided,
   copy: elapsed: 2.69
   copy via add: elapsed: 4.31
   
   The reason that I changed the code is that the computation of NDArray is 
lazy.
   The script `b = a + 0.0` only records this operation but there is no actual 
computation until `nd.waitall` is called.

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