Skip to content

Commit

Permalink
Merge branch 'master' into itikhono/transformations/ngraph_to_ov_refa…
Browse files Browse the repository at this point in the history
…ctoring
  • Loading branch information
itikhono authored Sep 28, 2023
2 parents 16c7f67 + 23e602f commit 288b13a
Show file tree
Hide file tree
Showing 36 changed files with 588 additions and 665 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/code_style.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ jobs:
- name: Install Clang dependency
run: |
sudo apt update
sudo apt --assume-yes remove clang-7 clang-8 clang-9 clang-10 clang-11 clang-12 clang-13
sudo apt --assume-yes remove clang-7 clang-8 clang-9 clang-10 clang-11 clang-12 clang-13 clang-15
sudo apt --assume-yes install clang-14 libclang-14-dev
- name: Install Python-based dependencies
Expand Down
9 changes: 9 additions & 0 deletions src/core/dev_api/validation_util.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,14 @@ OPENVINO_API int64_t clip(const int64_t& value, const int64_t& min, const int64_
///
/// \return Constant node or nullptr if unable to constantfold the subgraph
OPENVINO_API std::shared_ptr<op::v0::Constant> constantfold_subgraph(const Output<Node>& subgraph_sink);

/**
* @brief Runs an estimation of source tensor. If it succeeded to calculate both bounds and
* they are the same returns Constant operation from the resulting bound, otherwise nullptr.
*
* @param source Node output used to get its tensor data as constant.
* @return Shared pointer to constant data or nullptr.
*/
OPENVINO_API std::shared_ptr<op::v0::Constant> get_constant_from_source(const Output<Node>& source);
} // namespace util
} // namespace ov
4 changes: 1 addition & 3 deletions src/core/include/openvino/op/reduce_max.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ class OPENVINO_API ReduceMax : public util::ArithmeticReductionKeepDims {

std::shared_ptr<Node> 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;
bool evaluate_lower(TensorVector& outputs) const override;
bool evaluate_upper(TensorVector& outputs) const override;
Expand Down
4 changes: 1 addition & 3 deletions src/core/include/openvino/op/reduce_mean.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ class OPENVINO_API ReduceMean : public util::ArithmeticReductionKeepDims {

std::shared_ptr<Node> 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 v1
Expand Down
4 changes: 1 addition & 3 deletions src/core/include/openvino/op/reduce_min.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ class OPENVINO_API ReduceMin : public util::ArithmeticReductionKeepDims {

std::shared_ptr<Node> 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;
bool evaluate_lower(TensorVector& outputs) const override;
bool evaluate_upper(TensorVector& outputs) const override;
Expand Down
4 changes: 1 addition & 3 deletions src/core/include/openvino/op/reduce_prod.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ class OPENVINO_API ReduceProd : public util::ArithmeticReductionKeepDims {

std::shared_ptr<Node> 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;
bool evaluate_lower(TensorVector& outputs) const override;
bool evaluate_upper(TensorVector& outputs) const override;
Expand Down
4 changes: 1 addition & 3 deletions src/core/include/openvino/op/reduce_sum.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,7 @@ class OPENVINO_API ReduceSum : public util::ArithmeticReductionKeepDims {

std::shared_ptr<Node> 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 v1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
#include <numeric>

#include "openvino/core/shape.hpp"
#include "openvino/reference/mean.hpp"
#include "openvino/reference/sum.hpp"
#include "openvino/reference/reduce_mean.hpp"
#include "openvino/reference/reduce_sum.hpp"

namespace ov {
namespace reference {
Expand Down Expand Up @@ -38,11 +38,11 @@ void group_normalization(const T* const data,
const auto group_begin = data + n * batch_size + g * group_size;
const auto group_end = group_begin + group_size;
std::vector<T> mean_value(1);
mean(group_begin, mean_value.data(), Shape{group_size}, {0});
reduce_mean(group_begin, mean_value.data(), Shape{group_size}, {0});
T mean = mean_value[0];
T variance = 0, err = 0;
for_each(group_begin, group_end, [&](const T d) {
return details::kahan_summation(static_cast<T>(pow(d - mean, 2)), err, variance);
variance = details::kahan_summation(static_cast<T>(pow(d - mean, 2)), variance, err);
});
variance /= group_size;
const T standard_deviation = sqrt(variance + eps);
Expand Down
8 changes: 4 additions & 4 deletions src/core/reference/include/openvino/reference/log_softmax.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
#include <cmath>

#include "ngraph/shape_util.hpp"
#include "openvino/reference/max.hpp"
#include "openvino/reference/sum.hpp"
#include "openvino/reference/reduce_max.hpp"
#include "openvino/reference/reduce_sum.hpp"
#include "openvino/reference/utils/coordinate_transform.hpp"

namespace ov {
Expand All @@ -21,7 +21,7 @@ void log_softmax(const T* arg, T* out, const Shape& shape, const AxisSet& axes)
auto temp_max = std::vector<T>(temp_elements, 0);
auto temp_sum = std::vector<T>(temp_elements, 0);

max(arg, temp_max.data(), shape, axes);
reduce_max(arg, temp_max.data(), shape, axes);

CoordinateTransform transform(shape);
CoordinateTransform temp_transform(temp_shape);
Expand All @@ -31,7 +31,7 @@ void log_softmax(const T* arg, T* out, const Shape& shape, const AxisSet& axes)
static_cast<T>(std::exp(arg[transform.index(coord)] - temp_max[temp_transform.index(temp_coord)]));
}

sum(out, temp_sum.data(), shape, axes);
reduce_sum(out, temp_sum.data(), shape, axes);

for (const Coordinate& coord : transform) {
Coordinate temp_coord = ngraph::reduce(coord, axes, true);
Expand Down
46 changes: 0 additions & 46 deletions src/core/reference/include/openvino/reference/max.hpp

This file was deleted.

58 changes: 0 additions & 58 deletions src/core/reference/include/openvino/reference/mean.hpp

This file was deleted.

51 changes: 0 additions & 51 deletions src/core/reference/include/openvino/reference/min.hpp

This file was deleted.

12 changes: 6 additions & 6 deletions src/core/reference/include/openvino/reference/mvn.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@

#include "openvino/reference/add.hpp"
#include "openvino/reference/divide.hpp"
#include "openvino/reference/mean.hpp"
#include "openvino/reference/multiply.hpp"
#include "openvino/reference/reduce_mean.hpp"
#include "openvino/reference/reduce_sum.hpp"
#include "openvino/reference/sqrt.hpp"
#include "openvino/reference/subtract.hpp"
#include "openvino/reference/sum.hpp"

namespace ov {
namespace reference {
Expand All @@ -28,13 +28,13 @@ void mvn(const T* arg,
const double eps) {
auto reduced_shape = ngraph::reduce(in_shape, reduction_axes, true);
std::vector<T> tmp_buffer(shape_size(in_shape));
mean(arg, tmp_buffer.data(), in_shape, reduction_axes);
reduce_mean(arg, tmp_buffer.data(), in_shape, reduction_axes);
subtract(arg, tmp_buffer.data(), out, in_shape, reduced_shape, op::AutoBroadcastType::NUMPY);

if (normalize_variance) {
multiply(out, out, tmp_buffer.data(), shape_size(in_shape));
std::vector<T> mean_value(shape_size(reduced_shape));
mean(tmp_buffer.data(), mean_value.data(), in_shape, reduction_axes);
reduce_mean(tmp_buffer.data(), mean_value.data(), in_shape, reduction_axes);

add(mean_value.data(),
std::vector<T>(shape_size(reduced_shape), static_cast<T>(eps)).data(),
Expand All @@ -58,13 +58,13 @@ void mvn_6(const T* arg,
op::MVNEpsMode eps_mode) {
auto reduced_shape = ngraph::reduce(in_shape, reduction_axes, true);
std::vector<T> tmp_buffer(shape_size(in_shape));
mean(arg, tmp_buffer.data(), in_shape, reduction_axes);
reduce_mean(arg, tmp_buffer.data(), in_shape, reduction_axes);
subtract(arg, tmp_buffer.data(), out, in_shape, reduced_shape, op::AutoBroadcastType::NUMPY);

if (normalize_variance) {
multiply(out, out, tmp_buffer.data(), shape_size(in_shape));
std::vector<T> mean_value(shape_size(reduced_shape));
mean(tmp_buffer.data(), mean_value.data(), in_shape, reduction_axes);
reduce_mean(tmp_buffer.data(), mean_value.data(), in_shape, reduction_axes);

if (eps_mode == op::MVNEpsMode::INSIDE_SQRT) {
add(mean_value.data(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <ngraph/op/normalize_l2.hpp>

#include "openvino/reference/autobroadcast_binop.hpp"
#include "openvino/reference/sum.hpp"
#include "openvino/reference/reduce_sum.hpp"

namespace ov {
namespace reference {
Expand Down Expand Up @@ -38,7 +38,7 @@ void normalize_l2(const T* data,
}

std::vector<T> sum_data(shape_size(reduce_shape));
sum(sqr_data.data(), sum_data.data(), data_shape, reduction_axes);
reduce_sum(sqr_data.data(), sum_data.data(), data_shape, reduction_axes);
autobroadcast_binop(data,
sum_data.data(),
out,
Expand Down
39 changes: 0 additions & 39 deletions src/core/reference/include/openvino/reference/product.hpp

This file was deleted.

Loading

0 comments on commit 288b13a

Please sign in to comment.