Skip to content

Commit

Permalink
clip
Browse files Browse the repository at this point in the history
  • Loading branch information
kali committed Feb 8, 2024
1 parent 8326a8d commit ab3cf83
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 92 deletions.
6 changes: 2 additions & 4 deletions core/src/model/typed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,8 @@ impl SpecialOps<TypedFact, Box<dyn TypedOp>> for TypedModel {
) -> TractResult<OutletId> {
let v = v.into_arc_tensor();
for node in &self.nodes {
if node.op_is::<Const>() {
if node.outputs[0].fact.konst.as_ref() == Some(&v) {
return Ok(node.id.into());
}
if node.op_is::<Const>() && node.outputs[0].fact.konst.as_ref() == Some(&v) {
return Ok(node.id.into());
}
}
let fact = TypedFact::from(v.clone());
Expand Down
2 changes: 1 addition & 1 deletion hir/src/infer/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use super::*;
/// Infers every possible fact when all the values are concrete.
pub fn infer_forward_concrete(
op: &dyn Op,
inputs: &Vec<&InferenceFact>,
inputs: &[&InferenceFact],
) -> TractResult<Option<TVec<InferenceFact>>> {
let input_values: TVec<_> = inputs.iter().filter_map(|t| t.value.concretize()).collect();

Expand Down
86 changes: 0 additions & 86 deletions hir/src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,89 +64,3 @@ macro_rules! valuefact {
fact
}};
}

/// Tries to unwrap an option, or returns Ok(None) otherwise.
#[macro_export]
macro_rules! unwrap_or_none {
($e:expr) => {{
let e = $e;
if e.is_none() {
return Ok(None);
} else {
e.unwrap()
}
}};
}

#[cfg(tests)]
mod tests {
#[test]
fn shape_macro_closed_1() {
assert_eq!(shapefactoid![], ShapeFactoid::closed(tvec![]));
}

#[test]
fn shape_macro_closed_2() {
assert_eq!(shapefactoid![1], ShapeFactoid::closed(tvec![GenericFactoid::Only(1)]));
}

#[test]
fn shape_macro_closed_3() {
assert_eq!(shapefactoid![(1 + 1)], ShapeFactoid::closed(vec![GenericFactoid::Only(2)]));
}

#[test]
fn shape_macro_closed_4() {
assert_eq!(
shapefactoid![_, 2],
ShapeFactoid::closed(vec![GenericFactoid::Any, GenericFactoid::Only(2)])
);
}

#[test]
fn shape_macro_closed_5() {
assert_eq!(
shapefactoid![(1 + 1), _, 2],
ShapeFactoid::closed(vec![
GenericFactoid::Only(2),
GenericFactoid::Any,
GenericFactoid::Only(2),
])
);
}

#[test]
fn shape_macro_open_1() {
assert_eq!(shapefactoid![..], ShapeFactoid::open(tvec![]));
}

#[test]
fn shape_macro_open_2() {
assert_eq!(shapefactoid![1; ..], ShapeFactoid::open(vec![GenericFactoid::Only(1)]));
}

#[test]
fn shape_macro_open_3() {
assert_eq!(shapefactoid![(1 + 1); ..], ShapeFactoid::open(vec![GenericFactoid::Only(2)]));
}

#[test]
fn shape_macro_open_4() {
assert_eq!(
shapefactoid![_, 2; ..],
ShapeFactoid::open(vec![GenericFactoid::Any, GenericFactoid::Only(2)])
);
}

#[test]
fn shape_macro_open_5() {
assert_eq!(
shapefactoid![(1 + 1), _, 2; ..],
ShapeFactoid::open(tvec![
GenericFactoid::Only(2),
GenericFactoid::Any,
GenericFactoid::Only(2),
])
);
}
}
2 changes: 1 addition & 1 deletion pulse/src/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ impl SpecialOps<PulsedFact, Box<dyn PulsedOp>> for PulsedModel {
}
}
}
let op = NonPulsingWrappingOp(Box::new(Const(v.into())));
let op = NonPulsingWrappingOp(Box::new(Const(v)));
Ok(self.wire_node(name, op, &[])?[0])
}
}
Expand Down

0 comments on commit ab3cf83

Please sign in to comment.