diff --git a/src/core/include/openvino/op/log.hpp b/src/core/include/openvino/op/log.hpp index ae0ca7080a7..33a0fe6aa44 100644 --- a/src/core/include/openvino/op/log.hpp +++ b/src/core/include/openvino/op/log.hpp @@ -21,11 +21,8 @@ public: /// \param arg Node that produces the input tensor. Log(const Output& arg); - bool visit_attributes(AttributeVisitor& visitor) override; std::shared_ptr clone_with_new_inputs(const OutputVector& new_args) const override; - OPENVINO_SUPPRESS_DEPRECATED_START - bool evaluate(const HostTensorVector& outputs, const HostTensorVector& inputs) const override; - OPENVINO_SUPPRESS_DEPRECATED_END + bool evaluate(TensorVector& outputs, const TensorVector& inputs) const override; bool has_evaluate() const override; }; } // namespace v0 diff --git a/src/core/reference/include/openvino/reference/log.hpp b/src/core/reference/include/openvino/reference/log.hpp index fec6c959e29..d8b7fdeab3b 100644 --- a/src/core/reference/include/openvino/reference/log.hpp +++ b/src/core/reference/include/openvino/reference/log.hpp @@ -4,6 +4,7 @@ #pragma once +#include #include #include @@ -11,9 +12,9 @@ namespace ov { namespace reference { template void log(const T* arg, T* out, size_t count) { - for (size_t i = 0; i < count; i++) { - out[i] = static_cast(std::log(arg[i])); - } + std::transform(arg, arg + count, out, [](const T v) { + return static_cast(std::log(v)); + }); } } // namespace reference } // namespace ov diff --git a/src/core/src/op/log.cpp b/src/core/src/op/log.cpp index a854ceb06f5..dacde7087e9 100644 --- a/src/core/src/op/log.cpp +++ b/src/core/src/op/log.cpp @@ -2,78 +2,66 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "ngraph/op/log.hpp" +#include "openvino/op/log.hpp" +#include "element_visitor.hpp" #include "itt.hpp" -#include "ngraph/op/divide.hpp" -#include "ngraph/runtime/host_tensor.hpp" #include "openvino/reference/log.hpp" -using namespace std; -using namespace ngraph; +namespace ov { +namespace op { +namespace log { +struct Evaluate : element::NoAction { + using element::NoAction::visit; -op::Log::Log(const Output& arg) : UnaryElementwiseArithmetic(arg) { + template > + static result_type visit(const Tensor& in, Tensor& out, const size_t count) { + reference::log(in.data(), out.data(), count); + return true; + } +}; +} // namespace log + +namespace v0 { +Log::Log(const Output& arg) : UnaryElementwiseArithmetic(arg) { constructor_validate_and_infer_types(); } -bool ngraph::op::v0::Log::visit_attributes(AttributeVisitor& visitor) { - OV_OP_SCOPE(v0_Log_visit_attributes); - return true; -} - -shared_ptr op::Log::clone_with_new_inputs(const OutputVector& new_args) const { +std::shared_ptr Log::clone_with_new_inputs(const OutputVector& new_args) const { OV_OP_SCOPE(v0_Log_clone_with_new_inputs); check_new_args_count(this, new_args); - return make_shared(new_args.at(0)); + return std::make_shared(new_args.at(0)); } -OPENVINO_SUPPRESS_DEPRECATED_START -namespace logop { -namespace { -template -inline bool evaluate(const HostTensorPtr& arg0, const HostTensorPtr& out, const size_t count) { - using T = typename element_type_traits::value_type; - ov::reference::log(arg0->get_data_ptr(), out->get_data_ptr(), count); - return true; -} - -bool evaluate_log(const HostTensorPtr& arg0, const HostTensorPtr& out, const size_t count) { - bool rc = true; - out->set_unary(arg0); - - switch (arg0->get_element_type()) { - OPENVINO_TYPE_CASE(evaluate_log, i32, arg0, out, count); - OPENVINO_TYPE_CASE(evaluate_log, i64, arg0, out, count); - OPENVINO_TYPE_CASE(evaluate_log, u32, arg0, out, count); - OPENVINO_TYPE_CASE(evaluate_log, u64, arg0, out, count); - OPENVINO_TYPE_CASE(evaluate_log, f16, arg0, out, count); - OPENVINO_TYPE_CASE(evaluate_log, f32, arg0, out, count); - default: - rc = false; - break; - } - return rc; -} -} // namespace -} // namespace logop - -bool op::Log::evaluate(const HostTensorVector& outputs, const HostTensorVector& inputs) const { +bool Log::evaluate(TensorVector& outputs, const TensorVector& inputs) const { OV_OP_SCOPE(v0_Log_evaluate); - return logop::evaluate_log(inputs[0], outputs[0], shape_size(inputs[0]->get_shape())); + OPENVINO_ASSERT(outputs.size() == 1); + OPENVINO_ASSERT(inputs.size() == 1); + + const auto& input_shape = inputs[0].get_shape(); + const auto count = shape_size(input_shape); + outputs[0].set_shape(input_shape); + using namespace ov::element; + return IfTypeOf::apply(inputs[0].get_element_type(), + inputs[0], + outputs[0], + count); } -bool op::Log::has_evaluate() const { +bool Log::has_evaluate() const { OV_OP_SCOPE(v0_Log_has_evaluate); switch (get_input_element_type(0)) { - case ngraph::element::i32: - case ngraph::element::i64: - case ngraph::element::u32: - case ngraph::element::u64: - case ngraph::element::f16: - case ngraph::element::f32: + case element::f16: + case element::f32: + case element::i32: + case element::i64: + case element::u32: + case element::u64: return true; default: - break; + return false; } - return false; } +} // namespace v0 +} // namespace op +} // namespace ov