This document is relevant for: Trn2, Trn3
nki.isa.nc_match_replace8#
- nki.isa.nc_match_replace8(dst: NkiTensor, data: NkiTensor, vals: NkiTensor, imm: float, dst_idx: Optional[NkiTensor] = None, name=None)[source]#
Replace first occurrence of each value in
valswithimmindatausing the Vector engine and return the replaced tensor. Ifdst_idxtile is provided, the indices of the matched values are written todst_idx.Behavior with duplicate vals: when
valscontains the same value multiple times within a partition, the instruction processesvalsin reverse order (i = 7, 6, ..., 0), so each occurrence of a duplicate indatais paired with a distinct column ofdst_idx. The first matched data position (smallest input-position index) is written to the highestdst_idxslot among the duplicates, and subsequent occurrences fill lower slots in descending order. For example, withdata = [1, 2, 3, 4, 8, 8, 8, 8, 8, 8, 8]andvals = [3, 8, 8, 8, 8, 8, 8, 8],dst_idxis[2, 10, 9, 8, 7, 6, 5, 4]: column 0 holds the unique match forvals[0] = 3at position 2, and the seven duplicate8values are paired with their seven matching positions[4, 5, 6, 7, 8, 9, 10]in descending order across columns 1-7. This duplicate-vals tie-break is the opposite ofnc_find_index8(), which pairs duplicate vals with their matching positions in ascending order acrossdst_idxcolumns.- Parameters:
dst – output tile with replaced values
data – the data tensor to search and replace in
vals – tensor containing the 8 values per partition to match
imm – the immediate float value to replace matched values with
dst_idx – optional tile to store indices of matched values
This document is relevant for: Trn2, Trn3