select#
Selects value from a tensor based on a 1D index mapping. The 1D index mapping works for any rank tensor. Usually the mapping is provided by find_idx, but any source with the same mapping will work.
-
template<typename T, typename IdxType>
auto __MATX_INLINE__ matx::select(const T &t, IdxType idx)# Helper function to select values from a predicate operator.
select() is used to index from a source operator using indices stored in another operator. This is commonly used with the find_idx executor which returns the indices of values meeting a selection criteria.
- Template Parameters:
T – Input type
IdxType – Operator with indices
- Parameters:
t – Input operator
idx – Index tensor
- Returns:
Value in t from each location in idx
Examples#
(mtie(t1o_idx, num_found) = find_idx(t1, GT{thresh})).run(exec);
// Since we use the output on the host in select() we need to synchronize first
exec.sync();
auto t1o_slice = slice(t1o, {0}, {num_found()});
auto t1o_idx_slice = slice(t1o_idx, {0}, {num_found()});
(t1o_slice = select(t1o_slice, t1o_idx_slice)).run(exec);
// Compare to simply finding the values
(mtie(t1o_2, num_found2) = find(t1, GT{thresh})).run(exec);