message: Add unit test for reduction remover when reduction dimension is empty
diff: @@ -69,6 +69,36 @@ ENTRY main {
  )");
  }
  +TEST_F(ReductionDegenerateDimRemoverTest, DegenerateWithEmptyDimension) {
  + const char* hlo_text = R"(
  +HloModule ReduceWithDegenerateDimensions
  +
  +add {
  + accum = f32[] parameter(0)
  + op = f32[] parameter(1)
  + ROOT out = f32[] add(accum, op)
  +}
  +
  +ENTRY main {
  + input = f32[1,3,1,4,1,5,1] parameter(0)
  + zero = f32[] constant(0)
  +
  + ROOT out = f32[3,4,5,1] reduce(input, zero), dimensions={0,2,4}, to_apply=add
  +}
  +
  +)";
  +
  + EXPECT_TRUE(RunAndCompare(hlo_text, ErrorSpec{1e-5, 1e-5}));
  + // Copy insertion
  + MatchOptimizedHloWithShapes(hlo_text,
  + R"(
  +// CHECK: ENTRY %main (input: f32[1,3,1,4,1,5,1]) -> f32[3,4,5,1] {
  +// CHECK: %input = f32[1,3,1,4,1,5,1]{6,5,4,3,2,1,0} parameter(0)
  +// CHECK: %bitcast{{.+}} = f32[3,4,5,1]{3,2,1,0} bitcast(f32[1,3,1,4,1,5,1]{6,5,4,3,2,1,0} %input)
  +// CHECK: ROOT %copy{{.+}} = f32[3,4,5,1]{3,2,1,0} copy(f32[3,4,5,1]{3,2,1,0} %bitcast{{.+}})
  + )");
  +}
  +
  } // namespace
  } // namespace gpu
  } // namespace xla
  