use cudarc::driver::LaunchConfig;
use crate::kernels::MAX_THREADS;
pub use tract_gpu::utils::{compute_broadcast_strides, reshape_to_rank_2, reshape_to_rank_3};
pub fn cuda_launch_cfg_for_cpy(shape: &[usize]) -> LaunchConfig {
let rank = shape.len();
let grid_dim = match rank {
0 => panic!("Unexpected empty shape while build grid size"),
1 => (1, 1, 1),
2 => (shape[0] as _, 1, 1),
3 => (shape[1] as _, shape[0] as _, 1),
4 => (shape[2] as _, shape[1] as _, shape[0] as _),
5 => (shape[2] as u32 * shape[3] as u32, shape[1] as _, shape[0] as _),
6 => (shape[2] as u32 * shape[3] as u32 * shape[4] as u32, shape[1] as _, shape[0] as _),
_ => panic!("Unsupported rank {rank} for cuda copy launch config"),
};
LaunchConfig {
grid_dim,
block_dim: (shape[rank - 1].min(MAX_THREADS) as _, 1, 1),
shared_mem_bytes: 0,
}
}