Skip to content

Commit

Permalink
reset over every pass
Browse files Browse the repository at this point in the history
kali committed Oct 20, 2020
1 parent 02c47f2 commit 5722b0d
Showing 2 changed files with 26 additions and 18 deletions.
43 changes: 25 additions & 18 deletions core/src/model/typed.rs
Original file line number Diff line number Diff line change
@@ -127,28 +127,35 @@ impl TypedModel {
for i in 0.. {
model = model.compact()?;
let mut done_something_this_time = false;
for p in passes.iter_mut() {
while let Some(mut patch) = p.next(&model)? {
patch.push_context(format!("{:?}/{}", p, i));
'pass: for p in passes.iter_mut() {
loop {
let mut done_something_this_pass = false;
p.reset()?;
while let Some(mut patch) = p.next(&model)? {
patch.push_context(format!("{:?}/{}", p, i));
#[cfg(debug_assertions)]
{
patch.model.check_consistent_facts()?;
model.check_consistent_facts()?;
patch.model.invariants()?;
model.invariants()?;
}
debug!("applying: {}", patch.context.iter().rev().join(" / "),);
patch.apply(&mut model)?;
done_something_this_pass = true;
done_something_this_time = true;
}
#[cfg(debug_assertions)]
{
patch.model.check_consistent_facts()?;
model.check_consistent_facts()?;
patch.model.invariants()?;
model.invariants()?;
model.check_edges()?;
model
.check_consistent_facts()
.with_context(|| format!("after declutter pass {:?}", p))?
}
if !done_something_this_pass {
continue 'pass;
}
debug!("applying: {}", patch.context.iter().rev().join(" / "),);
patch.apply(&mut model)?;
done_something_this_time = true;
}
#[cfg(debug_assertions)]
{
model.check_edges()?;
model
.check_consistent_facts()
.with_context(|| format!("after declutter pass {:?}", p))?
}
model = model.compact()?;
}
if !done_something_this_time {
return Ok(model);
1 change: 1 addition & 0 deletions core/src/optim/mod.rs
Original file line number Diff line number Diff line change
@@ -65,6 +65,7 @@ impl std::fmt::Debug for OpOptim {

impl TypedPass for OpOptim {
fn reset(&mut self) -> TractResult<()> {
self.2 = 0;
Ok(())
}

0 comments on commit 5722b0d

Please sign in to comment.