barry-jin commented on a change in pull request #20462:
URL: https://github.com/apache/incubator-mxnet/pull/20462#discussion_r673515352
##########
File path: src/imperative/cached_op.cc
##########
@@ -989,7 +991,12 @@ void CachedOp::StaticBackward(
auto entry = state.info.grad_graph.outputs[iter->second];
if (!idx.exist(entry.node.get())) continue;
auto eid = idx.entry_id(entry);
- state.array_reqs[eid] = reqs[iter->second];
+ // if ref count is not 0, then we should not assign req user provide
+ if (reqs[iter->second] == kNullOp && !(ref_count[eid] == 0)) {
+ state.array_reqs[eid] = kWriteTo;
Review comment:
Yes, we need to put `kWriteTo` here. Because memory plan already happens
in
[SetBackwardGraph](https://github.com/apache/incubator-mxnet/blob/3480ba2c6df02bb907d3a975d354efa8697c4e71/src/imperative/cached_op.cc#L259)
before this. Here we get the updated ref_count from the graph and modify the
req_types based on the ref_count.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]