hiddenlayer icon indicating copy to clipboard operation
hiddenlayer copied to clipboard

How to fold when constant is added ?

Open theevann opened this issue 7 years ago • 1 comments

Hello ! How can I write a proper folding rule for this ?

image

I don't know how to remove the "Constant" by including it in a folding since it has no parent...

theevann avatar Feb 04 '19 10:02 theevann

You can remove the constant using the transform: Prune("Constant").

I don't know the rules you have in place already, but based on the image you posted I'm guessing you have something like this:

    Fold("Constant > Unsqueeze", "ConstUnsqueeze")
    Fold("Gather > Unsqueeze", "GatherUnsqueeze")

If so, then you can build on the above as follows:

    # 1. Merge the right branch:
    Fold("Shape > (ConstUnsqueeze | GatherUnsqueeze) > Concat", "RightBranch")

    # 2. Merge the rest
    Fold("Relu > RightBranch > Reshape", "FullBlock")

Use this as a hint only. Since I don't have access to your code, I'm just guessing here.

waleedka avatar Feb 10 '19 03:02 waleedka