leezu commented on issue #17530: Add deferred compute support
URL: https://github.com/apache/incubator-mxnet/pull/17530#issuecomment-590473083
 
 
   @eric-haibin-lin enabling deferred compute mode enables recording and 
deferring the computation. 
   
   It does not automatically export the recording to a CachedOp and use that 
for accelerated computation. This logic is implemented in 
`HybridBlock.__call__`. `HybridBlock.__call__`, which automatically enables 
deferred compute mode for the computation of the Block. Users should not enable 
deferred compute outside manually (in fact it's an internal API as of this PR).
   
   We can add a `@hyridize` decorator in the future, which helps to hybridize 
functions based on deferred compute.
   
   Specifically to your code example, there are a few more considerations:
   
   **Cross device execution**
   `copyto` is not supported by CachedOp yet. Thus while we can use `copyto` 
inside deferred compute mode, exporting to Symbol and running the Symbol will 
fail.
   **Autograd**
   Autograd recording and deferred compute recording are currently mutually 
exclusive. You can't enable both at the same time. But you don't need to: 
Deferred compute provides the symbolic representation of the forward 
computation. We don't need autograd while obtaining this symbolic 
representation, ie. we can just disable autograd inside the deferred compute 
scope. `CachedOp` takes the symbol and facilitates computing gradients.
   
   It will be useful to support autograd inside deferred compute in the future, 
for higher order grads.
   
   > what happens if a user enables DC for the program below? 
   
   `MXNetError("Autograd recording is not supported during deferred compute 
mode.")`
   
   
https://github.com/apache/incubator-mxnet/blob/e64e03cb27b43f369c27c6629f1238103fa875e0/src/imperative/imperative.cc#L204-L214
   
   
https://github.com/apache/incubator-mxnet/blob/e64e03cb27b43f369c27c6629f1238103fa875e0/src/imperative/imperative.cc#L295-L299

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


With regards,
Apache Git Services

Reply via email to