lsils / mockturtle

C++ logic network library
MIT License
202 stars 136 forks source link

`refactoring` using `sop_factoring` assertion fails in `mffc_view` #602

Closed lee30sonia closed 1 year ago

lee30sonia commented 1 year ago

Describe the bug refactoring using sop_factoring assertion fails in mffc_view.

To Reproduce

#include <mockturtle/algorithms/node_resynthesis/sop_factoring.hpp>
#include <mockturtle/algorithms/refactoring.hpp>
#include <mockturtle/algorithms/cleanup.hpp>

#include <mockturtle/networks/aig.hpp>
#include <mockturtle/io/aiger_reader.hpp>
#include <lorina/aiger.hpp>

using namespace mockturtle;

int main( int argc, char* argv[] )
{
  aig_network aig;
  if ( lorina::read_aiger( argv[1], aiger_reader( aig ) ) != lorina::return_code::success )
  {
    std::cerr << "Cannot read\n";
    return -1;
  }

  sop_factoring<aig_network> resyn;
  refactoring( aig, resyn );
  aig = cleanup_dangling( aig );

  return 0;
}

tmp_minimized.aig.zip

Output: Assertion failed: (_inner.size() == _topo.size()), function compute_sets, file mffc_view.hpp, line 271.

mffc_view assumes that the fanout size of every node is stored in its value, but refactoring doesn't seem to maintain these values correctly. Adding the following lines in the foreach_gate loop in refactoring solves the issue (but this is of course inefficient).

ntk.foreach_node( [&]( auto const& n ) {
  ntk.set_value( n, ntk.fanout_size( n ) );
} );

I think the problem comes from the refactoring framework but not sop_factoring, but I didn't try with other node_resynthesis methods.

Check list

aletempiac commented 1 year ago

Same as #571

lee30sonia commented 1 year ago

Right 😅 Then I'm looking forward to the fix :)