STRA-338 size-fn: strata-control: part_layout and plan_parts within the limits (fn>30 2 -> 0)
This commit is contained in:
@@ -182,12 +182,7 @@ fn part_layout(
|
||||
.ok_or("KAR part F32 byte count overflow")?;
|
||||
let dimensions = part_dimensions(tensor, part_rows)?;
|
||||
Ok(Layout {
|
||||
name: format!(
|
||||
"{}#strata-part-{:03}-of-{:03}",
|
||||
tensor.name,
|
||||
number + 1,
|
||||
plan.count
|
||||
),
|
||||
name: part_name(tensor, number, plan.count),
|
||||
dimensions,
|
||||
source_byte_offset: cursors.0,
|
||||
source_bytes: part_elements / geometry.block_elements * geometry.block_bytes,
|
||||
@@ -196,6 +191,15 @@ fn part_layout(
|
||||
})
|
||||
}
|
||||
|
||||
fn part_name(tensor: &gguf::TensorInfo, number: u64, count: u64) -> String {
|
||||
format!(
|
||||
"{}#strata-part-{:03}-of-{:03}",
|
||||
tensor.name,
|
||||
number + 1,
|
||||
count
|
||||
)
|
||||
}
|
||||
|
||||
/// The tensor's dimensions with the outermost one replaced by the part's row count.
|
||||
fn part_dimensions(tensor: &gguf::TensorInfo, part_rows: u64) -> Result<Vec<u64>, String> {
|
||||
let mut dimensions = tensor.dimensions.clone();
|
||||
|
||||
@@ -25,6 +25,13 @@ struct ParentHashes {
|
||||
}
|
||||
|
||||
impl ParentHashes {
|
||||
fn new() -> Self {
|
||||
Self {
|
||||
source: Sha256::new(),
|
||||
f32: Sha256::new(),
|
||||
}
|
||||
}
|
||||
|
||||
fn matches(self, original: &derived_mixed::TensorIdentity) -> bool {
|
||||
self.source.finalize().as_slice() == original.source_sha256
|
||||
&& self.f32.finalize().as_slice() == original.f32_sha256
|
||||
@@ -107,10 +114,7 @@ impl<'a> Planner<'a> {
|
||||
source: &mut File,
|
||||
) -> Result<Vec<PartIdentity>, String> {
|
||||
let split = layouts.len() > 1;
|
||||
let mut parent = ParentHashes {
|
||||
source: Sha256::new(),
|
||||
f32: Sha256::new(),
|
||||
};
|
||||
let mut parent = ParentHashes::new();
|
||||
let mut parts = Vec::with_capacity(layouts.len());
|
||||
for part in layouts {
|
||||
if !self.names.insert(part.name.clone()) {
|
||||
|
||||
Reference in New Issue
Block a user