support pytorch efrc op (#21567)

* support pytorch efrc op

* allow dynamic case & fix code format

* fix code style, use space 4
This commit is contained in:
Ahmad Chalhoub authored and GitHub committed 2023-12-12 21:54:29 +01:00
1 parent 9ab0a6d2f1
commit 942bc8b1ba
3 files changed
+105

No files matched your search

+45
View File
@@ -0,0 +1,45 @@
// Copyright (C) 2018-2023 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#include "openvino/frontend/pytorch/node_context.hpp"
#include "openvino/op/convert.hpp"
#include "openvino/op/erf.hpp"
#include "openvino/op/subtract.hpp"
#include "utils.hpp"
using namespace std;
using namespace ov::op;
namespace ov {
namespace frontend {
namespace pytorch {
namespace op {
OutputVector translate_erfc(const NodeContext& context) {
// aten::erf(Tensor self) -> Tensor
// aten::erf.out(Tensor self, Tensor(!a) out) -> Tensor(!a)
num_inputs_check(context, 1, 2);
auto x = context.get_input(0);
// create 'ones' to use to calculate complementary of Erf output
auto ones = context.mark_node(make_shared<v0::Constant>(element::f32, Shape{}, 1.0f))->output(0);
// align data types of input 'x' and ones
align_eltwise_input_types(context, x, ones);
// apply Erf to the input tensor 'x'
auto y = context.mark_node(make_shared<v0::Erf>(x));
y = context.mark_node(make_shared<v1::Subtract>(ones, y));
if (!context.input_is_none(1)) {
context.mutate_input(1, y);
}
return {y};
};
} // namespace op
} // namespace pytorch
} // namespace frontend
} // namespace ov
+3
View File
@@ -68,6 +68,7 @@ OP_CONVERTER(translate_embedding_bag);
OP_CONVERTER(translate_empty);
OP_CONVERTER(translate_empty_like);
OP_CONVERTER(translate_erf);
OP_CONVERTER(translate_erfc);
OP_CONVERTER(translate_expand);
OP_CONVERTER(translate_expand_as);
OP_CONVERTER(translate_eye);
@@ -348,6 +349,8 @@ const std::map<std::string, CreatorFunction> get_supported_ops_ts() {
{"aten::eq", op::translate_1to1_match_2_inputs_align_types<opset10::Equal>},
{"aten::erf", op::translate_erf},
{"aten::erf_", op::inplace_op<op::translate_erf>},
{"aten::erfc", op::translate_erfc},
{"aten::erfc_", op::inplace_op<op::translate_erfc>},
{"aten::exp", op::translate_1to1_match_1_inputs_with_fp32_type_alignment<opset10::Exp>},
{"aten::exp_", op::inplace_op<op::translate_1to1_match_1_inputs_with_fp32_type_alignment<opset10::Exp>>},
{"aten::expand", op::translate_expand},