#[cube]Expand description
Mark a cube function, trait or implementation for expansion.
§Arguments
launch- generates a function to launch the kernellaunch_unchecked- generates a launch function without checksdebug- panics after generation to print the output to consolecreate_dummy_kernel- Generates a function to create a kernel without launching it. Used for testing.harness- generates aharnessfunction that runs the function on a single unit of a runtime and returns its result to the host, so a test can callf::harness::<R>(..)instead of writing a kernel, buffers and a read back by hand. Every parameter must be a scalar, a slice or array of scalars, a comptime scalar or a cube type that derivesCubeHarness, and the function must return them or a tuple of them, or nothing when it writes into a mutable slice. The harness is gated:harness- same asharness(cfg(test))harness(cfg(<predicate>))- compiled under#[cfg(<predicate>)]. The predicate is evaluated in the crate using the macro, sofeature = "..."names one of its features.harness(always)- ungated
§Trait arguments
expand_base_traits- base traits for the expanded “second half” of a trait with methods.
§Example
# use cubecl_macros::cube;
#[cube]
fn my_addition(a: u32, b: u32) -> u32 {
a + b
}§Harness example
#[cube(harness)]
fn add<F: Float>(x: F, y: F) -> F {
x + y
}
#[test]
fn adds() {
assert_eq!(add::harness::<CpuRuntime, f32>(1.0, 2.0), 3.0);
}