Skip to content

Conversation

@tbennun
Copy link
Collaborator

@tbennun tbennun commented Oct 20, 2025

Refactors C argument construction outside of the CompiledSDFG module. Cleans up the code and additionally enables easy Python structure construction via the following syntax:

# Create data structure
CSR = dace.data.Structure(dict(indptr=dace.int32[M + 1], indices=dace.int32[nnz], data=dace.float32[nnz]),
                          name='CSRMatrix')

# Create a usable argument in calling generated code
s = CSR.make_argument(indptr=arr1, indices=arr2, data=arr3)
# Or from a live object
s = CSR.make_argument_from_object(a)

# DaCe programs can be called directly
dace_program(s)

Syntactic sugar for creating Structures from dataclasses is also supported:

@dataclass
class Inner:
    a: dace.float32[20]
    b: dace.int32

@dataclass
class Outer:
    x: Inner
    y: dace.float64[10, 10]

Struct = dace.data.Structure.from_dataclass(Outer)

@tbennun tbennun changed the title Refactor C argument construction Support making arguments from Structure objects, refactor C argument construction Oct 20, 2025
@tbennun tbennun changed the title Support making arguments from Structure objects, refactor C argument construction Support arguments from Structure objects, refactor C argument construction Oct 20, 2025
@tbennun tbennun changed the title Support arguments from Structure objects, refactor C argument construction Support arguments from Structure objects, refactor arg construction Oct 20, 2025
@tbennun tbennun changed the title Support arguments from Structure objects, refactor arg construction Syntax support for Structures, refactor C argument construction Oct 21, 2025
@tbennun tbennun marked this pull request as ready for review October 21, 2025 00:34
Copy link
Collaborator

@phschaad phschaad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@tbennun tbennun enabled auto-merge October 29, 2025 13:03
@tbennun tbennun disabled auto-merge October 29, 2025 19:33
@tbennun tbennun added this pull request to the merge queue Oct 30, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Oct 30, 2025
@tbennun tbennun enabled auto-merge October 30, 2025 04:59
@tbennun tbennun disabled auto-merge October 30, 2025 06:45
@tbennun tbennun merged commit 29bcb5d into main Oct 30, 2025
7 of 10 checks passed
@tbennun tbennun deleted the loop-range branch October 30, 2025 06:45
philip-paul-mueller added a commit to GridTools/gt4py that referenced this pull request Nov 4, 2025
This PR changes how calls to the underlying `CompiledSDFG` objects are
carried out. Before, the implementation heavily relied on the internal data
format of the DaCe class. However a recent [change in DaCe](spcl/dace#2185) changed this internal data leading to errors, that had to [be patched](GridTools/dace#9).
This PR introduces a more stable fix and builds upon a [refactoring in DaCe](spcl/dace#2206) that beside other things, exposes the tools that were needed by GT4Py to
work independently of the internals.
For that reason this PR also updates the DaCe dependency to `2025.11.04`.

The main change is, that the argument vector, i.e. the C representation
of the arguments used for the call, are no longer managed by
`CompiledSDFG` but instead by GT4Py's `CompiledDaceProgram`.

Co-authored-by: edopao <[email protected]>
sophieblock pushed a commit to sophieblock/dace that referenced this pull request Nov 18, 2025
…cl#2185)

Refactors C argument construction outside of the CompiledSDFG module.
Cleans up the code and additionally enables easy Python structure
construction via the following syntax:
```python
# Create data structure
CSR = dace.data.Structure(dict(indptr=dace.int32[M + 1], indices=dace.int32[nnz], data=dace.float32[nnz]),
                          name='CSRMatrix')

# Create a usable argument in calling generated code
s = CSR.make_argument(indptr=arr1, indices=arr2, data=arr3)
# Or from a live object
s = CSR.make_argument_from_object(a)

# DaCe programs can be called directly
dace_program(s)
```

Syntactic sugar for creating `Structure`s from `dataclass`es is also
supported:
```python
@DataClass
class Inner:
    a: dace.float32[20]
    b: dace.int32

@DataClass
class Outer:
    x: Inner
    y: dace.float64[10, 10]

Struct = dace.data.Structure.from_dataclass(Outer)
```
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.

3 participants