argmax

fun argmax(source: Tensor, result: Tensor)

Compute argmax operation on tensor, giving the indices of max element of the input tensor per channel.

Parameters

source

The input to argmax. It must be a multi-dimensional tensor, of C channel(s).

result

The required result, to store the indices of the max elements among each of the source's C channel(s). The result must be a multi-dimensional tensor of D channels, where D is the number of dimensions in source. The result must contain C elements, each of which is a D-channel index, i.e., C * D values in total. The data type must be one of integral types.

Throws

If the usage is not allowed by the SpatialML run-time Framework, or if the framework encounter internal error and cannot perform the requested behavior.

For example, the source may be 1-channel 2x3 tensor: [[1, 2, 3], [6, 5, 4]], where the argmax is the index of "6": (1, 0). Hence, the result should be of a 2-channel tensor of dimensions: 1x1, in order to store this (1, 0) value.

If the source is a 2-channel tensor instead, for example:

  • 1st channel: `` [[1, 2, 3], [6, 5, 4]] ``

  • 2nd channel: `` [[4, 5, 6], [1, 2, 3]] ``

  • 3rd channel: `` [[1, 3, 5], [4, 6, 2]] `` As the argmax is performed per-channel, the argmax result on the 1st channel is (1, 0), (0, 2) on the 2nd and (1, 1) on the 3rd. In this case, the result is expected to store all three dual-value indices, so it should be a 2-channel tensor, of dimensions such as 1x3, 3x1, 1x3x1, etc. For example, if the result is a 2-channel tensor of dimensions 1x3, its content after the operation will be

[
[(1,0), (0,2), (1,1)],
]