audit and update error messages in tensor_tracer_report.py
PiperOrigin-RevId: 389059305
Change-Id: Ifb5c702c5013d9a86476ef12adaebc20e61354ed
diff --git a/tensorflow/python/tpu/tensor_tracer_report.py b/tensorflow/python/tpu/tensor_tracer_report.py
index 7eabfc3..e8d86a7 100644
--- a/tensorflow/python/tpu/tensor_tracer_report.py
+++ b/tensorflow/python/tpu/tensor_tracer_report.py
@@ -159,20 +159,26 @@
for out_tensor in self.traced_tensors:
tensor_name = out_tensor.name
if tensor_name in self.tensorname_to_cache_idx:
- raise ValueError(
- 'Tensor name %s should not be already in '
- 'tensorname_to_cache_idx'%tensor_name)
+ raise ValueError('Tensor name {} should not be already in '
+ 'tensorname_to_cache_idx'.format(tensor_name))
if tensor_name not in self.graph_order.tensor_to_idx:
raise ValueError(
- 'Tensor name %s is not in the tensor_to_idx'%tensor_name)
+ 'Tensor name {} is not in the tensor_to_idx, tensor_to_idx={} '
+ .format(tensor_name, self.graph_order.tensor_to_idx))
tensor_idx = self.graph_order.tensor_to_idx[tensor_name]
cache_idx = len(self.tensorname_to_cache_idx)
self.tensorname_to_cache_idx[tensor_name] = cache_idx
self.cache_idx_to_tensor_idx.append(tensor_idx)
if len(self.tensorname_to_cache_idx) != len(
self.cache_idx_to_tensor_idx):
- raise RuntimeError('len(self.tensorname_to_cache_idx) != '
- 'len(self.cache_idx_to_tensor_idx')
+ raise RuntimeError(
+ 'len(self.tensorname_to_cache_idx) must equal'
+ 'len(self.cache_idx_to_tensor_idx), got '
+ 'len(self.tensorname_to_cache_idx)={}, '
+ 'len(self.cache_idx_to_tensor_idx)={}'
+ .format(
+ len(self.tensorname_to_cache_idx),
+ len(self.cache_idx_to_tensor_idx)))
def sort_tensors_and_ops(graph):
@@ -376,7 +382,9 @@
for out_tensor in op.outputs:
if out_tensor.name not in graph_order.tensor_to_idx:
raise ValueError(
- 'out_tensor %s is not in tensor_to_idx'%out_tensor.name)
+ 'out_tensor is not in tensor_to_idx. out_tensor={}, '
+ 'tensor_to_idx={}'
+ .format(out_tensor.name, graph_order.tensor_to_idx))
line += ' %d'%graph_order.tensor_to_idx[out_tensor.name]
line += '\n'
self._write_report(line)
@@ -397,7 +405,9 @@
for consumer_op in consumers:
if consumer_op.name not in graph_order.op_to_idx:
raise ValueError(
- 'consumer_op %s is not in op_to_idx'%consumer_op.name)
+ 'consumer_op is not in op_to_idx. '
+ 'got consumer_op={}, op_to_idx={}'
+ .format(consumer_op.name, graph_order.op_to_idx))
line += ' %d'%graph_order.op_to_idx[consumer_op.name]
line += '\n'
self._write_report(line)