// // Copyright (C) 2021 Intel Corporation // // SPDX-License-Identifier: Apache-2.0 // // // #include // #include // #include // #include // #include // #include // #include // #include // #include // #include // #include "common_test_utils/ngraph_test_utils.hpp" // using namespace testing; // using namespace ngraph; // TEST(TransformationTests, Preprocessing_AddStdScale) { // std::shared_ptr f(nullptr), f_ref(nullptr); // const Shape data_shape{1, 3, 14, 14}; // const Shape scale_shape{3, 1, 1}; // { // auto data = std::make_shared(element::f32, data_shape); // auto relu = std::make_shared(data); // f = std::make_shared(NodeVector{relu}, ParameterVector{data}); // auto scales = opset5::Constant::create(element::f32, scale_shape, // std::vector(shape_size(scale_shape), 2.0f)); // pass::Manager m; // m.register_pass(); // m.register_pass(pass::AddStdScale::ScaleMap{ { data->get_friendly_name(), scales } }); // m.run_passes(f); // } // { // auto data = std::make_shared(element::f32, data_shape); // auto scales = opset5::Constant::create(element::f32, scale_shape, // std::vector(shape_size(scale_shape), 2.0f)); // auto div = std::make_shared(data, scales); // auto relu = std::make_shared(div); // f_ref = std::make_shared(NodeVector{relu}, ParameterVector{data}); // } // auto res = compare_functions(f, f_ref); // ASSERT_TRUE(res.first) << res.second; // } // TEST(TransformationTests, Preprocessing_AddMeanValue) { // std::shared_ptr f(nullptr), f_ref(nullptr); // const Shape data_shape{1, 3, 14, 14}; // const Shape mean_shape{3, 1, 1}; // { // auto data = std::make_shared(element::f32, data_shape); // auto relu = std::make_shared(data); // f = std::make_shared(NodeVector{relu}, ParameterVector{data}); // auto meanValues = opset5::Constant::create(element::f32, mean_shape, // std::vector(shape_size(mean_shape), 2.0f)); // pass::Manager m; // m.register_pass(); // m.register_pass(pass::AddMeanSubtract::MeanMap{ { data->get_friendly_name(), meanValues } }); // m.run_passes(f); // } // { // auto data = std::make_shared(element::f32, data_shape); // auto meanValues = opset5::Constant::create(element::f32, mean_shape, // std::vector(shape_size(mean_shape), 2.0f)); // auto sub = std::make_shared(data, meanValues); // auto relu = std::make_shared(sub); // f_ref = std::make_shared(NodeVector{relu}, ParameterVector{data}); // } // auto res = compare_functions(f, f_ref); // ASSERT_TRUE(res.first) << res.second; // } // TEST(TransformationTests, Preprocessing_AddMeanImage) { // std::shared_ptr f(nullptr), f_ref(nullptr); // const Shape data_shape{1, 3, 14, 14}; // const Shape mean_shape{3, 14, 14}; // { // auto data = std::make_shared(element::f32, data_shape); // auto relu = std::make_shared(data); // f = std::make_shared(NodeVector{relu}, ParameterVector{data}); // auto meanValues = opset5::Constant::create(element::f32, mean_shape, // std::vector(shape_size(mean_shape), 2.0f)); // pass::Manager m; // m.register_pass(); // m.register_pass(pass::AddMeanSubtract::MeanMap{ { data->get_friendly_name(), meanValues } }); // m.run_passes(f); // } // { // auto data = std::make_shared(element::f32, data_shape); // auto meanValues = opset5::Constant::create(element::f32, mean_shape, // std::vector(shape_size(mean_shape), 2.0f)); // auto sub = std::make_shared(data, meanValues); // auto relu = std::make_shared(sub); // f_ref = std::make_shared(NodeVector{relu}, ParameterVector{data}); // } // auto res = compare_functions(f, f_ref); // ASSERT_TRUE(res.first) << res.second; // } // TEST(TransformationTests, Preprocessing_AddMeanImageAndScale) { // std::shared_ptr f(nullptr), f_ref(nullptr); // const Shape data_shape{1, 3, 14, 14}; // const Shape mean_shape{3, 14, 14}; // const Shape scale_shape{3, 1, 1}; // { // auto data = std::make_shared(element::f32, data_shape); // auto relu = std::make_shared(data); // f = std::make_shared(NodeVector{relu}, ParameterVector{data}); // auto meanValues = opset5::Constant::create(element::f32, mean_shape, // std::vector(shape_size(mean_shape), 2.0f)); // auto scaleValues = opset5::Constant::create(element::f32, scale_shape, // std::vector(shape_size(scale_shape), 2.0f)); // pass::Manager m; // m.register_pass(); // m.register_pass(pass::AddStdScale::ScaleMap{ { data->get_friendly_name(), scaleValues } }); // m.register_pass(pass::AddMeanSubtract::MeanMap{ { data->get_friendly_name(), meanValues } }); // m.run_passes(f); // } // { // auto data = std::make_shared(element::f32, data_shape); // auto meanValues = opset5::Constant::create(element::f32, mean_shape, // std::vector(shape_size(mean_shape), 2.0f)); // auto scaleValues = opset5::Constant::create(element::f32, scale_shape, // std::vector(shape_size(scale_shape), 2.0f)); // auto sub = std::make_shared(data, meanValues); // auto div = std::make_shared(sub, scaleValues); // auto relu = std::make_shared(div); // f_ref = std::make_shared(NodeVector{relu}, ParameterVector{data}); // } // auto res = compare_functions(f, f_ref); // ASSERT_TRUE(res.first) << res.second; // } // TEST(TransformationTests, Preprocessing_AddMeanValueAndScale) { // std::shared_ptr f(nullptr), f_ref(nullptr); // const Shape data_shape{1, 3, 14, 14}; // const Shape mean_shape{3, 1, 1}; // const Shape scale_shape{3, 1, 1}; // { // auto data = std::make_shared(element::f32, data_shape); // auto relu = std::make_shared(data); // f = std::make_shared(NodeVector{relu}, ParameterVector{data}); // auto meanValues = opset5::Constant::create(element::f32, mean_shape, // std::vector(shape_size(mean_shape), 2.0f)); // auto scaleValues = opset5::Constant::create(element::f32, scale_shape, // std::vector(shape_size(scale_shape), 2.0f)); // pass::Manager m; // m.register_pass(); // m.register_pass(pass::AddStdScale::ScaleMap{ { data->get_friendly_name(), scaleValues } }); // m.register_pass(pass::AddMeanSubtract::MeanMap{ { data->get_friendly_name(), meanValues } }); // m.run_passes(f); // } // { // auto data = std::make_shared(element::f32, data_shape); // auto meanValues = opset5::Constant::create(element::f32, mean_shape, // std::vector(shape_size(mean_shape), 2.0f)); // auto scaleValues = opset5::Constant::create(element::f32, scale_shape, // std::vector(shape_size(scale_shape), 2.0f)); // auto sub = std::make_shared(data, meanValues); // auto div = std::make_shared(sub, meanValues); // auto relu = std::make_shared(div); // f_ref = std::make_shared(NodeVector{relu}, ParameterVector{data}); // } // auto res = compare_functions(f, f_ref); // ASSERT_TRUE(res.first) << res.second; // }