Skip to content

[backend_cpu] Cloning of graphs fails when the graph contains a Memorize Node with a backend

Description

It looks like creating a graph with a Memorize Operator then setting a backend to the graph and trying to clone it will fail due to a registrar error.

Code example.

The following code sample will fail :

TEST_CASE("[cpu/operator] Memorize Cloning fails", "[Memorize][Clone]") {
        auto memorizeNode = Memorize(5, "memorize");
        auto memorizeNode2 = Memorize(5, "memorize2");

        auto graph = std::make_shared<GraphView>();
        graph->add(memorizeNode);
        graph->compile("cpu", DataType::Float32);

        auto graph2 = std::make_shared<GraphView>();
        graph2->add(memorizeNode2);
    
        REQUIRE_NOTHROW(graph2->clone());
        REQUIRE_NOTHROW(graph->clone());
}

The output :

  REQUIRE_NOTHROW( graph->clone() )
due to unexpected exception with message:
  missing or invalid registrar key:  for registrable object
  N5Aidge11Memorize_OpE
  Did you include/import the corresponding module?
  If so, it is possible that the object is not yet supported.
  
Available registrar keys are:

I have to investigate why, but I would say that it is because of the copy constructor of Memorize, that is calling SET_IMPL_MACRO.