File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed
paddle/fluid/framework/ir Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -117,7 +117,15 @@ Graph::Graph(const ProgramDesc &program) : program_(program) {
117
117
}
118
118
// For output args, always create a new var.
119
119
for (auto &each_var_name : op->OutputArgumentNames ()) {
120
- ir::Node *var = CreateVarNode (all_vars.at (each_var_name));
120
+ ir::Node *var = nullptr ;
121
+ if (all_vars.count (each_var_name) != 0 ) {
122
+ var = CreateVarNode (all_vars.at (each_var_name));
123
+ } else {
124
+ // Operation output vars can be @EMPTY@. For example, while_grad
125
+ // can have multi @EMPTY@ outputs with no VarDesc.
126
+ // TODO(panyx0718): Add a test.
127
+ var = CreateEmptyNode (each_var_name, ir::Node::Type::kVariable );
128
+ }
121
129
var_nodes[each_var_name].push_back (var);
122
130
node->outputs .push_back (var);
123
131
var->inputs .push_back (node);
@@ -208,7 +216,8 @@ Graph::Graph(const ProgramDesc &program) : program_(program) {
208
216
// Add write after write dependence
209
217
ir::Node *upstream_op =
210
218
(*it_old)->inputs .empty () ? nullptr : (*it_old)->inputs [0 ];
211
- if (upstream_op) {
219
+ // TODO(zcd): Add a test.
220
+ if (upstream_op && upstream_op != write_op) {
212
221
ir::Node *dep_var = CreateControlDepVar ();
213
222
write_op->inputs .push_back (dep_var);
214
223
upstream_op->outputs .push_back (dep_var);
You can’t perform that action at this time.
0 commit comments