Revise log (#6061)

* refactor ngraph log class, add type_prop tests

* udpate inputs, outputs decscription in spec

Co-authored-by: jdanieck <jozef.daniecki@intel.com>
This commit is contained in:
Bartek Szmelczynski
2021-06-10 18:35:52 +02:00
committed by GitHub
parent 9e9e33e772
commit 084aa4e591
6 changed files with 41 additions and 12 deletions

View File

@@ -6,28 +6,28 @@
**Short description**: *Log* performs element-wise natural logarithm operation with given tensor.
**Detailed description**: *Log* does the following with the input tensor *a*:
\f[
a_{i} = log(a_{i})
\f]
**Attributes**:
No attributes available.
**Inputs**
* **1**: An tensor of type T. **Required.**
* **1**: An tensor of type T and arbitrary shape. **Required.**
**Outputs**
* **1**: The result of element-wise log operation. A tensor of type T.
* **1**: The result of element-wise log operation. A tensor of type T and the same shape as input.
**Types**
* *T*: any numeric type.
*Log* does the following with the input tensor *a*:
\f[
a_{i} = log(a_{i})
\f]
**Examples**
*Example 1*

View File

@@ -16,8 +16,7 @@ namespace ngraph
class NGRAPH_API Log : public util::UnaryElementwiseArithmetic
{
public:
static constexpr NodeTypeInfo type_info{"Log", 0};
const NodeTypeInfo& get_type_info() const override { return type_info; }
NGRAPH_RTTI_DECLARATION;
/// \brief Constructs a natural log operation.
Log() = default;
/// \brief Constructs a natural log operation.

View File

@@ -13,7 +13,7 @@
using namespace std;
using namespace ngraph;
constexpr NodeTypeInfo op::Log::type_info;
NGRAPH_RTTI_DEFINITION(op::v0::Log, "Log", 0);
op::Log::Log(const Output<Node>& arg)
: UnaryElementwiseArithmetic(arg)

View File

@@ -232,6 +232,7 @@ set(SRC
visitors/op/grn.cpp
visitors/op/group_conv.cpp
visitors/op/interpolate.cpp
visitors/op/log.cpp
visitors/op/logical_xor.cpp
visitors/op/lrn.cpp
visitors/op/lstm_cell.cpp

View File

@@ -96,6 +96,6 @@ REGISTER_TYPED_TEST_CASE_P(UnaryOperator,
dynamic_rank_input_shape_3D,
dynamic_rank_input_shape_full);
using Types = ::testing::Types<op::Acos, op::Asin, op::Abs, op::Sqrt, op::Sin, op::Exp, op::Floor>;
using Types = ::testing::Types<op::Acos, op::Asin, op::Abs, op::Sqrt, op::Sin, op::Exp, op::Floor, op::Log>;
INSTANTIATE_TYPED_TEST_CASE_P(type_prop, UnaryOperator, Types);

View File

@@ -0,0 +1,29 @@
// Copyright (C) 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, log_op)
{
using namespace opset1;
NodeBuilder::get_ops().register_factory<Log>();
const auto data_input = make_shared<Parameter>(element::f32, Shape{1, 2, 3});
const auto op = make_shared<Sqrt>(data_input);
NodeBuilder builder(op);
const auto expected_attr_count = 0;
EXPECT_EQ(builder.get_value_map_size(), expected_attr_count);
}