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

SDFG class documentation does not match implementation #1563

Closed
tim0s opened this issue Apr 28, 2024 · 2 comments · Fixed by #1571
Closed

SDFG class documentation does not match implementation #1563

tim0s opened this issue Apr 28, 2024 · 2 comments · Fixed by #1571

Comments

@tim0s
Copy link
Contributor

tim0s commented Apr 28, 2024

The SDFG class init method looks like this:

def __init__(self,
                 name: str,
                 constants: Dict[str, Tuple[dt.Data, Any]] = None,
                 propagate: bool = True,
                 parent=None):
        """ Constructs a new SDFG.

            :param name: Name for the SDFG (also used as the filename for
                         the compiled shared library).
            :param symbols: Additional dictionary of symbol names -> types that the SDFG
                            defines, apart from symbolic data sizes.
            :param propagate: If False, disables automatic propagation of
                              memlet subsets from scopes outwards. Saves
                              processing time but disallows certain
                              transformations.
            :param parent: The parent SDFG or SDFG state (for nested SDFGs).
        """

Note that the second argument is named constants in the implementation but symbols in the documentation.
I don't want to just change it because I don't fully understand what is meant here and for me the semantics are different: Constants do not change within their scope of definition, Symbols (as an SDFG concept) can be changed i.e., on interstate edges AFAIU.

@alexnick83
Copy link
Contributor

The documentation is wrong. It should be constants. Symbols are added to SDFGs as follows:

  • Explicitly: call SDFG.add_symbol (please note that direct manipulation of the SDFG.symbols dictionary is also allowed)
  • Implicitly: whenever you add any elements on the SDFG that depend on/refer to specific symbols. For example, in the following code snippet, N will be implicitly added to the SDFG and the output should be {'N': int}:
import dace
N = dace.symbol('N')
sdfg = dace.SDFG('implicit_symbol_test')
sdfg.add_array('A', shape=(N,), dtype=dace.int32)
print(sdfg.symbols)

I will make a PR.

github-merge-queue bot pushed a commit that referenced this issue May 8, 2024
This PR corrects the `SDFG.__init__` docstring to refer to the correct
parameter `constants` (compile-time constants) instead of `symbols`
(scalars that are immutable in the SDFG scope). See also #1563
@tim0s
Copy link
Contributor Author

tim0s commented May 8, 2024

Fixed by #1571

@tim0s tim0s closed this as completed May 8, 2024
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 a pull request may close this issue.

2 participants