Rspress

# #nn.functional.filter

horizon_plugin_pytorch.nn.functional.filter (*inputs: Tuple[Tensor] | Tuple[QTensor], threshold: float, idx_range: Tuple[int, int] | None = None)

Filter.

The output order is different with bpu, because that the compiler do some optimization and slice input following complex rules, which is hard to be done by plugin.

All inputs are filtered along HW by the max value within a range in channel dim of the first input. Each NCHW input is splited, transposed and flattened to List[Tensor[H * W, C]] first. If input is QTensor, the output will be dequantized.

Parameters:

inputs (Union[Tuple[Tensor], Tuple[QTensor]]) – Data in NCHW format. Each input shold have the same size in N, H, W. The output will be selected according to the first input.

threshold (float) – Threshold, the lower bound of output.

idx_range (Optional[Tuple[int, int]]) – The index range of values counted in compare of the first input. Defaults to None which means use all the values.

Returns: A list with same length of batch size, and each element contains:

max_value: Flattened max value within idx_range in channel dim.

max_idx: Flattened max value index in channel dim.

coord: The original coordinates of the output data in the input data in the shape of [M, (h, w)].

(multi) data: Filtered data in the shape of [M, C].

Return type: Union[List[List[Tensor]], List[List[QTensor]]]

页面目录