Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix IndexError in memlet propagation #1480

Closed
wants to merge 2 commits into from

Conversation

edopao
Copy link
Collaborator

@edopao edopao commented Dec 13, 2023

During integration of dace v0.15.1 into icon4py, the following exception was raised in SDFG auto-optimize step:

../edopao/gt4py/src/gt4py/next/program_processors/runners/dace_iterator/__init__.py:233: in build_sdfg_from_itir
    sdfg = autoopt.auto_optimize(sdfg, device, symbols=symbols, use_gpu_storage=on_gpu)
../edopao/dace/dace/transformation/auto/auto_optimize.py:575: in auto_optimize
    l2ms = sdfg.apply_transformations_repeated((LoopToMap, RefineNestedAccess),
../edopao/dace/dace/sdfg/sdfg.py:2484: in apply_transformations_repeated
    results = pazz.apply_pass(self, {})
../edopao/dace/dace/transformation/passes/pattern_matching.py:253: in apply_pass
    return self._apply_pass(sdfg, pipeline_results, apply_once=False)
../edopao/dace/dace/transformation/passes/pattern_matching.py:211: in _apply_pass
    self._apply_and_validate(match, sdfg, start, pipeline_results, applied_transformations)
../edopao/dace/dace/transformation/passes/pattern_matching.py:168: in _apply_and_validate
    applied_transformations[type(match).__name__].append(match.apply(graph, tsdfg))
../edopao/dace/dace/transformation/interstate/sdfg_nesting.py:1101: in apply
    propagation.propagate_memlets_state(sdfg, state)
../edopao/dace/dace/sdfg/propagation.py:1202: in propagate_memlets_state
    propagate_memlets_sdfg(node.sdfg)
../edopao/dace/dace/sdfg/propagation.py:1162: in propagate_memlets_sdfg
    propagate_memlets_state(sdfg, state)
../edopao/dace/dace/sdfg/propagation.py:1205: in propagate_memlets_state
    propagate_memlets_nested_sdfg(sdfg, state, node)
../edopao/dace/dace/sdfg/propagation.py:1084: in propagate_memlets_nested_sdfg
    border_memlet.src_subset[i] = fallback_subset[i]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = Range (0:geofac_n2s_shape0_6730), key = 1

    def __getitem__(self, key):
>       return self.ranges.__getitem__(key)
E       IndexError: list index out of range

../edopao/dace/dace/subsets.py:624: IndexError

This error is probably the same as one of the issues reported in #1468. The testcase in this PR allows to reproduce this issue.

This PR is applying a workaround in dace/sdfg/propagation.py, to make the test pass. However, this does not seem to be the proper the solution. This code change is rather a placeholder to highlight where the issue originates.

@edopao edopao linked an issue Dec 13, 2023 that may be closed by this pull request
@edopao
Copy link
Collaborator Author

edopao commented Dec 13, 2023

@phschaad This PR mainly includes a test SDFG to reproduce the issue in memlet propagation. The code change I made is not the fix, but rather a placeholder to highlight where this issue originates. It seems like you have worked on this code, so you maybe have some idea how we can properly fix it?

@edopao edopao requested a review from phschaad December 13, 2023 14:02
@edopao edopao changed the title Fix for IndexError: list index out of range Fix IndexError in memlet propagation Dec 13, 2023
@philip-paul-mueller
Copy link
Collaborator

philip-paul-mueller commented Dec 14, 2023

@edopao
I am not sure if this fix would also work if we slice off a row, i.e. A[idx_X, :]. But, I think it should be relatively easy^{(R)} to implement a general fix that works for that case and also in multiple dimensions.

@edopao
Copy link
Collaborator Author

edopao commented Dec 18, 2023

Not an issue in memlet propagation, the problem was in the test SDFG. The memlet that performed the actual slicing was going from _out to _inp, i.e. in the wrong direction.

@edopao edopao closed this Dec 18, 2023
@edopao edopao deleted the bug-memlet-propagation branch December 18, 2023 15:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

IndexError in memlet propagation
2 participants