sheep94lion commented on issue #12159: C++ api executor->Forward(false) is much 
slower than MXPredForward?
URL: 
https://github.com/apache/incubator-mxnet/issues/12159#issuecomment-506118494
 
 
   > Hi @xiaojingxie
   > 
   > The Executor->Forward() method performs more tasks as compared to 
MXPredForward(). It invokes following 2 C APIs internally
   > MXExecutorForward()
   > and
   > MXExecutorOutputs()
   > where as MXPredForward() only runs the forward pass and does not retrieve 
the outputs.
   > In addition, the outputs of the forward pass are copied to the 'output' 
array in the Executor object, for faster retrieval later.
   > 
   > Therefore, we can not compare MXPredForward() with Executor->Forward(). 
For the correct comparison, we should find out the time required to invoke 
MXPredGetOutputShape() and MXPredGetOutput() after invoking the MXPredForward()
   > 
   > I hope this answers the question.
   > @mxnet-label-bot add [Pending Requester Info]
   
   The running time of C API MXPredForward is much shorter than the running 
time of MXPredGetOutput:
   ```
   auto start = std::chrono::high_resolution_clock::now();
   MXPredForward(pred_hnd);
   auto stop = std::chrono::high_resolution_clock::now();
   auto duration = std::chrono::duration_cast<std::chrono::microseconds>(stop - 
start);
   LOGI("MXPredForward: %d microseconds.", duration.count());
   std::vector<float> data(size);
   start = std::chrono::high_resolution_clock::now();
   MXPredGetOutput(pred_hnd, output_index, &(data[0]), 
static_cast<mx_uint>(size));
   stop = std::chrono::high_resolution_clock::now();
   duration = std::chrono::duration_cast<std::chrono::microseconds>(stop - 
start);
   LOGI("MXPredGetOutput: %d microseconds.", duration.count());
   ```
   The result is:
   ```
   I/MXNET: MXPredForward: 106 microseconds.
   I/MXNET: MXPredGetOutput: 3748967 microseconds.
   ```
   Why? Is it something related to lazy evaluation?
   The code runs on Pixel3 with Snapdragon 835.

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


With regards,
Apache Git Services

Reply via email to