@@ -708,7 +708,8 @@ ENTRY entry {
708708 token.0 = token[] after-all()
709709 data = (f32[1024,2]{1,0}, f32[2]{0}) parameter(0), sharding={{devices=[2,1]0,1},
710710 {devices=[2]0,1}}
711- ROOT outfeed = token[] outfeed(data, token.0), sharding={{devices=[2,1]0,1},
711+ ROOT outfeed = token[] outfeed(data, token.0),
712+ outfeed_shape=(f32[1024,2]{0,1}, f32[2]{0}), sharding={{devices=[2,1]0,1},
712713 {devices=[2]0,1}}
713714})" ;
714715 TF_ASSERT_OK_AND_ASSIGN (auto module ,
@@ -717,6 +718,12 @@ ENTRY entry {
717718 HloInstruction* root = module ->entry_computation ()->root_instruction ();
718719 EXPECT_THAT (root, AllOf (op::Shape (" token[]" ),
719720 op::Outfeed (op::Parameter (), op::AfterAll ())));
721+ auto expected_layout0 = LayoutUtil::MakeLayout ({0 , 1 });
722+ auto expected_layout1 = LayoutUtil::MakeLayout ({0 });
723+ EXPECT_TRUE (LayoutUtil::Equal (root->outfeed_shape ().tuple_shapes (0 ).layout (),
724+ expected_layout0));
725+ EXPECT_TRUE (LayoutUtil::Equal (root->outfeed_shape ().tuple_shapes (1 ).layout (),
726+ expected_layout1));
720727}
721728
722729TEST_F (SpmdPartitioningTest, OutfeedReplicated) {
@@ -746,7 +753,8 @@ ENTRY entry {
746753 token.0 = token[] after-all()
747754 data = (f32[1023,2]{1,0}, f32[3]{0}) parameter(0), sharding={{devices=[2,1]0,1},
748755 {devices=[2]0,1}}
749- outfeed = token[] outfeed(data, token.0), sharding={{devices=[2,1]0,1},
756+ outfeed = token[] outfeed(data, token.0),
757+ outfeed_shape=(f32[1023,2]{0,1}, f32[3]{0}), sharding={{devices=[2,1]0,1},
750758 {devices=[2]0,1}}
751759})" ;
752760 TF_ASSERT_OK_AND_ASSIGN (auto module ,
@@ -770,6 +778,24 @@ ENTRY entry {
770778 EXPECT_THAT (root->called_computations ()[1 ]->root_instruction (),
771779 AllOf (op::Shape (" token[]" ),
772780 op::Outfeed (second_outfeed, op::GetTupleElement ())));
781+
782+ auto expected_layout0 = LayoutUtil::MakeLayout ({0 , 1 });
783+ auto expected_layout1 = LayoutUtil::MakeLayout ({0 });
784+ auto first_outfeed_instr = root->called_computations ()[0 ]->root_instruction ();
785+ auto second_outfeed_instr =
786+ root->called_computations ()[1 ]->root_instruction ();
787+ EXPECT_TRUE (LayoutUtil::Equal (
788+ first_outfeed_instr->outfeed_shape ().tuple_shapes (0 ).layout (),
789+ expected_layout0));
790+ EXPECT_TRUE (LayoutUtil::Equal (
791+ first_outfeed_instr->outfeed_shape ().tuple_shapes (1 ).layout (),
792+ expected_layout1));
793+ EXPECT_TRUE (LayoutUtil::Equal (
794+ second_outfeed_instr->outfeed_shape ().tuple_shapes (0 ).layout (),
795+ expected_layout0));
796+ EXPECT_TRUE (LayoutUtil::Equal (
797+ second_outfeed_instr->outfeed_shape ().tuple_shapes (1 ).layout (),
798+ expected_layout1));
773799}
774800
775801TEST_F (SpmdPartitioningTest, ReduceWindowReplicatedInput) {
0 commit comments