From e9612a6dc2fbd7651270663ef4b7493024ff2f1c Mon Sep 17 00:00:00 2001 From: Piotr Szmelczynski Date: Fri, 21 May 2021 06:55:26 +0200 Subject: [PATCH] Revise floor (#5618) * create type_prop tests * add visitors test * fix bug in visitor test * add RTTI macro * fix bug in visitors test * add newline * update spec * update spec * update RTTI definition * move RTTI definitioion to the top of he file * Remove broadcast from attribute tests. * Add Floor-1 to summarize.py report. Co-authored-by: jdanieck --- docs/ops/arithmetic/Floor_1.md | 20 +++++++------- .../layer_tests_summary/utils/constants.py | 1 + ngraph/core/include/ngraph/op/floor.hpp | 3 +-- ngraph/core/src/op/floor.cpp | 2 +- ngraph/test/CMakeLists.txt | 1 + ngraph/test/type_prop/unary_ops.cpp | 2 +- ngraph/test/visitors/op/floor.cpp | 26 +++++++++++++++++++ 7 files changed, 41 insertions(+), 14 deletions(-) create mode 100644 ngraph/test/visitors/op/floor.cpp diff --git a/docs/ops/arithmetic/Floor_1.md b/docs/ops/arithmetic/Floor_1.md index f76c3b24752e8c..910ce43d5903b8 100644 --- a/docs/ops/arithmetic/Floor_1.md +++ b/docs/ops/arithmetic/Floor_1.md @@ -2,31 +2,31 @@ **Versioned name**: *Floor-1* -**Category**: Arithmetic unary operation +**Category**: Arithmetic unary operation **Short description**: *Floor* performs element-wise floor operation with given tensor. -**Attributes**: +**Detailed description**: For each element from the input tensor calculates corresponding +element in the output tensor with the following formula: - No attributes available. +\f[ +a_{i} = floor(a_{i}) +\f] + +**Attributes**: *Floor* operation has no attributes. **Inputs** -* **1**: An tensor of type T. **Required.** +* **1**: A tensor of type *T* and arbitrary shape. **Required.** **Outputs** -* **1**: The result of element-wise floor operation. A tensor of type T. +* **1**: The result of element-wise floor operation. A tensor of type *T*. **Types** * *T*: any numeric type. -*Floor* does the following with the input tensor *a*: - -\f[ -a_{i} = floor(a_{i}) -\f] **Examples** diff --git a/inference-engine/tests/ie_test_utils/functional_test_utils/layer_tests_summary/utils/constants.py b/inference-engine/tests/ie_test_utils/functional_test_utils/layer_tests_summary/utils/constants.py index 20442899b87ce6..59df352e9d5506 100644 --- a/inference-engine/tests/ie_test_utils/functional_test_utils/layer_tests_summary/utils/constants.py +++ b/inference-engine/tests/ie_test_utils/functional_test_utils/layer_tests_summary/utils/constants.py @@ -28,6 +28,7 @@ 'ExperimentalDetectronPriorGridGenerator-6', 'ExperimentalDetectronROIFeatureExtractor-6', 'ExperimentalDetectronTopKROIs-6', + 'Floor-1' 'FloorMod-1' 'GRUSequence-5', 'Gather-1', diff --git a/ngraph/core/include/ngraph/op/floor.hpp b/ngraph/core/include/ngraph/op/floor.hpp index 8cb99b158873fa..237cd68a4e73c1 100644 --- a/ngraph/core/include/ngraph/op/floor.hpp +++ b/ngraph/core/include/ngraph/op/floor.hpp @@ -16,8 +16,7 @@ namespace ngraph class NGRAPH_API Floor : public util::UnaryElementwiseArithmetic { public: - static constexpr NodeTypeInfo type_info{"Floor", 0}; - const NodeTypeInfo& get_type_info() const override { return type_info; } + NGRAPH_RTTI_DECLARATION; /// \brief Constructs a floor operation. Floor() = default; /// \brief Constructs a floor operation. diff --git a/ngraph/core/src/op/floor.cpp b/ngraph/core/src/op/floor.cpp index 74ace6debf7998..89a6a5efda878d 100644 --- a/ngraph/core/src/op/floor.cpp +++ b/ngraph/core/src/op/floor.cpp @@ -12,7 +12,7 @@ using namespace std; using namespace ngraph; -constexpr NodeTypeInfo op::Floor::type_info; +NGRAPH_RTTI_DEFINITION(op::v0::Floor, "Floor", 0, util::UnaryElementwiseArithmetic); op::Floor::Floor(const Output& arg) : UnaryElementwiseArithmetic(arg) diff --git a/ngraph/test/CMakeLists.txt b/ngraph/test/CMakeLists.txt index 7164ebbea7cba1..3f2f72ed5c6bd7 100644 --- a/ngraph/test/CMakeLists.txt +++ b/ngraph/test/CMakeLists.txt @@ -223,6 +223,7 @@ set(SRC visitors/op/elu.cpp visitors/op/extractimagepatches.cpp visitors/op/fake_quantize.cpp + visitors/op/floor.cpp visitors/op/gather.cpp visitors/op/gelu.cpp visitors/op/grn.cpp diff --git a/ngraph/test/type_prop/unary_ops.cpp b/ngraph/test/type_prop/unary_ops.cpp index f9c2160d2afe7b..3859dd7369d490 100644 --- a/ngraph/test/type_prop/unary_ops.cpp +++ b/ngraph/test/type_prop/unary_ops.cpp @@ -96,6 +96,6 @@ REGISTER_TYPED_TEST_CASE_P(UnaryOperator, dynamic_rank_input_shape_3D, dynamic_rank_input_shape_full); -using Types = ::testing::Types; +using Types = ::testing::Types; INSTANTIATE_TYPED_TEST_CASE_P(type_prop, UnaryOperator, Types); diff --git a/ngraph/test/visitors/op/floor.cpp b/ngraph/test/visitors/op/floor.cpp new file mode 100644 index 00000000000000..57cd6011c67239 --- /dev/null +++ b/ngraph/test/visitors/op/floor.cpp @@ -0,0 +1,26 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "gtest/gtest.h" + +#include "ngraph/ngraph.hpp" +#include "ngraph/op/util/attr_types.hpp" +#include "ngraph/opsets/opset1.hpp" +#include "util/visitor.hpp" + +using namespace std; +using namespace ngraph; +using ngraph::test::NodeBuilder; + +TEST(attributes, floor_op) +{ + NodeBuilder::get_ops().register_factory(); + const auto A = make_shared(element::f32, Shape{5, 2}); + + const auto floor = make_shared(A); + NodeBuilder builder(floor); + + const auto expected_attr_count = 0; + EXPECT_EQ(builder.get_value_map_size(), expected_attr_count); +}