Repository: microsoft/onnxruntime
File: onnxruntime/test/providers/cpu/reduction/reduction_ops_test.cc (C++)

Code before:
}

TEST(ReductionOpTest, empty_set_ReduceSumSquare_13) {
  test_empty_set("ReduceSumSquare", 13, false, 0.0f);
}

TEST(ReductionOpTest, MissingOptionalAxes) {
  OpTester test("ReduceMax", 18);
  test.AddInput<float>("data", {2, 2},
                       {1.0f, 4.0f,
                        3.0f, 2.0f});
  test.AddOptionalInputEdge<int64_t>();
  test.AddOutput<float>("reduced", {1, 1}, {4.0f});

  // OpenVINO doesn't support "axes" input
  test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kOpenVINOExecutionProvider});
}

TEST(ReductionOpTest, ReduceSumSquare_NoopWithEmptyAxes_Scalar) {
  OpTester test("ReduceSumSquare", 18);
  test.AddInput<float>("data", {}, {-3.f});
  test.AddInput<int64_t>("axes", {0}, {}, true);
  test.AddAttribute<int64_t>("noop_with_empty_axes", 1);
  test.AddOutput<float>("reduced", {}, {9.f});
  auto cpu = DefaultCpuExecutionProvider();
  if (!cpu) GTEST_SKIP() << "CPU EP not available in this build.";
  test.ConfigEp(std::move(cpu)).RunWithConfig();
}
TEST(ReductionOpTest, ReduceSumSquare_NoopWithEmptyAxes_ElementwiseSquare) {
  OpTester test("ReduceSumSquare", 18);
  test.AddInput<float>("data", {2}, {2.f, 3.f});
  test.AddInput<int64_t>("axes", {0}, {}, true);
  test.AddAttribute<int64_t>("noop_with_empty_axes", 1);
  test.AddOutput<float>("reduced", {2}, {4.f, 9.f});
  auto cpu = DefaultCpuExecutionProvider();
  if (!cpu) GTEST_SKIP() << "CPU EP not available in this build.";
  test.ConfigEp(std::move(cpu)).RunWithConfig();
}
TEST(ReductionOpTest, ReduceSumSquare_NoopWithEmptyAxes_2D_ElementwiseSquare) {
  OpTester test("ReduceSumSquare", 18);
  test.AddInput<float>("data", {2, 3}, {-1.f, 2.f, -3.f, 0.5f, -0.5f, 4.f});
  test.AddInput<int64_t>("axes", {0}, {}, true);
  test.AddAttribute<int64_t>("noop_with_empty_axes", 1);
  test.AddOutput<float>("reduced", {2, 3}, {1.f, 4.f, 9.f, 0.25f, 0.25f, 16.f});
  auto cpu = DefaultCpuExecutionProvider();
  if (!cpu) GTEST_SKIP() << "CPU EP not available in this build.";
  test.ConfigEp(std::move(cpu)).RunWithConfig();
}
TEST(ReductionOpTest, ReduceSumSquare_NoopWithEmptyAxes_3D_ElementwiseSquare) {
  OpTester test("ReduceSumSquare", 18);
  test.AddInput<float>("data", {2, 1, 3}, {-1.f, 2.f, -3.f, 0.5f, -0.5f, 4.f});

Review comment (suggestion):
```suggestion

TEST(ReductionOpTest, ReduceSumSquare_NoopWithEmptyAxes_ElementwiseSquare) {
```
(consistency nit) All the above functions have a blank line separating them, like between ReduceMax_noop_axes_input_initializer_opset_18 and ReduceMax_empty_axes_input_initializer_opset_18. #Resolved

Code after:
TEST(ReductionOpTest, empty_set_ReduceSumSquare_13) {
  test_empty_set("ReduceSumSquare", 13, false, 0.0f);
}

TEST(ReductionOpTest, MissingOptionalAxes) {
  OpTester test("ReduceMax", 18);
  test.AddInput<float>("data", {2, 2},
                       {1.0f, 4.0f,
                        3.0f, 2.0f});
  test.AddOptionalInputEdge<int64_t>();
  test.AddOutput<float>("reduced", {1, 1}, {4.0f});

  // OpenVINO doesn't support "axes" input
  test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kOpenVINOExecutionProvider});
}

TEST(ReductionOpTest, ReduceSumSquare_NoopWithEmptyAxes_Scalar) {
  OpTester test("ReduceSumSquare", 18);
  test.AddInput<float>("data", {}, {-3.f});
  test.AddInput<int64_t>("axes", {0}, {}, true);
  test.AddAttribute<int64_t>("noop_with_empty_axes", 1);
  test.AddOutput<float>("reduced", {}, {9.f});
  test.ConfigEp(DefaultCpuExecutionProvider()).RunWithConfig();
}

TEST(ReductionOpTest, ReduceSumSquare_NoopWithEmptyAxes_ElementwiseSquare) {
  OpTester test("ReduceSumSquare", 18);
  test.AddInput<float>("data", {2}, {2.f, 3.f});
  test.AddInput<int64_t>("axes", {0}, {}, true);
  test.AddAttribute<int64_t>("noop_with_empty_axes", 1);
  test.AddOutput<float>("reduced", {2}, {4.f, 9.f});
  test.ConfigEp(DefaultCpuExecutionProvider()).RunWithConfig();
}

TEST(ReductionOpTest, ReduceSumSquare_NoopWithEmptyAxes_2D_ElementwiseSquare) {
  OpTester test("ReduceSumSquare", 18);
  test.AddInput<float>("data", {2, 3}, {-1.f, 2.f, -3.f, 0.5f, -0.5f, 4.f});
  test.AddInput<int64_t>("axes", {0}, {}, true);
  test.AddAttribute<int64_t>("noop_with_empty_axes", 1);
  test.AddOutput<float>("reduced", {2, 3}, {1.f, 4.f, 9.f, 0.25f, 0.25f, 16.f});
  test.ConfigEp(DefaultCpuExecutionProvider()).RunWithConfig();
}

TEST(ReductionOpTest, ReduceSumSquare_NoopWithEmptyAxes_3D_ElementwiseSquare) {
  OpTester test("ReduceSumSquare", 18);
  test.AddInput<float>("data", {2, 1, 3}, {-1.f, 2.f, -3.f, 0.5f, -0.5f, 4.f});
  test.AddInput<int64_t>("axes", {0}, {}, true);
  test.AddAttribute<int64_t>("noop_with_empty_axes", 1);
  test.AddOutput<float>("reduced", {2, 1, 3}, {1.f, 4.f, 9.f, 0.25f, 0.25f, 16.f});
  test.ConfigEp(DefaultCpuExecutionProvider()).RunWithConfig();
}