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

Method launch

cake-core/src/backends/cuda/ops.rs:197–234  ·  view source on GitHub ↗
(
            a: &CudaSlice<T>,
            l_a: &Layout,
            b: &CudaSlice<T>,
            l_b: &Layout,
            c: &CudaSlice<T>,
            l_c: &Layout,
            dev: &CudaDevice,

Source from the content-addressed store, hash-verified

195
196 #[allow(clippy::too_many_arguments)]
197 fn launch<T: DeviceRepr + WithDType>(
198 a: &CudaSlice<T>,
199 l_a: &Layout,
200 b: &CudaSlice<T>,
201 l_b: &Layout,
202 c: &CudaSlice<T>,
203 l_c: &Layout,
204 dev: &CudaDevice,
205 ) -> Result<CudaSlice<T>> {
206 let a = match l_a.contiguous_offsets() {
207 Some((o1, o2)) => a.slice(o1..o2),
208 None => candle_core::bail!("add3: a must be contiguous"),
209 };
210 let b = match l_b.contiguous_offsets() {
211 Some((o1, o2)) => b.slice(o1..o2),
212 None => candle_core::bail!("add3: b must be contiguous"),
213 };
214 let c = match l_c.contiguous_offsets() {
215 Some((o1, o2)) => c.slice(o1..o2),
216 None => candle_core::bail!("add3: c must be contiguous"),
217 };
218 let el = l_a.shape().elem_count();
219 let cfg = LaunchConfig::for_num_elems(el as u32);
220 let func = dev.get_or_load_custom_func(
221 &kernel_name::<T>("add3"),
222 "cake_fused_ops",
223 FUSED_OPS_PTX,
224 )?;
225 let out = unsafe { dev.alloc::<T>(el)? };
226 let mut builder = func.builder();
227 builder.arg(&el);
228 builder.arg(&a);
229 builder.arg(&b);
230 builder.arg(&c);
231 builder.arg(&out);
232 unsafe { builder.launch(cfg) }.w()?;
233 Ok(out)
234 }
235
236 use candle_core::backend::BackendStorage;
237 use candle_core::cuda_backend::CudaStorageSlice as SS;

Callers 4

startMethod · 0.80
onStartCommandMethod · 0.80
fMethod · 0.80
cuda_fwdMethod · 0.80

Calls 1

shapeMethod · 0.80

Tested by

no test coverage detected