[TF:TRT] Avoid null pointer accesses in TRTOptimizationPass::PrintDebugInfo.
Cluster::GetDeviceSet may return a null pointer. Skip printing the DeviceSet
when the routine returns nullptr. Move the printing of DeviceSet to closer to
the other information for the cluster and before the information for the
grappler item.
PiperOrigin-RevId: 321368504
Change-Id: Ic59c9f79fe759a40558fbf2377818e3d8999d752
diff --git a/tensorflow/compiler/tf2tensorrt/convert/trt_optimization_pass.cc b/tensorflow/compiler/tf2tensorrt/convert/trt_optimization_pass.cc
index 1cf98d1..4d6f8fa 100644
--- a/tensorflow/compiler/tf2tensorrt/convert/trt_optimization_pass.cc
+++ b/tensorflow/compiler/tf2tensorrt/convert/trt_optimization_pass.cc
@@ -86,6 +86,7 @@
string offset2 = StrCat(offset, offset);
string offset3 = StrCat(offset2, offset);
string offset4 = StrCat(offset2, offset2);
+
if (cluster) {
LOG(INFO) << offset << "type = " << cluster->type();
LOG(INFO) << offset << "num warmup steps = " << cluster->NumWarmupSteps();
@@ -132,7 +133,15 @@
}
}
}
+
+ if (cluster->GetDeviceSet()) {
+ for (const auto dev : cluster->GetDeviceSet()->devices()) {
+ LOG(INFO) << "Device name= " << dev->name() << "Pased name= "
+ << DeviceNameUtils::ParsedNameToString(dev->parsed_name());
+ }
+ }
}
+
LOG(INFO) << "item: " << item.id;
if (!item.feed.empty()) {
LOG(INFO) << offset << "Feeds :";
@@ -171,13 +180,6 @@
} else {
LOG(INFO) << offset << "No keep ops";
}
- for (const auto dev : cluster->GetDeviceSet()->devices()) {
- const auto& pname = dev->parsed_name();
- LOG(INFO) << "Device name= " << dev->name()
- << " parsedname job= " << pname.job << " id= " << pname.id
- << " has_id: " << pname.has_id << " has_job: " << pname.has_job
- << "has_type: " << pname.has_type << " type =" << pname.type;
- }
}
Status TRTOptimizationPass::Optimize(grappler::Cluster* cluster,