From d917b22700d2d9b1a6b5cd82248010bfecc0163f Mon Sep 17 00:00:00 2001 From: "Hu, Yuan2" Date: Wed, 21 Jul 2021 15:39:28 +0800 Subject: [PATCH] add template plugin test case for uint and float remove the float test in backend Signed-off-by: Hu, Yuan2 --- .../tests/functional/op_reference/tan.cpp | 34 +++++----- ngraph/test/CMakeLists.txt | 1 - ngraph/test/backend/tan.in.cpp | 64 ------------------- 3 files changed, 18 insertions(+), 81 deletions(-) delete mode 100644 ngraph/test/backend/tan.in.cpp diff --git a/docs/template_plugin/tests/functional/op_reference/tan.cpp b/docs/template_plugin/tests/functional/op_reference/tan.cpp index 74540c9ffad03c..837fc06617b7da 100644 --- a/docs/template_plugin/tests/functional/op_reference/tan.cpp +++ b/docs/template_plugin/tests/functional/op_reference/tan.cpp @@ -57,23 +57,25 @@ TEST_P(ReferenceTanLayerTest, CompareWithHardcodedRefs) { Exec(); } -template -std::vector generateTanParamsInt(const ngraph::element::Type& type) { - using T = typename element_type_traits::value_type; - std::vector tanParams { - TanParams(ngraph::PartialShape {5}, type, std::vector {-2, -1, 0, 1, 2}, - std::vector {2, -2, 0, 2, -2}) - }; - return tanParams; -} - std::vector generateTanCombinedParams() { - const std::vector> tanTypeParams {generateTanParamsInt(ngraph::element::i32), - generateTanParamsInt(ngraph::element::i64)}; - std::vector combinedParams; - std::for_each(tanTypeParams.begin(), tanTypeParams.end(), [&](std::vector params) { - combinedParams.insert(combinedParams.end(), params.begin(), params.end()); - }); + std::vector combinedParams { + TanParams(ngraph::PartialShape {5}, ngraph::element::i32, std::vector {-2, -1, 0, 1, 2}, + std::vector {2, -2, 0, 2, -2}), + TanParams(ngraph::PartialShape {5}, ngraph::element::i64, std::vector {-2, -1, 0, 1, 2}, + std::vector {2, -2, 0, 2, -2}), + TanParams(ngraph::PartialShape {5}, ngraph::element::u32, std::vector {1, 2, 3, 4, 5}, + std::vector {2, 0xFFFFFFFF - 1, 0, 1, 0xFFFFFFFF - 2}), + TanParams(ngraph::PartialShape {5}, ngraph::element::u64, std::vector {1, 2, 3, 4, 5}, + std::vector {2, 0xFFFFFFFFFFFFFFFF - 1, 0, 1, 0xFFFFFFFFFFFFFFFF - 2}), + TanParams(ngraph::PartialShape {11}, ngraph::element::f32, std::vector {0.f, 0.25f, + -0.25f, 0.5f, -0.5f, 1.f, -1.f, 2.f, -2.f, 4.f, -4.f}, + std::vector {0.00000000f, 0.25534192f, -0.25534192f, 0.54630249f, -0.54630249f, + 1.55740772f, -1.55740772f, -2.18503986f, 2.18503986f, 1.15782128f, -1.15782128f}), + TanParams(ngraph::PartialShape {11}, ngraph::element::f16, std::vector {0.f, 0.25f, + -0.25f, 0.5f, -0.5f, 1.f, -1.f, 2.f, -2.f, 4.f, -4.f}, + std::vector {0.00000000f, 0.25534192f, -0.25534192f, 0.54630249f, -0.54630249f, + 1.55740772f, -1.55740772f, -2.18503986f, 2.18503986f, 1.15782128f, -1.15782128f}) + }; return combinedParams; } diff --git a/ngraph/test/CMakeLists.txt b/ngraph/test/CMakeLists.txt index e9435a1d14b4d4..82b988a7375cfe 100644 --- a/ngraph/test/CMakeLists.txt +++ b/ngraph/test/CMakeLists.txt @@ -520,7 +520,6 @@ set(MULTI_TEST_SRC backend/squeeze.in.cpp backend/subtract.in.cpp backend/swish.in.cpp - backend/tan.in.cpp backend/tanh.in.cpp backend/tile.in.cpp backend/topk.in.cpp diff --git a/ngraph/test/backend/tan.in.cpp b/ngraph/test/backend/tan.in.cpp deleted file mode 100644 index a234639d73d1ef..00000000000000 --- a/ngraph/test/backend/tan.in.cpp +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright (C) 2018-2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include -#include -#include -#include -#include -#include - -// clang-format off -#ifdef ${BACKEND_NAME}_FLOAT_TOLERANCE_BITS -#define DEFAULT_FLOAT_TOLERANCE_BITS ${BACKEND_NAME}_FLOAT_TOLERANCE_BITS -#endif - -#ifdef ${BACKEND_NAME}_DOUBLE_TOLERANCE_BITS -#define DEFAULT_DOUBLE_TOLERANCE_BITS ${BACKEND_NAME}_DOUBLE_TOLERANCE_BITS -#endif -// clang-format on - -#include "gtest/gtest.h" -#include "runtime/backend.hpp" -#include "ngraph/runtime/tensor.hpp" -#include "ngraph/ngraph.hpp" -#include "util/all_close.hpp" -#include "util/all_close_f.hpp" -#include "util/ndarray.hpp" -#include "util/test_control.hpp" -#include "util/test_tools.hpp" - -using namespace std; -using namespace ngraph; - -static string s_manifest = "${MANIFEST}"; - -NGRAPH_TEST(${BACKEND_NAME}, tan_float) -{ - Shape shape{11}; - auto A = make_shared(element::f32, shape); - auto f = make_shared(make_shared(A), ParameterVector{A}); - - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - - // Create some tensors for input/output - auto a = backend->create_tensor(element::f32, shape); - vector input{0.f, 0.25f, -0.25f, 0.5f, -0.5f, 1.f, -1.f, 2.f, -2.f, 4.f, -4.f}; - copy_data(a, input); - auto result = backend->create_tensor(element::f32, shape); - auto handle = backend->compile(f); - handle->call_with_validate({result}, {a}); - EXPECT_TRUE(test::all_close_f(vector{0.00000000f, - 0.25534192f, - -0.25534192f, - 0.54630249f, - -0.54630249f, - 1.55740772f, - -1.55740772f, - -2.18503986f, - 2.18503986f, - 1.15782128f, - -1.15782128f}, - read_vector(result))); -}