How to handle fold of producer with scaling + casting
After PTQ the graph is as follow:
flowchart TD
Input --> Conv
Weights --> Scaling --> Conv
or
flowchart TD
Input --> Conv
Weights --> Scaling --> Cast --> Conv
If we are in true quantize.
For export we will want to fold the weights. To do so we need to set Producers to constant.
A current implementation has been proposed by @noamzerah that set every Producer to constant then apply constant folding: https://gitlab.eclipse.org/eclipse/aidge/aidge_quantization/-/blob/dev/src/PTQ/PTQ.cpp?ref_type=heads#L270-282
Another approache was proposed by @lucaslopez !41 (comment 3112148) In which he walk back the parents of a certain nodes ["FC","Conv1D", "Conv2D", "Conv3D","ConvDepthWise1D", "ConvDepthWise2D", "ConvDepthWise3D"] until he finds a producer.
After some reflexion, I wonder if we could not "just" use graph Matching to set to constant only the producer that are followed by a Scaling node.
What are you thougts @noamzerah @bhalimi @lucaslopez @olivierbichler @pineapple ?