Skip to content

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

[TFLite FE] Clarify public dev API documentation for TFLite Delegate integration (#26688)

Roman Kazantsev423ebd2acb69
diff --git a/src/frontends/tensorflow_lite/include/openvino/frontend/tensorflow_lite/decoder.hpp b/src/frontends/tensorflow_lite/include/openvino/frontend/tensorflow_lite/decoder.hpp
index d77e243d9c8..b3415cf288c 100644
--- a/src/frontends/tensorflow_lite/include/openvino/frontend/tensorflow_lite/decoder.hpp
+++ b/src/frontends/tensorflow_lite/include/openvino/frontend/tensorflow_lite/decoder.hpp
@@ -30,21 +30,39 @@ class DecoderBase : public ov::frontend::DecoderBase {};
class DecoderBaseOperation : public ov::frontend::tensorflow_lite::DecoderBase {
public:
/// \brief Get input tensor name by index
+ /// Operation nodes are connected between each other by tensors.
+ /// Each tensor must have unique name in a graph.
+ /// The tensor name uniqueness is provided by developer during GraphIterator construction.
+ /// This method returns tensor name that comes to this operation node by input index idx
+ /// If idx is out-of-range, it throws std::exception inherited exception
virtual std::string get_input_tensor_name(size_t idx) const = 0;
/// \brief Get input tensor type by index
+ /// If idx is out-of-range, it throws std::exception inherited exception
virtual ov::element::Type get_input_tensor_type(size_t idx) const = 0;
/// \brief Get output tensor name by index
+ /// Operation nodes are connected between each other by tensors.
+ /// Each tensor must have unique name in a graph.
+ /// The tensor name uniqueness is provided by developer during GraphIterator construction.
+ /// This method returns tensor name that outputs by output index idx from this operation
+ /// If idx is out-of-range, it throws std::exception inherited exception
virtual std::string get_output_tensor_name(size_t idx) const = 0;
/// \brief Get output tensor type by index
+ /// If idx is out-of-range, it throws std::exception inherited exception
virtual ov::element::Type get_output_tensor_type(size_t idx) const = 0;
/// \brief Get input tensor info
+ /// returns TensorInfo by input idx index that corresponds to a tensor
+ /// (it can correspond to Constant, Parameter or intermediate tensor connecting a producer and this current node)
+ /// If idx is out-of-range, it throws std::exception inherited exception
virtual TensorMetaInfo get_input_tensor_info(size_t idx) const = 0;
/// \brief Get output tensor info
+ /// returns TensorInfo by output idx index that corresponds to a tensor
+ /// (it can correspond to intermediate tensor connecting this current node and a consumer)
+ /// If idx is out-of-range, it throws std::exception inherited exception
virtual TensorMetaInfo get_output_tensor_info(size_t idx) const = 0;
/// \brief Get a number of outputs
@@ -59,9 +77,15 @@ public:
virtual TensorMetaInfo get_tensor_info() const = 0;
/// \brief Get input index for tensor
+ /// returns index of this input in the list of inputs in the model
+ /// it must be from 0 to n-1, where n - number of inputs in the model
+ /// if it is not input, returns -1
virtual int64_t get_input_idx() const = 0;
/// \brief Get output index for tensor
+ /// returns index of this output in the list of outputs in the model
+ /// it must be from 0 to m-1, where m - number of outputs in the model
+ /// if it is not input, returns -1
virtual int64_t get_output_idx() const = 0;
};
diff --git a/src/frontends/tensorflow_lite/include/openvino/frontend/tensorflow_lite/graph_iterator.hpp b/src/frontends/tensorflow_lite/include/openvino/frontend/tensorflow_lite/graph_iterator.hpp
index 30c39f4db29..8ec2bc3f05c 100644
--- a/src/frontends/tensorflow_lite/include/openvino/frontend/tensorflow_lite/graph_iterator.hpp
+++ b/src/frontends/tensorflow_lite/include/openvino/frontend/tensorflow_lite/graph_iterator.hpp
@@ -13,6 +13,17 @@ namespace frontend {
namespace tensorflow_lite {
/// Abstract representation for an input model graph that gives nodes in topologically sorted order
+/// It returns decoders for model inputs and outputs (DecoderBaseTensor objects) and for operation nodes
+/// (DecoderBaseOperation objects) DecoderBaseOperation objects for operation nodes must be sorted in topological order
+/// from producing nodes to consumer nodes when `get_decoder()` is called. DecoderBaseTensor objects for inputs and
+/// outputs must be returned first by `get_decoder()` method. Order of DecoderBaseTensor objects for inputs and outputs
+/// defines their order in the original model, i.e. model input index and model output index.
+/// For example, calling `get_decoder()` during iterating GraphIterator returns
+/// DecoderBaseTensor (for input 0), ..., DecoderBaseTensor (for input n-1),
+/// DecoderBaseTensor (for output 0), ..., DecoderBaseTensor (for output m-1),
+/// DecoderBaseOperation (for op 1), ..., DecoderBaseOperation (for op k),
+/// where n - number of inputs in the model, m - number of outputs in the model k - number of operation nodes.
+/// NOTE: constants are ignored and no decoder object is returned for constant.
class GraphIterator : ::ov::RuntimeAttribute {
public:
using Ptr = std::shared_ptr<GraphIterator>;