use crate as cubecl; use crate::prelude::*; #[cube(launch)] fn constant_array_kernel(out: &mut Array, #[comptime] data: Vec) { let array = Array::::from_data(data); if UNIT_POS == 0 { out[0] = array[1]; } } pub fn test_constant_array(client: ComputeClient) { let handle = client.create(f32::as_bytes(&[0.0, 1.0])); let vectorization = 1; constant_array_kernel::launch::( &client, CubeCount::Static(1, 1, 1), CubeDim::default(), unsafe { ArrayArg::from_raw_parts(&handle, 2, vectorization) }, vec![3, 5, 1], ); let actual = client.read(handle.binding()); let actual = f32::from_bytes(&actual); assert_eq!(actual[0], 5.0); } #[allow(missing_docs)] #[macro_export] macro_rules! testgen_constants { () => { use super::*; #[test] #[ignore = "Currently fails to compile in wgsl"] fn test_constant_array() { let client = TestRuntime::client(&Default::default()); cubecl_core::runtime_tests::constants::test_constant_array::(client); } }; }