提交 4bf9ea42 编写于 作者: B Blake Hechtman 提交者: TensorFlower Gardener

[XLA] Just use ShapeUtil::AlignLayouts for reshape layout selection.

PiperOrigin-RevId: 235138912
上级 057117af
...@@ -1019,16 +1019,6 @@ std::unique_ptr<Layout> LayoutAssignment::ChooseOperandLayoutFromOutputLayout( ...@@ -1019,16 +1019,6 @@ std::unique_ptr<Layout> LayoutAssignment::ChooseOperandLayoutFromOutputLayout(
Shape operand_shape = operand->shape(); Shape operand_shape = operand->shape();
*operand_shape.mutable_layout() = *operand_shape.mutable_layout() =
LayoutUtil::GetDefaultLayoutForShape(operand_shape); LayoutUtil::GetDefaultLayoutForShape(operand_shape);
if (ShapeUtil::ReshapeIsBitcast(operand_shape, output_shape_with_layout)) {
return absl::make_unique<Layout>(operand_shape.layout());
}
if (operand_shape.rank() == output_shape.rank()) {
*operand_shape.mutable_layout() = output_layout;
if (ShapeUtil::ReshapeIsBitcast(operand_shape,
output_shape_with_layout)) {
return absl::make_unique<Layout>(output_layout);
}
}
auto aligned_operand_shape = auto aligned_operand_shape =
ShapeUtil::AlignLayouts(output_shape_with_layout, operand_shape); ShapeUtil::AlignLayouts(output_shape_with_layout, operand_shape);
if (aligned_operand_shape) { if (aligned_operand_shape) {
...@@ -1090,16 +1080,6 @@ std::unique_ptr<Layout> LayoutAssignment::ChooseOutputLayoutFromOperandLayout( ...@@ -1090,16 +1080,6 @@ std::unique_ptr<Layout> LayoutAssignment::ChooseOutputLayoutFromOperandLayout(
Shape output_shape = user->shape(); Shape output_shape = user->shape();
*output_shape.mutable_layout() = *output_shape.mutable_layout() =
LayoutUtil::GetDefaultLayoutForShape(output_shape); LayoutUtil::GetDefaultLayoutForShape(output_shape);
if (ShapeUtil::ReshapeIsBitcast(output_shape, operand_shape_with_layout)) {
return absl::make_unique<Layout>(output_shape.layout());
}
if (operand->shape().rank() == output_shape.rank()) {
*output_shape.mutable_layout() = operand_layout;
if (ShapeUtil::ReshapeIsBitcast(output_shape,
operand_shape_with_layout)) {
return absl::make_unique<Layout>(operand_layout);
}
}
auto aligned_user_shape = auto aligned_user_shape =
ShapeUtil::AlignLayouts(operand_shape_with_layout, output_shape); ShapeUtil::AlignLayouts(operand_shape_with_layout, output_shape);
if (aligned_user_shape) { if (aligned_user_shape) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册