Skip to content

Commit

Permalink
dont try to be smart with axes in block_quant einsum
Browse files Browse the repository at this point in the history
  • Loading branch information
kali committed Aug 23, 2024
1 parent 99ffaa6 commit feb5aff
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 9 deletions.
2 changes: 2 additions & 0 deletions core/src/ops/array/concat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ impl TypedOp for TypedConcat {
fn slice(
&self,
patch: &mut TypedModelPatch,
_model: &TypedModel,
_node: &TypedNode,
prefix: &str,
inputs: &[OutletId],
output_axis: usize,
Expand Down
2 changes: 2 additions & 0 deletions core/src/ops/binary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,8 @@ impl TypedOp for TypedBinOp {
fn slice(
&self,
patch: &mut TypedModelPatch,
_model: &TypedModel,
_node: &TypedNode,
prefix: &str,
inputs: &[OutletId],
_output_axis: usize,
Expand Down
8 changes: 7 additions & 1 deletion core/src/ops/einsum/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -305,13 +305,19 @@ impl TypedOp for EinSum {
fn slice(
&self,
patch: &mut TypedModelPatch,
model: &TypedModel,
node: &TypedNode,
prefix: &str,
inputs: &[OutletId],
_output_axis: usize,
_start: usize,
_end: usize,
) -> TractResult<Option<TVec<OutletId>>> {
patch.wire_node(prefix, self.clone(), inputs).map(Some)
if model.node_input_facts(node.id)?.iter().any(|f| f.datum_type.is_opaque()) {
Ok(None)
} else {
patch.wire_node(prefix, self.clone(), inputs).map(Some)
}
}

#[allow(unused_variables)]
Expand Down
2 changes: 2 additions & 0 deletions core/src/ops/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,8 @@ pub trait TypedOp:
fn slice(
&self,
patch: &mut TypedModelPatch,
model: &TypedModel,
node: &TypedNode,
prefix: &str,
inputs: &[OutletId],
output_axis: usize,
Expand Down
20 changes: 12 additions & 8 deletions core/src/optim/slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,22 @@ impl super::TypedPass for PushSliceUp {
}
wires.push(wire);
}
let Some(wire) = node.op.slice(
&mut patch,
&format!(
"{}.split-over-{}.{}..{}",
&node.name, axis, start, end
),
let Some(wire) = node
.op
.slice(
&mut patch,
model,
node,
&format!("{}.split-over-{}.{}..{}", &node.name, axis, start, end),
&wires,
axis,
start,
*end,
).with_context(|| format!("Calling slice on {node}"))? else {
continue 'axis };
)
.with_context(|| format!("Calling slice on {node}"))?
else {
continue 'axis;
};
splits.push(wire[0]);
start = *end;
}
Expand Down

0 comments on commit feb5aff

Please sign in to comment.