Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 2 additions & 2 deletions .github/citation_format_authors.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
Parse the authors file and print for CITATION.cff
"""

with open("AUTHORS", "r") as f:
with open("AUTHORS") as f:
content = f.readlines()

for i, l in enumerate(content[4:]):
if l == "\n":
end_idx = i + 4
break
else:
raise ValueError()
raise ValueError

for author in content[4:end_idx]:
names = author.strip().split()
Expand Down
2 changes: 1 addition & 1 deletion ci/pyfv3_legacy_nested_sdfgs.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

# ndsl refuses to be imported once gt4py's configuration has been read, so it goes first
import ndsl.dsl # noqa: F401
import gt4py.cartesian.backend.dace_backend as dace_backend
from gt4py.cartesian.backend import dace_backend

from dace.sdfg import dealias

Expand Down
1 change: 0 additions & 1 deletion dace/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
# Import hooks from config last (as it may load classes from within dace)
hooks._install_hooks_from_config()

import sys
import os

raw_path = Config.get("external_transformations_path")
Expand Down
2 changes: 1 addition & 1 deletion dace/autodiff/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,4 @@
]

if TORCH_INTEGRATION_AVAILABLE:
__all__.append("make_backward_function")
__all__ += ["make_backward_function"]
16 changes: 8 additions & 8 deletions dace/autodiff/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@
Analysis helpers for autodiff
"""

from typing import Dict, Set, Tuple, Optional
import collections

import networkx as nx

from dace.sdfg import SDFG, SDFGState, nodes, utils as sdfg_utils
from dace.transformation.passes import analysis
from dace.sdfg import SDFG, SDFGState, nodes
from dace.sdfg import utils as sdfg_utils
from dace.sdfg.state import FunctionCallRegion
from dace.transformation.passes import analysis

AccessSets = Dict[SDFGState, Tuple[Set[str], Set[str]]]
AccessSets = dict[SDFGState, tuple[set[str], set[str]]]


def dependency_analysis(sdfg: SDFG) -> Dict[str, Set[str]]:
def dependency_analysis(sdfg: SDFG) -> dict[str, set[str]]:
"""
Analyze read dependencies of arrays in the SDFG.

Expand All @@ -40,11 +40,11 @@ def dependency_analysis(sdfg: SDFG) -> Dict[str, Set[str]]:
dependencies = nx.transitive_closure(dependencies)
result = {}
for array in dependencies:
result[array] = {nbr for nbr in dependencies.neighbors(array)}
result[array] = set(dependencies.neighbors(array))
return result


def inverse_reachability(sdfg: SDFG) -> Dict[SDFGState, Set[SDFGState]]:
def inverse_reachability(sdfg: SDFG) -> dict[SDFGState, set[SDFGState]]:

reachability = analysis.StateReachability().apply_pass(sdfg, {})
inverse_reachability = collections.defaultdict(set)
Expand All @@ -58,7 +58,7 @@ def inverse_reachability(sdfg: SDFG) -> Dict[SDFGState, Set[SDFGState]]:


def is_previously_written(
sdfg: SDFG, state: SDFGState, node: nodes.Node, array_name: str, access_sets: Optional[AccessSets] = None
sdfg: SDFG, state: SDFGState, node: nodes.Node, array_name: str, access_sets: AccessSets | None = None
) -> bool:
"""
Determine whether the given array name was written before the current node.
Expand Down
12 changes: 5 additions & 7 deletions dace/autodiff/autodiff.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
# Copyright 2019-2025 ETH Zurich and the DaCe authors. All rights reserved.
from typing import List, Union, Optional

from dace.autodiff.backward_pass_generator import BackwardPassGenerator

from dace.sdfg import SDFG, nodes
from dace.sdfg.utils import inline_control_flow_regions
from dace.sdfg.state import LoopRegion
from dace.sdfg.utils import inline_control_flow_regions


def add_backward_pass(
sdfg: SDFG,
outputs: List[Union[nodes.AccessNode, str]],
inputs: List[Union[nodes.AccessNode, str]],
outputs: list[nodes.AccessNode | str],
inputs: list[nodes.AccessNode | str],
data_forwarding_strategy: str = "store_all",
data_to_recompute: Optional[List[str]] = None,
data_to_recompute: list[str] | None = None,
simplify: bool = True,
separate_sdfgs: bool = False,
) -> Optional[SDFG]:
) -> SDFG | None:
"""Experimental: Add a backward pass to `state` using reverse-mode automatic differentiation.

``inputs``, ``outputs`` and ``grads`` can be provided either as ``AccessNode`` nodes, or as ``str``, in which
Expand Down
Loading
Loading