aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/compiler/xla/service/hlo_evaluator.cc
diff options
context:
space:
mode:
authorGravatar Justin Lebar <jlebar@google.com>2018-09-09 10:47:00 -0700
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2018-09-09 10:51:12 -0700
commit0b90eec6e16238198ffd0ff0011e0f6f33f4038d (patch)
tree2da377bda852931538b98cab8f475570f1c72ae2 /tensorflow/compiler/xla/service/hlo_evaluator.cc
parentb40ace8f28315431e3435647ce39cc7b24c20bfd (diff)
[XLA] Improve error message in HLO evaluator for illegal broadcast.
PiperOrigin-RevId: 212185352
Diffstat (limited to 'tensorflow/compiler/xla/service/hlo_evaluator.cc')
-rw-r--r--tensorflow/compiler/xla/service/hlo_evaluator.cc10
1 files changed, 8 insertions, 2 deletions
diff --git a/tensorflow/compiler/xla/service/hlo_evaluator.cc b/tensorflow/compiler/xla/service/hlo_evaluator.cc
index d0d955fea8..a2f683b690 100644
--- a/tensorflow/compiler/xla/service/hlo_evaluator.cc
+++ b/tensorflow/compiler/xla/service/hlo_evaluator.cc
@@ -940,8 +940,14 @@ Status HloEvaluator::HandleBroadcast(HloInstruction* broadcast) {
// Checks that operand's dimensions are the same as the broadcast's
// dimensions along the dimensions to be broadcasted.
for (int64 i = 0; i < broadcast->dimensions().size(); ++i) {
- TF_RET_CHECK(broadcast->shape().dimensions(broadcast->dimensions(i)) ==
- operand.shape().dimensions(i));
+ auto operand_dim_size = operand.shape().dimensions(i);
+ auto broadcast_dim_size =
+ broadcast->shape().dimensions(broadcast->dimensions(i));
+ TF_RET_CHECK(operand_dim_size == broadcast_dim_size) << absl::StreamFormat(
+ "Operand dimension %d is broadcast to output dimension %d, but the "
+ "sizes of these two dims do not match (%d vs %d): %s",
+ i, broadcast->dimensions(i), operand_dim_size, broadcast_dim_size,
+ broadcast->ToString());
}
TF_ASSIGN_OR_RETURN(