TopK

TopK  // TopK

v0 C++ Interface

class TopK : public ngraph::op::Op

Public Functions

const NodeTypeInfo &get_type_info() const

Returns the NodeTypeInfo for the node’s class. During transition to type_info, returns a dummy type_info for Node if the class has not been updated yet.

TopK()

Constructs a TopK operation.

TopK(const Output<Node> &arg, size_t top_k_axis, const element::Type &index_element_type, size_t k = 0, bool compute_max = true, SortType sort = SortType::SORT_VALUES)

Constructs a TopK operation.

Parameters
  • arg: The input tensor

  • top_k_axis: The axis along which to compute top k indices

  • index_element_type: produce indices. Currently, only int64 or int32 are supported

  • k: Number of top indices to compute. Compute all indices if k = 0

  • compute_max: Compute top k max or top k min?

  • sort: SortType for sorting results, default - SORT_VALUES

TopK(const Output<Node> &arg, const Output<Node> &k, size_t top_k_axis, const element::Type &index_element_type, bool compute_max = true, SortType sort = SortType::SORT_VALUES)

Constructs a TopK operation.

Parameters
  • arg: The input tensor

  • k: Number of top indices to compute. Compute all indices if k = 0

  • top_k_axis: The axis along which to compute top k indices

  • index_element_type: produce indices. Currently, only int64 or int32 are supported

  • compute_max: Compute top k max or top k min?

  • sort: SortType for sorting results, default - SORT_VALUES

TopK(const Output<Node> &arg, const Output<Node> &k, const Output<Node> &top_k_axis, const element::Type &index_element_type, bool compute_max = true, SortType sort = SortType::NONE)

Constructs a TopK operation.

Parameters
  • arg: The input tensor

  • k: Number of top indices to compute. Compute all indices if k = 0

  • top_k_axis: The axis along which to compute top k indices

  • index_element_type: produce indices. Currently, only int64 or int32 are supported

  • compute_max: Compute top k max or top k min?

  • sort: SortType for sorting results, default - NONE

void validate_and_infer_types()

Throws if the node is invalid.

v1 C++ Interface

class TopK : public ngraph::op::Op

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

Public Functions

const NodeTypeInfo &get_type_info() const

Returns the NodeTypeInfo for the node’s class. During transition to type_info, returns a dummy type_info for Node if the class has not been updated yet.

TopK()

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)

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

Parameters
  • data: The input tensor

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

  • axis: The axis along which to compute top k indices

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

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

  • index_element_type: Specyfies type of produced indices

void validate_and_infer_types()

Throws if the node is invalid.

virtual size_t get_version() const

Return

Version of this node

size_t get_k() const

Returns the value of K, if available.

Note

If the second input to this op is a constant, the value is retrieved and returned. If the input is not constant(dynamic) this method returns 0