MCPcopy Create free account
hub / github.com/evilsocket/cake / dispatch_binary_vec4

Method dispatch_binary_vec4

cake-core/src/backends/vulkan/mod.rs:803–825  ·  view source on GitHub ↗
(&self, a: &Tensor, b: &Tensor, entry: &str)

Source from the content-addressed store, hash-verified

801 // ── Elementwise dispatch helpers ─────────────────────────────────
802
803 fn dispatch_binary_vec4(&self, a: &Tensor, b: &Tensor, entry: &str) -> Result<Tensor> {
804 let dtype = a.dtype();
805 let shape = a.shape().clone();
806 let n = a.elem_count();
807
808 let buf_a = self.get_or_upload(a)?;
809 let buf_b = self.get_or_upload(b)?;
810 let buf_out = self.alloc_output(n);
811
812 let threads_needed = (n as u32).div_ceil(4);
813 let result = self.dispatch_compute(
814 entry,
815 &[buf_a.buffer, buf_b.buffer, buf_out.buffer],
816 &buf_out,
817 n,
818 &[n as u32, 0, 0, 0],
819 (threads_needed.div_ceil(WG_ELEM), 1, 1),
820 );
821
822 let tensor = Self::from_f32_vec(result, shape.dims(), dtype)?;
823 self.cache_activation(tensor.id(), buf_out);
824 Ok(tensor)
825 }
826
827 fn dispatch_ternary_vec4(
828 &self,

Callers 2

silu_mulMethod · 0.80
exp_mulMethod · 0.80

Calls 7

dtypeMethod · 0.80
shapeMethod · 0.80
alloc_outputMethod · 0.80
dispatch_computeMethod · 0.80
cache_activationMethod · 0.80
cloneMethod · 0.45
get_or_uploadMethod · 0.45

Tested by

no test coverage detected