aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/compiler/xla/service/zero_sized_hlo_elimination.cc
diff options
context:
space:
mode:
authorGravatar Mark Heffernan <meheff@google.com>2018-06-13 14:19:39 -0700
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2018-06-13 14:24:30 -0700
commite1296c15a32cac020160a1c89002dc561333c66b (patch)
tree62ef334470d3484d166ea583eddea10fc24d1718 /tensorflow/compiler/xla/service/zero_sized_hlo_elimination.cc
parentbf920de58a3ccb2cfe6642be9c487c3fcb13ccae (diff)
Fix assumptions that a Shape must be a tuple or an array.
A TOKEN primitive type was added with cl/199215963 and XLA also has an OPAQUE primitive type. However, in many places in XLA we assume either a tuple or array. This CL fixes many of those instances, but some may remain. Identified instances were discovered by searching for IsTuple or IsArray so the set of fixes is not exhaustive. Also opportunistically addressed a couple potential points of confusion in the ShapeUtil interface: (1) Rename ShapeUtil::HasZeroElements to ShapeUtil::IsZeroElementArray. The point of confusion here is that tuples can also have zero elements and HasZeroElements would check fail on tuple shapes. Method no longer check fails if the given shape is not an array. (2) ShapeUtil::IsNil now returns true only for empty tuples. Previously it also returned true for zero-element array types which was confusing because ShapeUtil::MakeNil creates an empty tuple. PiperOrigin-RevId: 200452672
Diffstat (limited to 'tensorflow/compiler/xla/service/zero_sized_hlo_elimination.cc')
-rw-r--r--tensorflow/compiler/xla/service/zero_sized_hlo_elimination.cc4
1 files changed, 2 insertions, 2 deletions
diff --git a/tensorflow/compiler/xla/service/zero_sized_hlo_elimination.cc b/tensorflow/compiler/xla/service/zero_sized_hlo_elimination.cc
index aa40b5cb26..44b0ec5cd4 100644
--- a/tensorflow/compiler/xla/service/zero_sized_hlo_elimination.cc
+++ b/tensorflow/compiler/xla/service/zero_sized_hlo_elimination.cc
@@ -32,11 +32,11 @@ StatusOr<bool> ZeroSizedHloElimination::Run(HloModule* module) {
for (HloComputation* comp : module->MakeNonfusionComputations()) {
for (HloInstruction* instruction : comp->MakeInstructionPostOrder()) {
if (instruction->HasSideEffect() ||
- ShapeUtil::IsTuple(instruction->shape())) {
+ !ShapeUtil::IsArray(instruction->shape())) {
continue;
}
if (comp->IsRemovable(instruction) &&
- ShapeUtil::HasZeroElements(instruction->shape())) {
+ ShapeUtil::IsZeroElementArray(instruction->shape())) {
TF_RETURN_IF_ERROR(comp->ReplaceWithNewInstruction(
instruction, HloInstruction::CreateConstant(
Literal::CreateFromShape(instruction->shape()))));