use crate::components::global::memory::GlobalIterator;
use crate::components::global::{CopyMechanism, GlobalConfig};
use crate::components::stage::{StridedStage, TilingLayout};
use crate::components::{InvalidConfigError, MatmulIdent, MatrixPrecision};
use cubecl_core as cubecl;
use cubecl_core::prelude::*;
#[cube]
pub trait LoadingJob<IP: MatrixPrecision, TL: TilingLayout>: CubeType + Copy + Clone {
fn execute_task<G: GlobalConfig>(
this: &mut Self,
#[comptime] task_id: u32,
tensor_reader: &GlobalIterator<Line<IP::Global>>,
stage_memory: &mut StridedStage<IP::Stage, TL>,
#[comptime] config: G,
);
fn task_count(this: &Self) -> comptime_type!(u32);
}
#[cube]
pub trait AsyncLoadingJob<IP: MatrixPrecision, TL: TilingLayout>: CubeType + Copy + Clone {
fn execute_task<CM: CopyMechanism, G: GlobalConfig>(
this: &mut Self,
task_id: u32,
tensor_reader: &GlobalIterator<Line<IP::Global>>,
stage_memory: &mut StridedStage<IP::Stage, TL>,
mechanism: &CM,
#[comptime] config: G,
);
fn task_count(this: &Self) -> comptime_type!(u32);
}
pub trait LoadingValidation {
fn check<C: GlobalConfig>(config: &C, ident: MatmulIdent) -> Result<(), InvalidConfigError>;
}
pub struct NoLoadingValidation {}
impl LoadingValidation for NoLoadingValidation {
fn check<C: GlobalConfig>(_config: &C, _ident: MatmulIdent) -> Result<(), InvalidConfigError> {
Ok(())
}
}
#[derive(Default, Copy, Clone, Debug, Hash, PartialEq, Eq)]
pub enum ReaderMode {
Strict,
#[default]
Relaxed,
}