dace icon indicating copy to clipboard operation
dace copied to clipboard

Error in `MapFusion` (Array Branch)

Open philip-paul-mueller opened this issue 1 year ago • 0 comments

Hello, in my #1535 I fixed a bug in the MapFusion transformation, in the "scalar branch". I have now found a new bug, but this time in the "array branch" and it has a different nature. I have tried to come up with a minimal example, but was unable to do so, thus the attached graph is quite large. Nevertheless, I was able to pinpoint the error rather accurately, but I have no idea how to solve it.

Now let's describe the error. Below (initial_state.png in the archive) we see a the state right before things go south. We see that a Map is populating transient dc (inside the map is a nested Map, I think that this at least contributes to the problem) of shape [27, 2, 10]. It is then fed into the second Map which does slicing using a trivial Tasklet, in the end the Map is doing dd = dc[:, 1, :], where dd is the output transient of the lower Map with shape [27, 1, 10]. initial_state

Then MapFusion starts working (intermediate_state.png), it has to introduce a scalar __s0..._dc to fake the existence of dc transient inside the second Map, with a shape of [1, 2, 1]. By the way the transformation only checks if dc is used inside this particular state, it does not check if dc is needed further down, which could also be a bug. As you can see in the picture below (I attached a modified copy of the map_fusion.py file, that contains a breakpoint at the time the intermediate state is generated) this temporary scalar is connected via a Memlet to the Tasklet, but this Memlet is of volume 2, but the Tasklet only expects volume 1. initial_state

The last picture (final_state.png) shows the state after the transformation. As you can see the dc transient has gone and only the temporary transient is there. final_state

To solve this, one would need to to use the original Memlet and manipulate its subset.

Best, Philip

attachement.tar.gz

philip-paul-mueller avatar Feb 29 '24 07:02 philip-paul-mueller