| 81 | } |
| 82 | |
| 83 | TEST_F(StableSortExpanderTest, StabilizeSortReuseIotaOperand) { |
| 84 | const char* hlo_string = R"( |
| 85 | HloModule permutation_sort |
| 86 | |
| 87 | compare { |
| 88 | p.0.lhs = f32[] parameter(0) |
| 89 | p.0.rhs = f32[] parameter(1) |
| 90 | p.1.lhs = s32[] parameter(2) |
| 91 | p.1.rhs = s32[] parameter(3) |
| 92 | ROOT lt = pred[] compare(p.0.lhs, p.0.rhs), direction=LT |
| 93 | } |
| 94 | |
| 95 | ENTRY sort_computation { |
| 96 | keys = f32[64,8732]{1,0} parameter(0) |
| 97 | values = s32[64,8732]{1,0} iota(), iota_dimension=1 |
| 98 | sort = (f32[64,8732]{1,0}, s32[64,8732]{1,0}) sort(keys, values), |
| 99 | dimensions={1}, to_apply=compare, is_stable=true |
| 100 | ROOT gte = f32[64,8732]{1,0} get-tuple-element(sort), index=0 |
| 101 | })"; |
| 102 | TF_ASSERT_OK_AND_ASSIGN(auto module, |
| 103 | ParseAndReturnVerifiedModule(hlo_string)); |
| 104 | |
| 105 | StableSortExpander stabilizer; |
| 106 | EXPECT_TRUE(stabilizer.Run(module.get()).ValueOrDie()); |
| 107 | auto root = module->entry_computation()->root_instruction(); |
| 108 | EXPECT_THAT(root, GmockMatch(m::GetTupleElement( |
| 109 | m::Sort(m::Parameter(0), m::Iota()), 0))); |
| 110 | CheckComputationHasTieBreaker( |
| 111 | root->operand(0)->to_apply()->root_instruction(), /*iota_parameter=*/1); |
| 112 | } |
| 113 | |
| 114 | TEST_F(StableSortExpanderTest, |
| 115 | StabilizeSortReuseIotaOperandComplicatedComparison) { |
nothing calls this directly
no test coverage detected