From e2e01bff32507ca3aae5851738dc59ea4b3eba6a Mon Sep 17 00:00:00 2001 From: Roman Kazantsev Date: Fri, 2 Sep 2022 16:35:54 +0300 Subject: [PATCH] [TF FE] Implement a loader for ListDiff operation (#12868) Signed-off-by: Kazantsev, Roman Signed-off-by: Kazantsev, Roman --- src/frontends/tensorflow/src/op/list_diff.cpp | 55 +++++++++++++++++++ src/frontends/tensorflow/src/op_table.cpp | 2 + 2 files changed, 57 insertions(+) create mode 100644 src/frontends/tensorflow/src/op/list_diff.cpp diff --git a/src/frontends/tensorflow/src/op/list_diff.cpp b/src/frontends/tensorflow/src/op/list_diff.cpp new file mode 100644 index 00000000000..8fe93184800 --- /dev/null +++ b/src/frontends/tensorflow/src/op/list_diff.cpp @@ -0,0 +1,55 @@ +// Copyright (C) 2018-2022 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "op_table.hpp" +#include "openvino/opsets/opset8.hpp" + +using namespace std; +using namespace ov::opset8; + +namespace ov { +namespace frontend { +namespace tensorflow { +namespace op { +OutputVector translate_list_diff_op(const NodeContext& node) { + // ListDiff computes the difference between two lists of numbers + default_op_checks(node, 2, {"ListDiff"}); + auto x = node.get_input(0); + auto y = node.get_input(1); + + // retrieve attribute + auto out_idx = node.get_attribute("out_idx", ov::element::i32); + + // unsqueeze both operand to make comparison elements between each other + auto unsqueeze_x = + make_shared(x, make_shared(ov::element::i64, ov::Shape{}, std::vector{1})); + auto unsqueeze_y = + make_shared(y, make_shared(ov::element::i64, ov::Shape{}, std::vector{0})); + + // generate a mask where elements x and y are different + auto x_is_non_equal_y = + make_shared(make_shared(unsqueeze_x, unsqueeze_y), + make_shared(ov::element::i64, ov::Shape{}, std::vector{1}), + false); + auto mask01_x_is_non_equal_y = + make_shared