sxjscience commented on a change in pull request #17530: Add deferred compute
support
URL: https://github.com/apache/incubator-mxnet/pull/17530#discussion_r386634532
##########
File path: src/imperative/imperative.cc
##########
@@ -273,7 +288,153 @@ void Imperative::RecordOp(
info.outputs.back().dtype_ = outputs[i]->dtype();
info.outputs.back().storage_type_ = outputs[i]->storage_type();
}
- outputs[i]->entry_ = nnvm::NodeEntry{node, i, 0};
+ outputs[i]->autograd_entry_ = nnvm::NodeEntry{node, i, 0};
+ }
+}
+
+void Imperative::RecordDeferredCompute(nnvm::NodeAttrs &&attrs,
+ const std::vector<NDArray *> &inputs,
+ const std::vector<NDArray *> &outputs) {
+ CHECK(!is_recording())
+ << "Autograd recording is not supported during deferred compute mode.";
+
+ for (const NDArray *output : outputs) {
+ CHECK(DCInfo::IsNone(*output))
+ << "Inplace operations (+=, -=, x[:]=, etc) are not supported when "
+ << "recording in deferred compute mode.";
+ // However, an inplace operation on a non-deferred compute array inside
Review comment:
Does it mean that these two code snippets will be different?
- Without error:
```python
a = mx.np.arange(10)
with dc.context():
a[:5] = 0
```
- With error:
```python
with dc.context():
a = mx.np.arange(10)
a[:5] = 0
```
----------------------------------------------------------------
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