cubecl_runtime/
feature_set.rs1use crate::{
2 Features, TypeUsage,
3 memory_management::{HardwareProperties, MemoryDeviceProperties},
4};
5use cubecl_common::profile::TimingMethod;
6use cubecl_ir::{SemanticType, StorageType, Type};
7use enumset::EnumSet;
8
9#[derive(Debug)]
12pub struct DeviceProperties {
13 pub features: Features,
15 pub memory: MemoryDeviceProperties,
17 pub hardware: HardwareProperties,
19 pub timing_method: TimingMethod,
21}
22
23impl DeviceProperties {
24 pub fn new(
26 features: Features,
27 memory_props: MemoryDeviceProperties,
28 hardware: HardwareProperties,
29 timing_method: TimingMethod,
30 ) -> Self {
31 DeviceProperties {
32 features,
33 memory: memory_props,
34 hardware,
35 timing_method,
36 }
37 }
38
39 pub fn type_usage(&self, ty: StorageType) -> EnumSet<TypeUsage> {
41 self.features.type_usage(ty)
42 }
43
44 pub fn supports_type(&self, ty: impl Into<Type>) -> bool {
46 self.features.supports_type(ty)
47 }
48
49 pub fn register_type_usage(
51 &mut self,
52 ty: impl Into<StorageType>,
53 uses: impl Into<EnumSet<TypeUsage>>,
54 ) {
55 *self.features.storage_types.entry(ty.into()).or_default() |= uses.into();
56 }
57
58 pub fn register_semantic_type(&mut self, ty: SemanticType) {
60 self.features.semantic_types.insert(ty);
61 }
62}