logicaffeine_compile/spatial/passes/
mod.rs1pub mod compose;
7pub mod from_q8;
8pub mod from_qwen_ops;
9pub mod from_tensor_op;
10pub mod forward;
11pub mod fuse_generic;
12pub mod fuse_readers;
13pub mod pack;
14pub mod persist;
15pub mod place;
16pub use crate::tensor_graph::front as recognize_stages;
17pub mod section_shape;
18pub mod shard;
19pub mod size_buffers;
20pub mod synthesize_handshakes;
21pub mod tile;
22pub mod verify;
23
24use super::eval::ChoreoFault;
25use super::ir::{AccPolicy, GroupId, IrViolation, Site};
26use super::target::{HandshakeKind, Interconnect};
27use crate::codegen_sva::fabric_target::Precision;
28use crate::tensor_recognize::{ElementwiseReject, MatmulReject, ReductionReject};
29
30#[derive(Clone, Debug, PartialEq)]
32pub enum SpatialReject {
33 Parse(String),
34 Unrecognized {
35 matmul: MatmulReject,
36 elementwise: ElementwiseReject,
37 reduction: ReductionReject,
38 },
39 NotLowered(&'static str),
40 MissingCompute {
41 needed: &'static str,
42 target: &'static str,
43 },
44 MissingPrecision {
45 needed: Precision,
46 target: &'static str,
47 },
48 MissingHandshake {
49 needed: HandshakeKind,
50 target: &'static str,
51 },
52 MissingInterconnect {
53 needed: Interconnect,
54 target: &'static str,
55 },
56 NoLegalTiling {
57 rows_t: usize,
58 cols_t: usize,
59 k_tiles: usize,
60 acc_tiles: usize,
61 sites: usize,
62 },
63 LocalMemExceeded {
64 site: Site,
65 needed_bytes: usize,
66 budget_bytes: usize,
67 },
68 AccTilesExceeded {
69 needed: usize,
70 available: usize,
71 acc: AccPolicy,
72 },
73 TooManyEngines {
74 site: Site,
75 needed: usize,
76 available: u8,
77 },
78 GroupCountMismatch {
79 group: GroupId,
80 counts: Vec<(Site, usize)>,
81 },
82 WrongPhase {
83 pass: &'static str,
84 expected: &'static str,
85 found: super::ir::Phase,
86 },
87 Unverified(ChoreoFault),
88 Invalid(IrViolation),
89 ScalarFrontEnd(String),
92 NotQ8_0 {
94 weight: String,
95 },
96}
97
98impl From<IrViolation> for SpatialReject {
99 fn from(v: IrViolation) -> Self {
100 SpatialReject::Invalid(v)
101 }
102}
103
104pub const LV_ITEM_Y: super::ir::LoopVar = super::ir::LoopVar(0);
106pub const LV_ITEM_X: super::ir::LoopVar = super::ir::LoopVar(1);
107pub const LV_KBLOCK: super::ir::LoopVar = super::ir::LoopVar(2);
108pub const LV_SUB_H: super::ir::LoopVar = super::ir::LoopVar(3);
109pub const LV_SUB_W: super::ir::LoopVar = super::ir::LoopVar(4);
110pub const LV_ITEM: super::ir::LoopVar = super::ir::LoopVar(5);
111
112pub const LV_GEN_ROW: super::ir::LoopVar = super::ir::LoopVar(6);
118pub const LV_GEN_COL: super::ir::LoopVar = super::ir::LoopVar(7);
119pub const LV_GEN_K: super::ir::LoopVar = super::ir::LoopVar(8);