sourcelibs/Accel/demos/topk.xtl

1⍝!/usr/bin/env xetal 2⍝ Choices: the position of each row's largest item (the first on a 3⍝ tie) and a mask of each row's two largest, then the two together on 4⍝ a batch of scores: the chosen class and the candidate set. Both are 5⍝ compositions of row reductions, tables and masks, so the GPU runs 6⍝ them with the kernels it has; no new operation. Run with 7⍝ "just demo-lib Accel topk". 8ᵃᶜ⁼u̲se< "Accel" 9m ← 3 4 r̲eshape 5.0 1.0 9.0 9.0 2.0 2.0 2.0 2.0 7.0 8.0 6.0 8.0 10ᵃᶜa̲rgmax m 112 ᵃᶜt̲opk m 121 ᵃᶜt̲opk m 13s ← 4 5 r̲eshape 0.1 0.5 0.15 0.25 0.0 -1.0 2.0 2.0 1.5 0.5 3.0 1.0 2.0 4.0 0.0 0.2 0.1 0.9 0.3 0.4 14ᵃᶜa̲rgmax s 153 ᵃᶜt̲opk s 16s × 3 ᵃᶜt̲opk s