pub(crate) mod builder;
mod config;
mod fully_contiguous;
mod layer_separate;
mod physical;
mod serialize;
mod validation;
#[cfg(all(test, feature = "testing-nixl"))]
pub(super) mod tests;
pub use builder::{LayoutKind, PhysicalLayoutBuilder};
pub use config::{BlockDimension, LayoutConfig};
pub use fully_contiguous::FullyContiguousLayout;
pub use layer_separate::LayerSeparateLayout;
pub use physical::{NixlMetadata, PhysicalLayout};
pub use serialize::{
BlockFormat, FullyContiguousDetails, LayerSeparateDetails, LayoutDescriptor, LayoutTypeDetails,
};
pub use validation::{TensorFormat, validate_tensor_shapes, validate_tensor_strides};
use anyhow::Result;
use serde::{Deserialize, Serialize};
pub use crate::block_manager::v2::memory::{MemoryDescriptor, MemoryRegion, OwnedMemoryRegion};
pub trait Layout: Send + Sync + std::fmt::Debug {
fn config(&self) -> &LayoutConfig;
fn memory_regions(&self) -> &[OwnedMemoryRegion];
fn memory_region(
&self,
block_id: usize,
layer_id: usize,
outer_id: usize,
) -> Result<MemoryDescriptor>;
fn required_allocations(&self) -> Vec<usize>;
fn is_fully_contiguous(&self) -> bool;
fn num_blocks(&self) -> usize;
fn num_layers(&self) -> usize;
fn outer_dim(&self) -> usize;
fn page_size(&self) -> usize;
fn inner_dim(&self) -> usize;
fn dtype_width_bytes(&self) -> usize;
fn serialization_details(&self) -> serialize::LayoutTypeDetails;
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum InnerShape {
Unknown,
NHD,
HND,
}