Skip to content

OpenVINO™ is an open source toolkit for optimizing and deploying AI inference

[TF FE] Support Expm1 operation (#27491)

Roman Kazantsev4dc005ec34b1
diff --git a/src/frontends/tensorflow/docs/supported_ops.md b/src/frontends/tensorflow/docs/supported_ops.md
index 31f871aca4f..88a8e58c3cf 100644
--- a/src/frontends/tensorflow/docs/supported_ops.md
+++ b/src/frontends/tensorflow/docs/supported_ops.md
@@ -419,7 +419,7 @@ A "supported operation" is one that TensorFlow Frontend can convert to the OpenV
| ExperimentalUnbatchDataset | NO | |
| ExperimentalUniqueDataset | NO | |
| Expint | NO | |
-| Expm1 | NO | |
+| Expm1 | YES | |
| ExtractGlimpse | NO | |
| ExtractGlimpseV2 | NO | |
| ExtractImagePatches | YES | |
diff --git a/src/frontends/tensorflow/src/op_table.cpp b/src/frontends/tensorflow/src/op_table.cpp
index c2bf460b02b..26b665c275b 100644
--- a/src/frontends/tensorflow/src/op_table.cpp
+++ b/src/frontends/tensorflow/src/op_table.cpp
@@ -252,6 +252,7 @@ const std::map<std::string, CreatorFunction> get_supported_ops() {
{"EmptyTensorList", CreatorFunction(translate_empty_tensor_list_op)},
{"EnsureShape", CreatorFunction(translate_identity_op)},
{"ExpandDims", CreatorFunction(translate_expand_dims_op)},
+ {"Expm1", CreatorFunction(translate_expm1_op)},
{"ExtractImagePatches", CreatorFunction(translate_extract_image_patches_op)},
{"FakeQuantWithMinMaxVars", CreatorFunction(translate_fake_quant_op)},
{"FakeQuantWithMinMaxVarsPerChannel", CreatorFunction(translate_fake_quant_op)},
diff --git a/src/frontends/tensorflow_common/include/common_op_table.hpp b/src/frontends/tensorflow_common/include/common_op_table.hpp
index 1fa3386fce4..5bbf056af1d 100644
--- a/src/frontends/tensorflow_common/include/common_op_table.hpp
+++ b/src/frontends/tensorflow_common/include/common_op_table.hpp
@@ -74,6 +74,7 @@ OP_CONVERTER(translate_mul_op);
OP_CONVERTER(translate_dynamic_partition_op);
OP_CONVERTER(translate_einsum_op);
OP_CONVERTER(translate_elu_op);
+OP_CONVERTER(translate_expm1_op);
OP_CONVERTER(translate_expand_dims_op);
OP_CONVERTER(translate_extract_image_patches_op);
OP_CONVERTER(translate_fake_quant_op);
diff --git a/src/frontends/tensorflow_common/src/op/expm1.cpp b/src/frontends/tensorflow_common/src/op/expm1.cpp
new file mode 100644
index 00000000000..21759bd3cbd
--- /dev/null
+++ b/src/frontends/tensorflow_common/src/op/expm1.cpp
@@ -0,0 +1,30 @@
+// Copyright (C) 2018-2024 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#include "common_op_table.hpp"
+#include "openvino/op/exp.hpp"
+#include "openvino/op/subtract.hpp"
+#include "utils.hpp"
+
+using namespace std;
+using namespace ov::op;
+
+namespace ov {
+namespace frontend {
+namespace tensorflow {
+namespace op {
+
+OutputVector translate_expm1_op(const NodeContext& node) {
+ default_op_checks(node, 1, {"Expm1"});
+ auto input = node.get_input(0);
+ auto const_one = create_same_type_const_scalar<int>(input, 1);
+ auto exp = make_shared<v0::Exp>(input);
+ auto res = make_shared<v1::Subtract>(exp, const_one);
+ set_node_name(node.get_name(), res);
+ return {res};
+}
+} // namespace op
+} // namespace tensorflow
+} // namespace frontend
+} // namespace ov
diff --git a/tests/layer_tests/tensorflow_tests/test_tf_Expm1.py b/tests/layer_tests/tensorflow_tests/test_tf_Expm1.py
new file mode 100644
index 00000000000..ff689901285
--- /dev/null
+++ b/tests/layer_tests/tensorflow_tests/test_tf_Expm1.py
@@ -0,0 +1,40 @@
+# Copyright (C) 2018-2024 Intel Corporation
+# SPDX-License-Identifier: Apache-2.0
+
+import numpy as np
+import pytest
+import tensorflow as tf
+from common.tf_layer_test_class import CommonTFLayerTest
+
+rng = np.random.default_rng(345345)
+
+
+class TestExpm1(CommonTFLayerTest):
+ def _prepare_input(self, inputs_info):
+ assert 'x:0' in inputs_info, "Test error: inputs_info must contain `x`"
+ x_shape = inputs_info['x:0']
+ inputs_data = {}
+ inputs_data['x:0'] = rng.uniform(-2.0, 2.0, x_shape).astype(self.x_type)
+ return inputs_data
+
+ def create_expm1_net(self, x_shape, x_type):
+ self.x_type = x_type
+ tf.compat.v1.reset_default_graph()
+ # Create the graph and model
+ with tf.compat.v1.Session() as sess:
+ x = tf.compat.v1.placeholder(x_type, x_shape, 'x')
+ tf.raw_ops.Expm1(x=x)
+ tf.compat.v1.global_variables_initializer()
+ tf_net = sess.graph_def
+
+ return tf_net, None
+
+ @pytest.mark.parametrize('x_shape', [[], [2], [3, 4], [3, 2, 1, 4]])
+ @pytest.mark.parametrize('x_type', [np.float16, np.float32, np.float64])
+ @pytest.mark.precommit
+ @pytest.mark.nightly
+ def test_expm1(self, x_shape, x_type, ie_device, precision, ir_version, temp_dir,
+ use_legacy_frontend):
+ self._test(*self.create_expm1_net(x_shape, x_type),
+ ie_device, precision, ir_version, temp_dir=temp_dir,
+ use_legacy_frontend=use_legacy_frontend)