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

Method dispatch_unary_vec4

cake-core/src/backends/vulkan/mod.rs:858–879  ·  view source on GitHub ↗
(&self, x: &Tensor, entry: &str)

Source from the content-addressed store, hash-verified

856 }
857
858 fn dispatch_unary_vec4(&self, x: &Tensor, entry: &str) -> Result<Tensor> {
859 let dtype = x.dtype();
860 let shape = x.shape().clone();
861 let n = x.elem_count();
862
863 let buf_a = self.get_or_upload(x)?;
864 let buf_out = self.alloc_output(n);
865
866 let threads_needed = (n as u32).div_ceil(4);
867 let result = self.dispatch_compute(
868 entry,
869 &[buf_a.buffer, self.dummy_buf.buffer, buf_out.buffer],
870 &buf_out,
871 n,
872 &[n as u32, 0, 0, 0],
873 (threads_needed.div_ceil(WG_ELEM), 1, 1),
874 );
875
876 let tensor = Self::from_f32_vec(result, shape.dims(), dtype)?;
877 self.cache_activation(tensor.id(), buf_out);
878 Ok(tensor)
879 }
880
881 // ── GPU softmax ──────────────────────────────────────────────────
882

Callers 1

stable_softplusMethod · 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