Fix pad op with int input (#4438)

* Added operation ConvertLike to the MO

* Fixed transformations with Pad which insert Const with pad value of incorrect type

* Added constant folding to ConvertLike operation

* Fixed unit tests for Pad transformations to include ConverLike operations

* Update copyright year

* nGraph code style fix

* Added OV_ITT_SCOPED_TASK for ConvertLike constant folding
This commit is contained in:
Evgeny Lazarev
2021-02-24 09:56:36 +03:00
committed by GitHub
parent 4d9797c1fe
commit 7420bb6cb0
8 changed files with 91 additions and 12 deletions

View File

@@ -42,6 +42,9 @@ namespace ngraph
virtual std::shared_ptr<Node>
clone_with_new_inputs(const OutputVector& new_args) const override;
bool constant_fold(OutputVector& output_values,
const OutputVector& input_values) override;
};
} // namespace v1

View File

@@ -17,6 +17,8 @@
#include <memory>
#include "itt.hpp"
#include "ngraph/op/constant.hpp"
#include "ngraph/op/convert.hpp"
#include "ngraph/op/convert_like.hpp"
using namespace std;
@@ -48,3 +50,17 @@ shared_ptr<Node> op::v1::ConvertLike::clone_with_new_inputs(const OutputVector&
check_new_args_count(this, new_args);
return make_shared<ConvertLike>(new_args.at(0), new_args.at(1));
}
bool op::v1::ConvertLike::constant_fold(OutputVector& output_values,
const OutputVector& input_values)
{
OV_ITT_SCOPED_TASK(itt::domains::nGraph, "op::v1::ConvertLike::constant_fold");
if (auto data_const =
std::dynamic_pointer_cast<op::Constant>(input_values[0].get_node_shared_ptr()))
{
auto convert = make_shared<Convert>(input_values[0], input_values[1].get_element_type());
convert->constant_fold(output_values, OutputVector{data_const});
return true;
}
return false;
}