use std::marker::PhantomData;
use crate::components::batch::partitioned_matmul::matmul::PartitionedBatchMatmul;
use crate::components::batch::partitioned_matmul::partition::GlobalPartitionMatmul;
use crate::components::batch::{BatchMatmulFamily, CubeCountInputArgs};
use crate::components::global::GlobalMatmulFamily;
use crate::components::{AccG, batch::entry_point::matmul};
use crate::components::{AccS, batch::partitioned_matmul::config::PartitionedBatchConfig};
use crate::components::{
Args, InputRuntimeArg, LhsG, LhsS, MatmulPrecision, MatmulProblem, MatmulSelection, MatmulSpec,
OutputRuntimeArg, RhsG, RhsS,
};
use crate::components::{MatmulLineSizes, MatmulSetupError};
use cubecl_core::prelude::*;
pub struct PartitionedBatchMatmulFamily<GMM: GlobalMatmulFamily, S: GlobalPartitionMatmul> {
_gmm: PhantomData<GMM>,
_s: PhantomData<S>,
}
impl<GMM: GlobalMatmulFamily, S: GlobalPartitionMatmul> BatchMatmulFamily
for PartitionedBatchMatmulFamily<GMM, S>
{
type Matmul<MP: MatmulPrecision> = PartitionedBatchMatmul<MP, GMM::Matmul<MP>, S>;
type Config = PartitionedBatchConfig<GMM::Config>;
fn setup<MP: MatmulPrecision, R: Runtime>(
client: &ComputeClient<R::Server>,
problem: &MatmulProblem,
selection: &MatmulSelection,
line_sizes: &MatmulLineSizes,
) -> Result<Self::Config, MatmulSetupError> {
let global_config = GMM::setup::<MP, R>(client, problem, selection, line_sizes)?;
PartitionedBatchConfig::new(
global_config,
selection
.hypercube_selection
.to_hypercube_config(problem, client.properties().hardware.max_cube_count.clone()),
)
.validate(problem)
}
unsafe fn launch_unchecked<'a, MS: MatmulSpec, R: Runtime>(
client: &ComputeClient<<R as Runtime>::Server>,
cube_dim: CubeDim,
cube_count: CubeCount,
input: InputRuntimeArg<'a, MS, R>,
output: OutputRuntimeArg<'a, MS, R>,
cube_count_input: CubeCountInputArgs<'a, R>,
config: Self::Config,
) {
unsafe {
matmul::launch_unchecked::<
Args<MS>,
LhsG<MS>,
RhsG<MS>,
AccG<MS>,
LhsS<MS>,
RhsS<MS>,
AccS<MS>,
Self,
R,
>(
client,
cube_count,
cube_dim,
input,
output,
cube_count_input,
config,
);
}
}
}