-
Notifications
You must be signed in to change notification settings - Fork 139
Description
Description
In codegen.py
, the SDFG is validated before compilation. However, the SDFG can still be modified after this validation step, and those intermediate changes are not re-validated. This can lead to code being generated from an invalid SDFG, resulting in subtle and unexpected bugs.
For example, as shown in PR #2117, a bug in the GEMM LibraryNode
expansion resulted in an invalid SDFG. The issue was only exposed when sdfg.apply_transformations_once_everywhere(...)
was called during CUDA codegen preprocessing. This method triggers sdfg.validate()
, which then raised an error unrelated to the new transformation itself, but caused by the earlier expansion step that had not been properly validated.
This PR addresses the bug in this specific instance, but similar issues may exist elsewhere. Invalid SDFG states
introduced after the initial validation can go unnoticed and only be caught much later, during code generation or
execution.
Reproduce
If PR #2117 is not yet merged, you can reproduce the issue by replacing this line in the code:
# Recursively expand library nodes that have not yet been expanded
sdfg.expand_library_nodes()
by
# Recursively expand library nodes that have not yet been expanded
sdfg.expand_library_nodes()
sdfg.validate()
and run:
pytest ./tests/library/gemm_test.py --cov-report=xml --cov=dace --tb=short -m "gpu"