* Doc Migration from Gitlab (#1289) * doc migration * fix * Update FakeQuantize_1.md * Update performance_benchmarks.md * Updates graphs for FPGA * Update performance_benchmarks.md * Change DL Workbench structure (#1) * Changed DL Workbench structure * Fixed tags * fixes * Update ie_docs.xml * Update performance_benchmarks_faq.md * Fixes in DL Workbench layout * Fixes for CVS-31290 * [DL Workbench] Minor correction * Fix for CVS-30955 * Added nGraph deprecation notice as requested by Zoe * fix broken links in api doxy layouts * CVS-31131 fixes * Additional fixes * Fixed POT TOC * Update PAC_Configure.md PAC DCP 1.2.1 install guide. * Update inference_engine_intro.md * fix broken link * Update opset.md * fix * added opset4 to layout * added new opsets to layout, set labels for them * Update VisionAcceleratorFPGA_Configure.md Updated from 2020.3 to 2020.4 Co-authored-by: domi2000 <domi2000@users.noreply.github.com>
2.9 KiB
TopK
Versioned name: TopK-3
Category: Sorting and maximization
Short description: TopK computes indices and values of the k maximum/minimum values for each slice along specified axis.
Attributes
-
axis
- Description: Specifies the axis along which
- Range of values: An integer. Negative value means counting dimension from the end.
- Type:
int - Default value: None
- Required: yes
-
mode
- Description: Specifies which operation is used to select the biggest element of two.
- Range of values:
min,max - Type:
string - Default value: None
- Required: yes
-
sort
- Description: Specifies order of output elements and/or indices.
- Range of values:
value,index,none - Type:
string - Default value: None
- Required: yes
-
index_element_type
- Description: the type of output tensor with indices
- Range of values: "i64" or "i32"
- Type: string
- Default value: "i32"
- Required: No
Inputs:
-
1: tensor of arbitrary rank of type T. Required.
-
2: k -- scalar of any integer type specifies how many maximum/minimum elements should be computed. Required
Outputs:
-
1: Output tensor of type T with top k values from the input tensor along specified dimension axis. The shape of the tensor is
[input1.shape[0], ..., input1.shape[axis-1], k, input1.shape[axis+1], ...]. -
2: Output tensor with top k indices for each slice along axis dimension of type T_IND. The shape of the tensor is the same as for the 1st output, that is
[input1.shape[0], ..., input1.shape[axis-1], k, input1.shape[axis+1], ...]
Types
-
T: any numeric type.
-
T_IND:
int64orint32.
Detailed Description
Output tensor is populated by values computes in the following way:
output[i1, ..., i(axis-1), j, i(axis+1) ..., iN] = top_k(input[i1, ...., i(axis-1), :, i(axis+1), ..., iN]), k, sort, mode)
So for each slice input[i1, ...., i(axis-1), :, i(axis+1), ..., iN] which represents 1D array, TopK value is computed individually. Sorting and minimum/maximum are controlled by sort and mode attributes.
Example
<layer ... type="TopK" ... >
<data axis="1" mode="max" sort="value" index_element_type="i64"/>
<input>
<port id="0">
<dim>6</dim>
<dim>12</dim>
<dim>10</dim>
<dim>24</dim>
</port>
<port id="1">
<!-- k = 3 -->
</port>
<output>
<port id="2">
<dim>6</dim>
<dim>3</dim>
<dim>10</dim>
<dim>24</dim>
</port>
<port id="3">
<dim>6</dim>
<dim>3</dim>
<dim>10</dim>
<dim>24</dim>
</port>
</output>
</layer>