class ov::op::v3::TopK


Computes indices and values of the k maximum/minimum values for each slice along specified axis. More…

#include <topk.hpp>

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

    TopK(, , , , , );
    TopK(, , , , , );

    // methods

    "TopK""opset3"op::util::TopKBase OPENVINO_OP(, , );
    virtual std::shared_ptr<Node>const OutputVector& clone_with_new_inputs() const;

    virtual OPENVINO_SUPPRESS_DEPRECATED_START boolconst HostTensorVector&const HostTensorVector& evaluate(

        ) const;

    virtual OPENVINO_SUPPRESS_DEPRECATED_END bool has_evaluate() const;

Inherited Members

    // typedefs

    typedef DiscreteTypeInfo type_info_t;
    typedef std::map<std::string, Any> RTMap;
    typedef TopKMode Mode;
    typedef TopKSortType SortType;

    // methods

    virtual void validate_and_infer_types();
    void constructor_validate_and_infer_types();
    virtual boolAttributeVisitor& visit_attributes();
    virtual const ov::op::AutoBroadcastSpec& get_autob() const;
    virtual bool has_evaluate() const;
    virtual boolconst ov::HostTensorVector&const ov::HostTensorVector& evaluate(, ) const;

    virtual boolconst ov::HostTensorVector&const ov::HostTensorVector&const EvaluationContext& evaluate(

        ) const;

    virtual boolov::TensorVector&const ov::TensorVector& evaluate(, ) const;

    virtual boolov::TensorVector&const ov::TensorVector&const ov::EvaluationContext& evaluate(

        ) const;

    virtual boolov::TensorVector& evaluate_lower() const;
    virtual boolov::TensorVector& evaluate_upper() const;
    virtual boolTensorLabelVector& evaluate_label() const;
    virtual boolOutputVector&const OutputVector& constant_fold(, );
    virtual OutputVector decompose_op() const;
    virtual const type_info_t& get_type_info() const = 0;
    const char \* get_type_name() const;
    voidconst NodeVector& set_arguments();
    voidconst OutputVector& set_arguments();
    voidsize_tconst Output<Node>& set_argument(, );
    voidsize_tconst element::Type&const PartialShape& set_output_type(, , );
    voidsize_t set_output_size();
    void invalidate_values();
    virtual void revalidate_and_infer_types();
    virtual std::string description() const;
    const std::string& get_name() const;
    voidconst std::string& set_friendly_name();
    const std::string& get_friendly_name() const;
    virtual bool is_dynamic() const;
    size_t get_instance_id() const;
    virtual std::ostream&std::ostream&uint32_t write_description(, ) const;
    const std::vector<std::shared_ptr<Node>>& get_control_dependencies() const;
    const std::vector<Node \*>& get_control_dependents() const;
    voidstd::shared_ptr<Node> add_control_dependency();
    voidstd::shared_ptr<Node> remove_control_dependency();
    void clear_control_dependencies();
    void clear_control_dependents();
    voidconst std::shared_ptr<const Node>& add_node_control_dependencies();
    voidconst std::shared_ptr<const Node>& add_node_control_dependents();
    voidstd::shared_ptr<Node> transfer_control_dependents();
    size_t get_output_size() const;
    const element::Type&size_t get_output_element_type() const;
    const element::Type& get_element_type() const;
    const Shape&size_t get_output_shape() const;
    const PartialShape&size_t get_output_partial_shape() const;
    Output<const Node> get_default_output() const;
    Output<Node> get_default_output();
    virtual size_t get_default_output_index() const;
    size_t no_default_index() const;
    const Shape& get_shape() const;
    descriptor::Tensor&size_t get_output_tensor() const;
    descriptor::Tensor&size_t get_input_tensor() const;
    std::set<Input<Node>>size_t get_output_target_inputs() const;
    size_t get_input_size() const;
    const element::Type&size_t get_input_element_type() const;
    const Shape&size_t get_input_shape() const;
    const PartialShape&size_t get_input_partial_shape() const;
    Node \*size_t get_input_node_ptr() const;
    std::shared_ptr<Node>size_t get_input_node_shared_ptr() const;
    Output<Node>size_t get_input_source_output() const;
    virtual std::shared_ptr<Node>const OutputVector& clone_with_new_inputs() const = 0;
    std::shared_ptr<Node>const OutputVector& copy_with_new_inputs() const;

    std::shared_ptr<Node>const OutputVector&const std::vector<std::shared_ptr<Node>>& copy_with_new_inputs(

        ) const;

    boolstd::shared_ptr<const Node> has_same_type() const;
    RTMap& get_rt_info();
    const RTMap& get_rt_info() const;
    NodeVectorbool get_users() const;
    boolconst Node& operator < () const;
    std::vector<Input<Node>> inputs();
    std::vector<Input<const Node>> inputs() const;
    std::vector<Output<Node>> input_values() const;
    std::vector<Output<Node>> outputs();
    std::vector<Output<const Node>> outputs() const;
    Input<Node>size_t input();
    Input<const Node>size_t input() const;
    Output<Node>size_t input_value() const;
    Output<Node>size_t output();
    Output<const Node>size_t output() const;

    virtual boolov::pass::pattern::Matcher \*const Output<Node>&const Output<Node>& match_value(


    virtual boolov::pass::pattern::Matcher \*const Output<Node>& match_node(, );
    static _OPENVINO_HIDDEN_METHODconst ::ov::Node::type_info_t& get_type_info_static();
    virtual const ::ov::Node::type_info_t& get_type_info() const;
    "TopKBase""util" OPENVINO_OP(, );
    virtual void validate_and_infer_types();
    virtual boolAttributeVisitor& visit_attributes();
    uint64_t get_axis() const;
    int64_t get_provided_axis() const;
    voidconst int64_t set_axis();
    voidconst Rank&const int64_t set_axis(, );
    TopKMode get_mode() const;
    voidconst TopKMode set_mode();
    TopKSortType get_sort_type() const;
    voidconst TopKSortType set_sort_type();
    element::Type get_index_element_type() const;
    voidconst element::Type& set_index_element_type();
    size_t get_k() const;
    voidsize_t set_k();
    virtual size_t get_default_output_index() const;

Detailed Documentation

Computes indices and values of the k maximum/minimum values for each slice along specified axis.



Constructs a TopK operation.

TopK(, , , , , )

Constructs a TopK operation with two outputs: values and indices. By default the indices output is described by i32 data type.



The input tensor


Specifies how many maximum/minimum elements should be computed (note: scalar input tensor)


The axis along which to compute top k indices


Specifies which operation (min or max) is used to select the biggest element of two.


Specifies order of output elements and/or indices Accepted values: none, index, value


Specyfies type of produced indices


virtual OPENVINO_SUPPRESS_DEPRECATED_START boolconst HostTensorVector&const HostTensorVector& evaluate(

    ) const

Evaluates the op on input_values putting results in output_values.

Deprecated Use evaluate with ov::Tensor instead



Tensors for the outputs to compute. One for each result


Tensors for the inputs. One for each inputs.


true if successful

virtual OPENVINO_SUPPRESS_DEPRECATED_END bool has_evaluate() const

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