Skip to main content

cubecl_ir/types/
spirv.rs

1use alloc::vec::Vec;
2
3use cubecl_macros_internal::TypeHash;
4use pliron::derive::{format, pliron_type};
5
6use crate::aligned;
7
8#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
9#[derive(Debug, Clone, Copy, TypeHash, PartialEq, Eq, Hash, PartialOrd, Ord)]
10#[format]
11pub enum ClampMode {
12    Undefined,
13    #[format("` ` $0")]
14    Constant(u32),
15    ClampToEdge,
16    Repeat,
17    RepeatMirrored,
18}
19
20#[allow(missing_docs)]
21#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
22#[pliron_type(
23    name = "spirv.tensor_layout",
24    format = "`<` $rank `d, clamp: ` $clamp_mode `>`",
25    generate_get = true,
26    verifier = "succ"
27)]
28pub struct TensorLayoutType {
29    pub rank: usize,
30    pub clamp_mode: ClampMode,
31}
32aligned!(TensorLayoutType, align_of::<u64>()); //Dummy align, ignored in SPIR-V
33
34#[allow(missing_docs)]
35#[derive(Debug, Clone, PartialEq, Eq, Hash)]
36#[pliron_type(
37    name = "spirv.tensor_view",
38    format = "`<` $rank `d, has_dims: ` $has_dims `[` vec($permutation, Char(`,`)) `]`",
39    generate_get = true,
40    verifier = "succ"
41)]
42pub struct TensorViewType {
43    pub rank: usize,
44    pub has_dims: bool,
45    pub permutation: Vec<usize>,
46}
47aligned!(TensorViewType, align_of::<u64>()); //Dummy align, ignored in SPIR-V