From 4c0721928b949ea67ea3f47650c7a65afe9611c5 Mon Sep 17 00:00:00 2001 From: Yunxing Dai Date: Wed, 18 Dec 2019 22:18:58 -0800 Subject: [PATCH] [XLA] Remove use of designated initializers in dynamic dimension inference. PiperOrigin-RevId: 286330416 Change-Id: I5878ab23b9596ac0c5dbf91394ee6ba8e5683c77 --- .../xla/service/dynamic_dimension_inference.cc | 14 +++++++------- .../xla/service/dynamic_dimension_inference.h | 3 +++ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/tensorflow/compiler/xla/service/dynamic_dimension_inference.cc b/tensorflow/compiler/xla/service/dynamic_dimension_inference.cc index e93e234f3db..d58c9ce0e47 100644 --- a/tensorflow/compiler/xla/service/dynamic_dimension_inference.cc +++ b/tensorflow/compiler/xla/service/dynamic_dimension_inference.cc @@ -469,7 +469,7 @@ Status DynamicDimensionInferenceVisitor::HandleSetDimensionSize( // Propagate dynamic dimension indicated by this set dimension size // instruction. parent_->SetDynamicSize(hlo, {}, hlo->dimension(), hlo->mutable_operand(1), - {.stride = 1, .multiple_of = 1}); + DimensionConstraint(1, 1)); } // Also Propagate dynamic dimension already set by operands. @@ -813,7 +813,7 @@ Status DynamicDimensionInferenceVisitor::HandleReshape(HloInstruction* hlo) { parent_->SetDynamicSize( reshape, {}, output_dynamic_dimension, new_dynamic_size, - {.stride = 1, .multiple_of = constraint.multiple_of / divisor}); + DimensionConstraint(1, constraint.multiple_of / divisor)); } if (input_dim_size < output_dim_size) { @@ -850,12 +850,12 @@ Status DynamicDimensionInferenceVisitor::HandleReshape(HloInstruction* hlo) { hlo->parent()->AddInstruction(HloInstruction::CreateBinary( output_dynamic_size->shape(), HloOpcode::kMultiply, new_dynamic_size, operand_dynamic_size)); + int64 new_multiple_of_constraint = + constraint.multiple_of * output_dim_size / + operand->shape().dimensions(input_dynamic_dimension); parent_->SetDynamicSize( reshape, {}, output_dynamic_dimension, new_dynamic_size, - {.stride = 1, - .multiple_of = - constraint.multiple_of * output_dim_size / - operand->shape().dimensions(input_dynamic_dimension)}); + DimensionConstraint(1, new_multiple_of_constraint)); } return Status::OK(); @@ -1227,7 +1227,7 @@ Status DynamicDimensionInferenceVisitor::HandleParameter(HloInstruction* hlo) { parent_->SetDynamicSize(target_parameter, dynamic_dimension.parameter_index, dynamic_dimension.dimension, dynamic_size, - {.stride = 1, .multiple_of = 1}); + DimensionConstraint(1, 1)); return Status::OK(); }); } diff --git a/tensorflow/compiler/xla/service/dynamic_dimension_inference.h b/tensorflow/compiler/xla/service/dynamic_dimension_inference.h index 21808385ec2..070127796d6 100644 --- a/tensorflow/compiler/xla/service/dynamic_dimension_inference.h +++ b/tensorflow/compiler/xla/service/dynamic_dimension_inference.h @@ -149,6 +149,9 @@ class DynamicDimensionInference { // // struct DimensionConstraint { + explicit DimensionConstraint(int64 s, int64 m) + : stride(s), multiple_of(m) {} + DimensionConstraint() : stride(1), multiple_of(1) {} // Stride represents the distance of a newly placed element and the previous // placed element on this dynamic dimension. int64 stride;