Class ov::op::v11::TopK

class TopK : public ov::op::util::TopKBase

Computes the top K elements of a given tensor along the specified axis.

Public Functions

TopK() = default

Constructs a TopK operation.

TopK(const Output<Node> &data, const Output<Node> &k, const int64_t axis, const std::string &mode, const std::string &sort, const element::Type &index_element_type = element::i32, const bool stable = false)

Constructs a TopK operation with two outputs: values and indices.

Parameters
  • data – The input tensor

  • k – Specifies how many maximum/minimum elements should be computed

  • axis – The axis along which the TopK operation should be executed

  • mode – Specifies whether TopK selects the largest or the smallest elements from each slice

  • sort – Specifies the order of corresponding elements of the output tensor

  • index_element_type – Specifies the data type of the elements in the ‘indices’ output tensor.

  • stable – Specifies whether the equivalent elements should maintain their relative order from the input tensor during sorting.

TopK(const Output<Node> &data, const Output<Node> &k, const int64_t axis, const TopKMode mode, const TopKSortType sort, const element::Type &index_element_type = element::i32, const bool stable = false)

Constructs a TopK operation with two outputs: values and indices.

Parameters
  • data – The input tensor

  • k – Specifies how many maximum/minimum elements should be computed

  • axis – The axis along which the TopK operation should be executed

  • mode – Specifies whether TopK selects the largest or the smallest elements from each slice

  • sort – Specifies the order of corresponding elements of the output tensor

  • index_element_type – Specifies the data type of the elements in the ‘indices’ output tensor.

  • stable – Specifies whether the equivalent elements should maintain their relative order from the input tensor during sorting.

virtual void validate_and_infer_types() override

Verifies that attributes and inputs are consistent and computes output shapes and element types. Must be implemented by concrete child classes so that it can be run any number of times.

Throws if the node is invalid.

virtual bool has_evaluate() const override

Allows to get information about availability of evaluate method for the current operation.