From: A. Unique TensorFlower Date: Wed, 9 May 2018 17:38:18 +0000 (-0700) Subject: Fix a bug of literal prints in hlo_graph_dumper X-Git-Tag: upstream/v1.9.0_rc1~116^2^2~207 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=46b86643aad647a59e8acdd0bb174650740ac041;p=platform%2Fupstream%2Ftensorflow.git Fix a bug of literal prints in hlo_graph_dumper Sigterm was raised when no literal info is associated with constant instructions in HloProto. PiperOrigin-RevId: 195992305 --- diff --git a/tensorflow/compiler/xla/service/hlo_graph_dumper.cc b/tensorflow/compiler/xla/service/hlo_graph_dumper.cc index b6b0387..55911ac 100644 --- a/tensorflow/compiler/xla/service/hlo_graph_dumper.cc +++ b/tensorflow/compiler/xla/service/hlo_graph_dumper.cc @@ -825,7 +825,7 @@ string HloDotDumper::GetInstructionNodeInlinedOperands( *elem_count *= dim; } } - if (elem_count.has_value() && *elem_count <= 8) { + if (elem_count.has_value() && *elem_count <= 8 && constant->HasLiteral()) { return Printf("%s (%s)", constant->literal().ToString(), ShapeUtil::HumanString(constant->shape())); } diff --git a/tensorflow/compiler/xla/service/hlo_instruction.cc b/tensorflow/compiler/xla/service/hlo_instruction.cc index 857cd39..03e0391 100644 --- a/tensorflow/compiler/xla/service/hlo_instruction.cc +++ b/tensorflow/compiler/xla/service/hlo_instruction.cc @@ -1557,6 +1557,8 @@ const Literal& HloInstruction::literal() const { return *literal_; } +bool HloInstruction::HasLiteral() const { return literal_ != nullptr; } + bool HloInstruction::CanHaveDimensionsField() const { return (opcode() == HloOpcode::kReverse || opcode() == HloOpcode::kConcatenate || diff --git a/tensorflow/compiler/xla/service/hlo_instruction.h b/tensorflow/compiler/xla/service/hlo_instruction.h index 14be58d..511227a 100644 --- a/tensorflow/compiler/xla/service/hlo_instruction.h +++ b/tensorflow/compiler/xla/service/hlo_instruction.h @@ -706,6 +706,9 @@ class HloInstruction { // Note: only constant and parameter opcodes have an associated literal. const Literal& literal() const; + // Returns whether there is literal associated with this instruction. + bool HasLiteral() const; + // Returns the parameter number associated with this instruction. // // Note: only parameter opcodes have an associated parameter number.