Log warning when GetGradientForOp() silently fails. (#6586)

* Add warning when GetGradientForOp() silently fails.

In some cases, `GetGradientForOp()` can return without creating any nodes, which may lead to an invalid graph being created.
This commit is contained in:
Derek Murray 2021-02-10 10:01:16 -08:00 committed by GitHub
parent b09bfc8611
commit 88d48063fa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -211,7 +211,11 @@ Status GradientGraphBuilder::Build(const std::unordered_set<std::string>* p_init
}
GradientDef node_defs = GetGradientForOp(gradient_graph_config_, graph_, node, output_args_need_grad, input_args_need_grad, logger_);
if (node_defs.empty()) {
LOGS(logger_, WARNING) << "GetGradientForOp() did not create any nodes for node "
<< node->Name() << " of type " << node->OpType() << ".";
}
// updates arg name if gradient accumulation is needed
for (auto& op_def : node_defs) {
for (auto& arg : op_def.output_args) {