[TEST] One more ReduceSUM func test
authorAlexander Peskov <alexander.peskov@intel.com>
Sun, 6 Sep 2020 23:47:14 +0000 (02:47 +0300)
committerAlexander Peskov <alexander.peskov@intel.com>
Wed, 9 Sep 2020 09:41:31 +0000 (12:41 +0300)
Special test case with input values which cannot be correctly processed via
decomposition with int AVG pool layer.

Signed-off-by: Alexander Peskov <alexander.peskov@intel.com>
inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/reduce_ops.cpp
inference-engine/tests/functional/plugin/shared/include/single_layer_tests/reduce_ops.hpp
inference-engine/tests/functional/plugin/shared/src/single_layer_tests/reduce_ops.cpp

index 3708798..0c10a69 100644 (file)
@@ -152,4 +152,20 @@ INSTANTIATE_TEST_CASE_P(
         params_ReductionTypes,
         ReduceOpsLayerTest::getTestCaseName
 );
+
+INSTANTIATE_TEST_CASE_P(
+        Reduce,
+        ReduceOpsLayerWithSpecificInputTest,
+        testing::Combine(
+                testing::ValuesIn(decltype(axes) {{0}, {1}}),
+                testing::Values(opTypes[1]),
+                testing::Values(true),
+                testing::Values(ngraph::helpers::ReductionType::Sum),
+                testing::Values(InferenceEngine::Precision::FP32,
+                                InferenceEngine::Precision::I32),
+                testing::Values(std::vector<size_t> {2, 10}),
+                testing::Values(CommonTestUtils::DEVICE_CPU)),
+        ReduceOpsLayerWithSpecificInputTest::getTestCaseName
+);
+
 }  // namespace
index ccbdad9..0b5ce1b 100644 (file)
@@ -34,4 +34,9 @@ protected:
     void SetUp() override;
 };
 
+class ReduceOpsLayerWithSpecificInputTest : public ReduceOpsLayerTest {
+protected:
+    InferenceEngine::Blob::Ptr GenerateInput(const InferenceEngine::InputInfo &info) const override;
+};
+
 }  // namespace LayerTestsDefinitions
\ No newline at end of file
index df62665..7191be4 100644 (file)
@@ -80,6 +80,28 @@ void ReduceOpsLayerTest::SetUp() {
 
 TEST_P(ReduceOpsLayerTest, CompareWithRefs) {
     Run();
-};
+}
+
+InferenceEngine::Blob::Ptr ReduceOpsLayerWithSpecificInputTest::GenerateInput(const InferenceEngine::InputInfo &info) const {
+    auto axis_vec = std::get<0>(GetParam());
+    IE_ASSERT(axis_vec.size() == 1);
+
+    auto axis = axis_vec[0];
+    auto td = info.getTensorDesc();
+    auto dims = td.getDims();
+
+    // Slice of tensor through axis is {1, 0, 0, ....}, the mean value is 1/slice_size
+    auto raw_values = std::vector<float>(dims[axis], 0);
+    raw_values[0] = 1;
+
+    auto blob = make_blob_with_precision(td);
+    blob->allocate();
+    CommonTestUtils::fill_data_with_broadcast(blob, axis, raw_values);
+    return blob;
+}
+
+TEST_P(ReduceOpsLayerWithSpecificInputTest, CompareWithRefs) {
+    Run();
+}
 
 }  // namespace LayerTestsDefinitions
\ No newline at end of file