use alloc::collections::BTreeSet;
use alloc::vec::Vec;
use crate::compiled::capture::CapturedGraph;
use crate::err::{Error, Result};
use crate::graph::ValueId;
#[derive(Debug, Clone, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize)]
pub struct ShapeBucket {
pub min_shape: Vec<usize>,
pub max_shape: Vec<usize>,
}
impl ShapeBucket {
#[must_use]
pub const fn new(min_shape: Vec<usize>, max_shape: Vec<usize>) -> Self {
Self {
min_shape,
max_shape,
}
}
#[must_use]
pub fn contains(&self, shape: &[usize]) -> bool {
if shape.len() != self.min_shape.len() || shape.len() != self.max_shape.len() {
return false;
}
for (i, &dim) in shape.iter().enumerate() {
if dim < self.min_shape[i] || dim > self.max_shape[i] {
return false;
}
}
true
}
}
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)]
pub struct ConstantFolder;
impl ConstantFolder {
pub fn fold(&self, graph: &CapturedGraph) -> Result<(CapturedGraph, BTreeSet<ValueId>)> {
let _ = graph;
Err(Error::UnsupportedBackendOperation {
op: "compiled.constant_fold",
backend: "compiled-prototype",
})
}
}
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)]
pub struct WeightPrepacker;
impl WeightPrepacker {
pub fn prepack(&self, graph: &CapturedGraph) -> Result<CapturedGraph> {
let _ = graph;
Err(Error::UnsupportedBackendOperation {
op: "compiled.weight_prepack",
backend: "compiled-prototype",
})
}
}