finn icon indicating copy to clipboard operation
finn copied to clipboard

Unnecessary tidy up transforms within transforms

Open Tobi-Alonso opened this issue 5 years ago • 0 comments

Many transforms, like most of the reorder ones, have an unconditional tidy up transform at the end:

   def apply(self, model):
        ...
        
        for n in nodes:
                ...
            if condition:
                ...
                graph_modified = True

        model = model.transform(InferShapes())

To avoid unnecesarry processes, I think it would be better to have :

   def apply(self, model):
        ...
        
        for n in nodes:
                ...
            if condition:
                ...
                graph_modified = True
        if graph_modified:
            model.transform(InferShapes(),make_deepcopy = False)

Like convert_to_hls_layers.py

In this way we would also know if any transformation was applied using input_model == out_model, if we call the top transformation with make_deepcopy = True.

Note: in general I think model.transform(SomeTransf(),make_deepcopy = False) makes more sense than model = model.transform(SomeTransf()). Particularly for big models

Tobi-Alonso avatar Jun 23 '20 08:06 Tobi-Alonso