Print out the deadness predicate on a mismatch

PiperOrigin-RevId: 248610290
This commit is contained in:
Sanjoy Das 2019-05-16 15:17:49 -07:00 committed by TensorFlower Gardener
parent 220e8e059a
commit eb2d84f659
3 changed files with 22 additions and 4 deletions

View File

@ -1188,4 +1188,8 @@ Status ComputePredicates(const Graph& graph,
}
} // namespace deadness_analysis_internal
string DeadnessAnalysis::DebugString(DeadnessPredicate predicate) const {
return static_cast<Predicate*>(predicate.pred_)->ToString();
}
} // namespace tensorflow

View File

@ -82,6 +82,8 @@ class DeadnessAnalysis {
virtual void Print() const = 0;
virtual ~DeadnessAnalysis();
string DebugString(DeadnessPredicate predicate) const;
// Run the deadness analysis over `graph` and returns an error or a populated
// instance of DeadnessAnalysis in `result`.
static Status Run(const Graph& graph,

View File

@ -401,6 +401,13 @@ class MarkForCompilationPassImpl {
return true;
}
string EdgeContractionFailureMsg(Cluster* from, Cluster* to,
absl::string_view reason) {
return absl::StrCat("Could not contract ", from->DebugString(*graph_),
" -> ", to->DebugString(*graph_), " because ", reason,
".");
}
DebugOptions debug_options_;
Graph* graph_;
FunctionLibraryDefinition* flib_def_;
@ -1067,8 +1074,7 @@ bool MarkForCompilationPassImpl::CompilationDisallowedByXlaCompileAttr(
bool MarkForCompilationPassImpl::LogNotContractableAndReturnFalse(
Cluster* from, Cluster* to, absl::string_view reason) {
VLOG(3) << "Could not contract " << from->DebugString(*graph_) << " -> "
<< to->DebugString(*graph_) << " because " << reason << ".";
VLOG(3) << EdgeContractionFailureMsg(from, to, reason);
return false;
}
@ -1077,8 +1083,14 @@ StatusOr<bool> MarkForCompilationPassImpl::TryToContractEdge(Cluster* from,
DCHECK(from->deadness_predicate().has_value() ==
to->deadness_predicate().has_value());
if (from->deadness_predicate() != to->deadness_predicate()) {
return LogNotContractableAndReturnFalse(
from, to, "the two nodes have mismatching deadness");
VLOG(3) << EdgeContractionFailureMsg(
from, to,
absl::StrCat(
"the two nodes have mismatching deadness: ",
deadness_analysis_->DebugString(*from->deadness_predicate()),
" and ",
deadness_analysis_->DebugString(*to->deadness_predicate())));
return false;
}
TF_ASSIGN_OR_RETURN(bool devices_compatible,