Skip to main content

cbtop/grammar/
composition.rs

1//! Composition mode (Facets equivalent in Grammar of Graphics).
2
3/// Composition mode (analogous to Facets)
4#[derive(Debug, Clone, PartialEq, Default)]
5pub enum CompositionMode {
6    /// Single execution
7    #[default]
8    None,
9    /// Data parallelism (same op, different data)
10    DataParallel { shards: usize },
11    /// Model parallelism (different ops, same data)
12    ModelParallel { stages: usize },
13    /// Pipeline parallelism
14    Pipeline { depth: usize, overlap: bool },
15    /// Batch processing
16    Batch { batch_size: usize, prefetch: usize },
17}
18
19impl CompositionMode {
20    /// Create data parallel mode
21    pub fn data_parallel(shards: usize) -> Self {
22        CompositionMode::DataParallel { shards }
23    }
24
25    /// Create batch mode
26    pub fn batch(size: usize) -> Self {
27        CompositionMode::Batch {
28            batch_size: size,
29            prefetch: 2,
30        }
31    }
32
33    /// Create pipeline mode
34    pub fn pipeline(depth: usize) -> Self {
35        CompositionMode::Pipeline {
36            depth,
37            overlap: true,
38        }
39    }
40}