You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2019/06/12 23:13:24 UTC

[GitHub] [incubator-mxnet] ThomasDelteil commented on a change in pull request #15228: Cleaned up profiling tutorial

ThomasDelteil commented on a change in pull request #15228: Cleaned up profiling tutorial
URL: https://github.com/apache/incubator-mxnet/pull/15228#discussion_r293153561
 
 

 ##########
 File path: docs/tutorials/python/profiler.md
 ##########
 @@ -34,33 +34,18 @@ y = nd.dot(x, x)
 print('Time for matrix multiplication: %f sec\n' % (time() - start))
 
 start = time()                                
-print(y.asnumpy())                                
-print('Time for printing the output: %f sec' % (time() - start))
+y_np = y.asnumpy()                             
+print('Time for converting to numpy: %f sec' % (time() - start))
 ```
 
-
 **Time for matrix multiplication: 0.005051 sec**<!--notebook-skip-line-->
 
-[[501.1584  508.29724 495.65237 ... 492.84705 492.69092 490.0481 ]<!--notebook-skip-line-->
-
- [508.81058 507.1822  495.1743  ... 503.10526 497.29315 493.67917]<!--notebook-skip-line-->
-
- [489.56598 499.47015 490.17722 ... 490.99945 488.05008 483.28836]<!--notebook-skip-line-->
-
- ...<!--notebook-skip-line-->
-
- [484.0019  495.7179  479.92142 ... 493.69952 478.89194 487.2074 ]<!--notebook-skip-line-->
-
- [499.64932 507.65094 497.5938  ... 493.0474  500.74512 495.82712]<!--notebook-skip-line-->
+**Time for converting to numpy: 0.167693 sec**<!--notebook-skip-line-->
 
- [516.0143  519.1715  506.354   ... 510.08878 496.35608 495.42523]]<!--notebook-skip-line-->
 
-**Time for printing the output: 0.167693 sec**<!--notebook-skip-line-->
+From the timings above, it seems as if converting to numpy takes lot more time than multiplying two large matrices. That doesn't feel right.
 
-
-From the output above, it seems as if printing the output takes lot more time that multiplying two large matrices. That doesn't feel right. 
-
-This is because, in MXNet, all operations are executed asynchronously. So, when `nd.dot(x, x)` returns, the matrix multiplication is not complete, it has only been queued for execution. `asnumpy` in `print(y.asnumpy())` however, waits for the result to be computed and hence takes longer time.
+This is because, in MXNet, all operations are executed asynchronously. So, when `nd.dot(x, x)` returns, the matrix multiplication is not complete, it has only been queued for execution. `asnumpy` however, waits for the result to be computed and hence takes longer time. Other examples of 'blocking' operations include `asscalar` and `wait_to_read`.
 
 Review comment:
   `asnumpy` however, has to wait for the result to be actually computed in order to be able to convert it to a numpy array on CPU, hence taking a longer time.
   
   or something like that. To express that it doesn't just wait for no reason.

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


With regards,
Apache Git Services