Archived
Implement exact DSpark attention and Markov ops
Shared-anchor window attention and full-vocabulary greedy Markov as named ops, with libref oracles. Register the anchor-window kernel constraints.
This commit is contained in:
1 parent
b43088a334
commit
340ff8781a
13 files changed
+723
-19
No files matched your search
@@ -2201,3 +2201,27 @@ extern "C" int r4d_shape_dflash_select(const RadParam* p, int n_p, int operand,
|
||||
};
|
||||
R4D_PICK(l);
|
||||
}
|
||||
|
||||
extern "C" int r4d_shape_dflash_markov(const RadParam* p, int n_p, int operand,
|
||||
RadOpdDesc* out) {
|
||||
const int64_t M = pi(p, n_p, "M");
|
||||
const int64_t steps = pi(p, n_p, "steps");
|
||||
const int64_t R = pi(p, n_p, "rank");
|
||||
const int64_t V = pi(p, n_p, "n_vocab");
|
||||
const int64_t astr = pi(p, n_p, "anchor_stride", 1);
|
||||
const uint32_t D = dt_act(p, n_p, "dtype");
|
||||
if (M <= 0 || steps <= 0 || R <= 0 || V <= 0 || astr < 1)
|
||||
return RAD_E_UNSUPPORTED;
|
||||
const int64_t tiles = (V + 63) / 64;
|
||||
const int64_t rows = M * steps;
|
||||
const RadOpdDesc l[] = {
|
||||
opd(D, rows, V),
|
||||
opd_idx((M - 1) * astr + 1, 0, V),
|
||||
opd(D, V, R),
|
||||
opd(D, V, R),
|
||||
opd((uint32_t)RAD_F32, M, tiles),
|
||||
opd_idx(M, tiles, V),
|
||||
opd_idx(M, steps, V),
|
||||
};
|
||||
R4D_PICK(l);
|
||||
}
|
||||
Reference in new issue
Block a user