From 5f5d1433f9b75464d748f553128e37e36ab55c12 Mon Sep 17 00:00:00 2001 From: Bixia Zheng Date: Thu, 23 May 2024 10:21:25 -0700 Subject: [PATCH] [xla] Move the shape check in HloReshapeInstruction constructor back to CreateReshape. PiperOrigin-RevId: 636593668 --- third_party/xla/xla/hlo/ir/hlo_instruction.cc | 5 +++++ third_party/xla/xla/hlo/ir/hlo_instructions.cc | 5 ----- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/third_party/xla/xla/hlo/ir/hlo_instruction.cc b/third_party/xla/xla/hlo/ir/hlo_instruction.cc index 992761fedce34e..422071b090e6df 100644 --- a/third_party/xla/xla/hlo/ir/hlo_instruction.cc +++ b/third_party/xla/xla/hlo/ir/hlo_instruction.cc @@ -2098,6 +2098,11 @@ HloInstruction::CreateBroadcastSequence( /* static */ std::unique_ptr HloInstruction::CreateReshape( const Shape& shape, HloInstruction* operand, int64_t inferred_dimension) { + CHECK(operand->shape().is_unbounded_dynamic() || + ShapeUtil::StaticExtentProduct(shape) == + ShapeUtil::StaticExtentProduct(operand->shape())) + << "shape: " << ShapeUtil::HumanString(shape) + << " operand: " << ShapeUtil::HumanString(operand->shape()); return std::make_unique(shape, operand, inferred_dimension); } diff --git a/third_party/xla/xla/hlo/ir/hlo_instructions.cc b/third_party/xla/xla/hlo/ir/hlo_instructions.cc index 9439fcd81f2b99..143eaafc1363e3 100644 --- a/third_party/xla/xla/hlo/ir/hlo_instructions.cc +++ b/third_party/xla/xla/hlo/ir/hlo_instructions.cc @@ -1555,11 +1555,6 @@ HloReshapeInstruction::HloReshapeInstruction(const Shape& shape, int64_t inferred_dimension) : HloInstruction(HloOpcode::kReshape, shape), inferred_dimension_(inferred_dimension) { - CHECK(operand->shape().is_unbounded_dynamic() || - ShapeUtil::StaticExtentProduct(shape) == - ShapeUtil::StaticExtentProduct(operand->shape())) - << "shape: " << ShapeUtil::HumanString(shape) - << " operand: " << ShapeUtil::HumanString(operand->shape()); AppendOperand(operand); }