ferrotensor_backend/engine/
misc.rs1use super::{groups64, uniform, ComputeEngine};
4use crate::{UnifiedTensor, WgpuContext};
5
6impl ComputeEngine {
7 pub fn top_k(&self, ctx: &WgpuContext, input: &UnifiedTensor, out_idx: &UnifiedTensor, k: u32) {
11 let params = uniform(ctx, bytemuck::cast_slice(&[k]));
12 self.run(
13 ctx,
14 &self.top_k,
15 &[(0, input.buffer()), (1, out_idx.buffer()), (2, ¶ms)],
16 (1, 1, 1),
17 );
18 }
19
20 pub fn conv1d(
24 &self,
25 ctx: &WgpuContext,
26 input: &UnifiedTensor,
27 weight: &UnifiedTensor,
28 bias: &UnifiedTensor,
29 out: &UnifiedTensor,
30 ) {
31 let dim = weight.shape[0];
32 let seq_len = input.shape[input.shape.len() - 1];
33 let params = uniform(ctx, bytemuck::cast_slice(&[dim as u32, seq_len as u32]));
34 self.run(
35 ctx,
36 &self.conv1d,
37 &[
38 (0, input.buffer()),
39 (1, weight.buffer()),
40 (2, out.buffer()),
41 (3, bias.buffer()),
42 (4, ¶ms),
43 ],
44 groups64(dim * seq_len),
45 );
46 }
47}