Skip to content

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

[TFL FE] Add CONV3D op support (#35527)

Anoob3e0b42cd0a6f
diff --git a/src/frontends/tensorflow_common/src/utils.cpp b/src/frontends/tensorflow_common/src/utils.cpp
index d753625e5c5..c0d075f6bf9 100644
--- a/src/frontends/tensorflow_common/src/utils.cpp
+++ b/src/frontends/tensorflow_common/src/utils.cpp
@@ -85,6 +85,7 @@ PadType convert_tf_padding(const frontend::NodeContext& node, const string& tf_p
"AvgPool",
"AvgPool3D",
"CONV_2D",
+ "CONV_3D",
"MAX_POOL_2D",
"AVERAGE_POOL_2D",
"TRANSPOSE_CONV",
@@ -114,7 +115,7 @@ PadType convert_tf_padding(const frontend::NodeContext& node, const string& tf_p
op_type == "MaxPool3D" || op_type == "MaxPoolWithArgmax" || op_type == "ExtractImagePatches" ||
op_type == "DepthwiseConv2dNative" || op_type == "AvgPool" || op_type == "AvgPool3D" ||
op_type == "CONV_2D" || op_type == "MAX_POOL_2D" || op_type == "AVERAGE_POOL_2D" ||
- op_type == "DEPTHWISE_CONV_2D") {
+ op_type == "DEPTHWISE_CONV_2D" || op_type == "CONV_3D") {
if (tf_padding == "SAME") {
// According to the formulas for calculating auto_pad values of the
// Conv layer in the Operation specification,
diff --git a/src/frontends/tensorflow_lite/src/decoder_flatbuffer.cpp b/src/frontends/tensorflow_lite/src/decoder_flatbuffer.cpp
index 4801d0e5463..0621090c36f 100644
--- a/src/frontends/tensorflow_lite/src/decoder_flatbuffer.cpp
+++ b/src/frontends/tensorflow_lite/src/decoder_flatbuffer.cpp
@@ -270,6 +270,24 @@ ov::Any DecoderFlatBuffer::get_attribute(const std::string& name) const {
return "NHWC";
} else if (name == "activation" && m_type == "CONV_2D") {
return EnumNameActivationFunctionType(this->get_attribute(&tflite::Conv2DOptions::fused_activation_function));
+ } else if (name == "strides" && m_type == "CONV_3D") {
+ return std::vector<int64_t>{1,
+ this->get_attribute(&tflite::Conv3DOptions::stride_d),
+ this->get_attribute(&tflite::Conv3DOptions::stride_h),
+ this->get_attribute(&tflite::Conv3DOptions::stride_w),
+ 1};
+ } else if (name == "padding" && m_type == "CONV_3D") {
+ return std::string(EnumNamePadding(this->get_attribute(&tflite::Conv3DOptions::padding)));
+ } else if (name == "dilations" && m_type == "CONV_3D") {
+ return std::vector<int64_t>{1,
+ this->get_attribute(&tflite::Conv3DOptions::dilation_d_factor),
+ this->get_attribute(&tflite::Conv3DOptions::dilation_h_factor),
+ this->get_attribute(&tflite::Conv3DOptions::dilation_w_factor),
+ 1};
+ } else if (name == "data_format" && m_type == "CONV_3D") {
+ return "NDHWC";
+ } else if (name == "activation" && m_type == "CONV_3D") {
+ return EnumNameActivationFunctionType(this->get_attribute(&tflite::Conv3DOptions::fused_activation_function));
} else if (name == "strides" && m_type == "DEPTHWISE_CONV_2D") {
return std::vector<int64_t>{1,
this->get_attribute(&tflite::DepthwiseConv2DOptions::stride_h),
diff --git a/src/frontends/tensorflow_lite/src/op/conv3d.cpp b/src/frontends/tensorflow_lite/src/op/conv3d.cpp
new file mode 100644
index 00000000000..0094aee412a
--- /dev/null
+++ b/src/frontends/tensorflow_lite/src/op/conv3d.cpp
@@ -0,0 +1,32 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#include "common_op_table.hpp"
+#include "op_translation_utils.hpp"
+#include "utils.hpp"
+
+namespace ov {
+namespace frontend {
+namespace tensorflow_lite {
+namespace op {
+
+OutputVector conv3d(const ov::frontend::tensorflow_lite::NodeContext& node) {
+ const auto& decoder = node.get_decoder();
+ FRONT_END_GENERAL_CHECK(node.get_input_size() >= 2,
+ "Unexpected number of input in node of type=",
+ node.get_op_type(),
+ " name=",
+ node.get_name());
+ OutputVector output;
+ get_conv(output, node, decoder, &ov::frontend::tensorflow::op::translate_conv_3d_op, {0, 1, 2, 3, 4});
+ get_bias(output, node, decoder);
+ get_activation(output, decoder);
+ output[0].get_node_shared_ptr()->set_friendly_name(node.get_name());
+ return output;
+}
+
+} // namespace op
+} // namespace tensorflow_lite
+} // namespace frontend
+} // namespace ov
diff --git a/src/frontends/tensorflow_lite/src/op_table.cpp b/src/frontends/tensorflow_lite/src/op_table.cpp
index 3307646e6d2..679b9351bfe 100644
--- a/src/frontends/tensorflow_lite/src/op_table.cpp
+++ b/src/frontends/tensorflow_lite/src/op_table.cpp
@@ -58,7 +58,7 @@ std::map<std::string, CreatorFunction> get_supported_ops() {
// CONCAT_EMBEDDINGS
{"CONCATENATION", DEQUANTIZE_INPUTS(concatenation)},
{"CONV_2D", DEQUANTIZE_INPUTS(conv2d)},
- // CONV_3D
+ {"CONV_3D", DEQUANTIZE_INPUTS(conv3d)},
// CONV_3D_TRANSPOSE
{"COS", translate_unary<opset10::Cos>},
{"CUMSUM", translate_cumsum_op},
diff --git a/src/frontends/tensorflow_lite/src/op_table.hpp b/src/frontends/tensorflow_lite/src/op_table.hpp
index 7ad208c8ed3..fc7e681dced 100644
--- a/src/frontends/tensorflow_lite/src/op_table.hpp
+++ b/src/frontends/tensorflow_lite/src/op_table.hpp
@@ -29,6 +29,7 @@ TFL_OP_CONVERTER(avg_pool_2d);
TFL_OP_CONVERTER(complex_abs);
TFL_OP_CONVERTER(concatenation);
TFL_OP_CONVERTER(conv2d);
+TFL_OP_CONVERTER(conv3d);
TFL_OP_CONVERTER(depthwise_conv2d);
TFL_OP_CONVERTER(dequantize);
TFL_OP_CONVERTER(embedding_lookup);
diff --git a/tests/layer_tests/tensorflow_lite_tests/test_tfl_Conv3D.py b/tests/layer_tests/tensorflow_lite_tests/test_tfl_Conv3D.py
new file mode 100644
index 00000000000..0877c79268b
--- /dev/null
+++ b/tests/layer_tests/tensorflow_lite_tests/test_tfl_Conv3D.py
@@ -0,0 +1,44 @@
+# Copyright (C) 2018-2026 Intel Corporation
+# SPDX-License-Identifier: Apache-2.0
+
+import numpy as np
+import pytest
+import tensorflow as tf
+
+from common.tflite_layer_test_class import TFLiteLayerTest
+
+np.random.seed(42)
+
+test_params = [
+ {'shape': [1, 16, 28, 28, 3], 'ksize': [1, 3, 3, 3, 1], 'strides': (1, 1, 1, 1, 1), 'padding': 'SAME', 'dilations': [1, 1, 1, 1, 1]},
+ {'shape': [1, 18, 230, 230, 3], 'ksize': [1, 7, 7, 3, 1], 'strides': (1, 1, 1, 1, 1), 'padding': 'SAME', 'dilations': [1, 2, 2, 2, 1]},
+ {'shape': [1, 18, 230, 230, 3], 'ksize': [1, 7, 7, 3, 1], 'strides': (1, 1, 2, 2, 1), 'padding': 'SAME', 'dilations': [1, 1, 1, 1, 1]},
+ {'shape': [1, 18, 230, 230, 3], 'ksize': [1, 7, 7, 3, 1], 'strides': (1, 2, 2, 2, 1), 'padding': 'VALID', 'dilations': [1, 1, 1, 1, 1]},
+ {'shape': [1, 16, 112, 112, 64], 'ksize': [1, 1, 1, 64, 1], 'strides': (1, 1, 1, 1, 1), 'padding': 'SAME', 'dilations': [1, 1, 1, 1, 1]},
+ {'shape': [1, 16, 112, 112, 64], 'ksize': [1, 1, 1, 64, 128], 'strides': (1, 1, 2, 2, 1), 'padding': 'VALID', 'dilations': [1, 1, 1, 1, 1]},
+]
+
+
+class TestTFLiteConv3DLayerTest(TFLiteLayerTest):
+ inputs = ["Input"]
+ outputs = ["Conv3D"]
+ allowed_ops = ['CONV_3D']
+
+ def make_model(self, params):
+ assert len(set(params.keys()).intersection({'shape', 'ksize', 'strides',
+ 'padding', 'dilations'})) == 5, \
+ 'Unexpected parameters for test: ' + ','.join(params.keys())
+ tf.compat.v1.reset_default_graph()
+ with tf.compat.v1.Session() as sess:
+ weights = tf.constant(np.random.randn(*params['ksize']), dtype=tf.float32)
+ place_holder = tf.compat.v1.placeholder(params.get('dtype', tf.float32), params['shape'],
+ name=self.inputs[0])
+ tf.nn.conv3d(place_holder, weights, params['strides'], params['padding'], 'NDHWC',
+ params['dilations'], name=self.outputs[0])
+ net = sess.graph_def
+ return net
+
+ @pytest.mark.parametrize("params", test_params)
+ @pytest.mark.nightly
+ def test_conv3d(self, params, ie_device, precision, temp_dir):
+ self._test(ie_device, precision, temp_dir, {**params, 'custom_eps': 0.5})