Rate This Document
Findability
Accuracy
Completeness
Readability

Select

Function

Select elements from two input tensors based on the true or false judgment of the conditional tensor, and then form a new tensor.

Prototype

1
int Select(bool *cond, T *thenBranch, T *elseBranch, T *output, size_t length);
  • This API accepts only 1D tensors as inputs.
  • Template type T: int64_t is supported. The value range is [–2^63, 2^63 – 1].
  • The valid length of the input pointer is determined by the user.
  • Ensure that the valid spaces of the input pointers do not overlap.

Parameters

Table 1 Parameters

Parameter

Input/Output

Description

Constraint

cond

Input

Judgment condition used for comparison.

This pointer is not null and only 1D tensors are accepted.

thenBranch

Input

Element selected when the condition is true.

This pointer is not null and only 1D tensors are accepted.

elseBranch

Input

Element selected when the condition is false.

This pointer is not null and only 1D tensors are accepted.

output

Input

Output tensor formed when a tensor is determined by the condition judgment.

This pointer is not null and only 1D tensors are accepted.

length

Input

Length of the tensor used for calculation.

The value range is [0, 2^64 – 1]. The length value is equal to the minimum value of the valid space of output, cond, or thenBranch. The value must be checked by the user to prevent security issues such as buffer overflow.