use crate::{DType, Shape};
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct OutputSpec {
pub shape: Shape,
pub dtype: DType,
}
impl OutputSpec {
#[must_use]
pub const fn new(shape: Shape, dtype: DType) -> Self {
Self { shape, dtype }
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct TemplateArg {
pub name: &'static str,
pub value: TemplateValue,
}
impl TemplateArg {
#[must_use]
pub const fn int(name: &'static str, value: i32) -> Self {
Self { name, value: TemplateValue::Int(value) }
}
#[must_use]
pub const fn bool(name: &'static str, value: bool) -> Self {
Self { name, value: TemplateValue::Bool(value) }
}
#[must_use]
pub const fn dtype(name: &'static str, value: DType) -> Self {
Self { name, value: TemplateValue::DType(value) }
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum TemplateValue {
Int(i32),
Bool(bool),
DType(DType),
}
#[derive(Debug, Clone)]
pub struct Dispatch {
pub grid: [usize; 3],
pub threadgroup: [usize; 3],
pub templates: Vec<TemplateArg>,
pub init_value: Option<f32>,
pub verbose: bool,
}
impl Dispatch {
#[must_use]
pub const fn new(grid: [usize; 3], threadgroup: [usize; 3]) -> Self {
Self {
grid,
threadgroup,
templates: Vec::new(),
init_value: None,
verbose: false,
}
}
#[must_use]
pub fn templates(mut self, templates: impl IntoIterator<Item = TemplateArg>) -> Self {
self.templates.extend(templates);
self
}
#[must_use]
pub const fn init_value(mut self, value: f32) -> Self {
self.init_value = Some(value);
self
}
#[must_use]
pub const fn verbose(mut self, verbose: bool) -> Self {
self.verbose = verbose;
self
}
}