Skip to content

Commit

Permalink
Merge branch 'main' into gtir-sdfg-convertible
Browse files Browse the repository at this point in the history
  • Loading branch information
DropD committed Dec 3, 2024
2 parents f8ec8f5 + e5abcd2 commit 5831591
Show file tree
Hide file tree
Showing 43 changed files with 408 additions and 301 deletions.
4 changes: 2 additions & 2 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Delete this comment and add a proper description of the changes contained in thi
- test: Adding missing tests or correcting existing tests
<scope>: cartesian | eve | next | storage
# ONLY if changes are limited to a specific subsytem
# ONLY if changes are limited to a specific subsystem
- PR Description:
Expand All @@ -27,7 +27,7 @@ Delete this comment and add a proper description of the changes contained in thi
## Requirements

- [ ] All fixes and/or new features come with corresponding tests.
- [ ] Important design decisions have been documented in the approriate ADR inside the [docs/development/ADRs/](docs/development/ADRs/Index.md) folder.
- [ ] Important design decisions have been documented in the appropriate ADR inside the [docs/development/ADRs/](docs/development/ADRs/Index.md) folder.

If this PR contains code authored by new contributors please make sure:

Expand Down
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ repos:
- devtools==0.12.2
- diskcache==5.6.3
- factory-boy==3.3.1
- filelock==3.16.1
- frozendict==2.4.6
- gridtools-cpp==2.3.8
- importlib-resources==6.4.5
Expand Down
8 changes: 4 additions & 4 deletions constraints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ executing==2.1.0 # via devtools, stack-data
factory-boy==3.3.1 # via gt4py (pyproject.toml), pytest-factoryboy
faker==33.0.0 # via factory-boy
fastjsonschema==2.20.0 # via nbformat
filelock==3.16.1 # via tox, virtualenv
filelock==3.16.1 # via gt4py (pyproject.toml), tox, virtualenv
fonttools==4.55.0 # via matplotlib
fparser==0.1.4 # via dace
frozendict==2.4.6 # via gt4py (pyproject.toml)
Expand Down Expand Up @@ -113,8 +113,8 @@ psutil==6.1.0 # via -r requirements-dev.in, ipykernel, pytest-xdist
ptyprocess==0.7.0 # via pexpect
pure-eval==0.2.3 # via stack-data
pybind11==2.13.6 # via gt4py (pyproject.toml)
pydantic==2.9.2 # via bump-my-version, pydantic-settings
pydantic-core==2.23.4 # via pydantic
pydantic==2.10.0 # via bump-my-version, pydantic-settings
pydantic-core==2.27.0 # via pydantic
pydantic-settings==2.6.1 # via bump-my-version
pydot==3.0.2 # via tach
pygments==2.18.0 # via -r requirements-dev.in, devtools, ipython, nbmake, rich, sphinx
Expand Down Expand Up @@ -159,7 +159,7 @@ stack-data==0.6.3 # via ipython
stdlib-list==0.10.0 # via tach
sympy==1.13.3 # via dace
tabulate==0.9.0 # via gt4py (pyproject.toml)
tach==0.14.3 # via -r requirements-dev.in
tach==0.14.4 # via -r requirements-dev.in
tomli==2.1.0 ; python_version < "3.11" # via -r requirements-dev.in, black, build, coverage, jupytext, mypy, pip-tools, pyproject-api, pytest, setuptools-scm, tach, tox
tomli-w==1.0.0 # via tach
tomlkit==0.13.2 # via bump-my-version
Expand Down
1 change: 1 addition & 0 deletions min-extra-requirements-test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ deepdiff==5.6.0
devtools==0.6
diskcache==5.6.3
factory-boy==3.3.0
filelock==3.0.0
frozendict==2.3
gridtools-cpp==2.3.8
hypothesis==6.0.0
Expand Down
1 change: 1 addition & 0 deletions min-requirements-test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ deepdiff==5.6.0
devtools==0.6
diskcache==5.6.3
factory-boy==3.3.0
filelock==3.0.0
frozendict==2.3
gridtools-cpp==2.3.8
hypothesis==6.0.0
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ dependencies = [
'devtools>=0.6',
'diskcache>=5.6.3',
'factory-boy>=3.3.0',
'filelock>=3.0.0',
'frozendict>=2.3',
'gridtools-cpp>=2.3.8,==2.*',
"importlib-resources>=5.0;python_version<'3.9'",
Expand Down
8 changes: 4 additions & 4 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ executing==2.1.0 # via -c constraints.txt, devtools, stack-data
factory-boy==3.3.1 # via -c constraints.txt, gt4py (pyproject.toml), pytest-factoryboy
faker==33.0.0 # via -c constraints.txt, factory-boy
fastjsonschema==2.20.0 # via -c constraints.txt, nbformat
filelock==3.16.1 # via -c constraints.txt, tox, virtualenv
filelock==3.16.1 # via -c constraints.txt, gt4py (pyproject.toml), tox, virtualenv
fonttools==4.55.0 # via -c constraints.txt, matplotlib
fparser==0.1.4 # via -c constraints.txt, dace
frozendict==2.4.6 # via -c constraints.txt, gt4py (pyproject.toml)
Expand Down Expand Up @@ -113,8 +113,8 @@ psutil==6.1.0 # via -c constraints.txt, -r requirements-dev.in, ipyk
ptyprocess==0.7.0 # via -c constraints.txt, pexpect
pure-eval==0.2.3 # via -c constraints.txt, stack-data
pybind11==2.13.6 # via -c constraints.txt, gt4py (pyproject.toml)
pydantic==2.9.2 # via -c constraints.txt, bump-my-version, pydantic-settings
pydantic-core==2.23.4 # via -c constraints.txt, pydantic
pydantic==2.10.0 # via -c constraints.txt, bump-my-version, pydantic-settings
pydantic-core==2.27.0 # via -c constraints.txt, pydantic
pydantic-settings==2.6.1 # via -c constraints.txt, bump-my-version
pydot==3.0.2 # via -c constraints.txt, tach
pygments==2.18.0 # via -c constraints.txt, -r requirements-dev.in, devtools, ipython, nbmake, rich, sphinx
Expand Down Expand Up @@ -158,7 +158,7 @@ stack-data==0.6.3 # via -c constraints.txt, ipython
stdlib-list==0.10.0 # via -c constraints.txt, tach
sympy==1.13.3 # via -c constraints.txt, dace
tabulate==0.9.0 # via -c constraints.txt, gt4py (pyproject.toml)
tach==0.14.3 # via -c constraints.txt, -r requirements-dev.in
tach==0.14.4 # via -c constraints.txt, -r requirements-dev.in
tomli==2.1.0 ; python_version < "3.11" # via -c constraints.txt, -r requirements-dev.in, black, build, coverage, jupytext, mypy, pip-tools, pyproject-api, pytest, setuptools-scm, tach, tox
tomli-w==1.0.0 # via -c constraints.txt, tach
tomlkit==0.13.2 # via -c constraints.txt, bump-my-version
Expand Down
7 changes: 7 additions & 0 deletions src/gt4py/cartesian/frontend/gtscript_frontend.py
Original file line number Diff line number Diff line change
Expand Up @@ -1460,6 +1460,13 @@ def visit_Assign(self, node: ast.Assign) -> list:
loc=nodes.Location.from_ast_node(t),
)

if self.backend_name in ["gt:gpu"]:
raise GTScriptSyntaxError(
message=f"Assignment to non-zero offsets in K is not available in {self.backend_name} as an unsolved bug remains."
"Please refer to https://github.com/GridTools/gt4py/issues/1754.",
loc=nodes.Location.from_ast_node(t),
)

if not self._is_known(name):
if name in self.temp_decls:
field_decl = self.temp_decls[name]
Expand Down
1 change: 0 additions & 1 deletion src/gt4py/eve/.gitignore

This file was deleted.

14 changes: 2 additions & 12 deletions src/gt4py/eve/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@
"""

from __future__ import annotations # isort:skip

from __future__ import annotations

from .concepts import (
AnnexManager,
Expand Down Expand Up @@ -89,15 +88,6 @@
"SymbolRef",
"VType",
"register_annex_user",
"# datamodels" "Coerced",
"DataModel",
"FrozenModel",
"GenericDataModel",
"Unchecked",
"concretize",
"datamodel",
"field",
"frozenmodel",
# datamodels
"Coerced",
"DataModel",
Expand All @@ -122,7 +112,7 @@
"pre_walk_values",
"walk_items",
"walk_values",
"# type_definition",
# type_definitions
"NOTHING",
"ConstrainedStr",
"Enum",
Expand Down
6 changes: 3 additions & 3 deletions src/gt4py/eve/codegen.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ def __str__(self) -> str:
class Template(Protocol):
"""Protocol (abstract base class) defining the Template interface.
Direct subclassess of this base class only need to implement the
Direct subclasses of this base class only need to implement the
abstract methods to adapt different template engines to this
interface.
Expand Down Expand Up @@ -654,8 +654,8 @@ def apply( # redefinition of symbol
Args:
root: An IR node.
node_templates (optiona): see :class:`NodeDumper`.
dump_function (optiona): see :class:`NodeDumper`.
node_templates (optional): see :class:`NodeDumper`.
dump_function (optional): see :class:`NodeDumper`.
``**kwargs`` (optional): custom extra parameters forwarded to `visit_NODE_TYPE_NAME()`.
Returns:
Expand Down
4 changes: 2 additions & 2 deletions src/gt4py/eve/datamodels/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
Data Models can be considered as enhanced `attrs <https://www.attrs.org>`_
/ `dataclasses <https://docs.python.org/3/library/dataclasses.html>`_ providing
additional features like automatic run-time type validation. Values assigned to fields
at initialization can be validated with automatic type checkings using the
at initialization can be validated with automatic type checking using the
field type definition. Custom field validation methods can also be added with
the :func:`validator` decorator, and global instance validation methods with
:func:`root_validator`.
Expand All @@ -33,7 +33,7 @@
1. ``__init__()``.
a. If a custom ``__init__`` already exists in the class, it will not be overwritten.
It is your responsability to call ``__auto_init__`` from there to obtain
It is your responsibility to call ``__auto_init__`` from there to obtain
the described behavior.
b. If there is not custom ``__init__``, the one generated by datamodels
will be called first.
Expand Down
16 changes: 8 additions & 8 deletions src/gt4py/eve/datamodels/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@


try:
# For perfomance reasons, try to use cytoolz when possible (using cython)
# For performance reasons, try to use cytoolz when possible (using cython)
import cytoolz as toolz
except ModuleNotFoundError:
# Fall back to pure Python toolz
Expand Down Expand Up @@ -270,7 +270,7 @@ def datamodel(


@overload
def datamodel( # redefinion of unused symbol
def datamodel( # redefinition of unused symbol
cls: Type[_T],
/,
*,
Expand All @@ -289,7 +289,7 @@ def datamodel( # redefinion of unused symbol


# TODO(egparedes): Use @dataclass_transform(eq_default=True, field_specifiers=("field",))
def datamodel( # redefinion of unused symbol
def datamodel( # redefinition of unused symbol
cls: Optional[Type[_T]] = None,
/,
*,
Expand Down Expand Up @@ -867,7 +867,7 @@ def _substitute_typevars(

def _make_counting_attr_from_attribute(
field_attrib: Attribute, *, include_type: bool = False, **kwargs: Any
) -> Any: # attr.s lies a bit in some typing definitons
) -> Any: # attr.s lies a bit in some typing definitions
args = [
"default",
"validator",
Expand Down Expand Up @@ -965,7 +965,7 @@ def _type_converter(value: Any) -> _T:
return value if isinstance(value, type_annotation) else type_annotation(value)
except Exception as error:
raise TypeError(
f"Error during coertion of given value '{value}' for field '{name}'."
f"Error during coercion of given value '{value}' for field '{name}'."
) from error

return _type_converter
Expand Down Expand Up @@ -996,7 +996,7 @@ def _type_converter(value: Any) -> _T:
return _make_type_converter(origin_type, name)

raise exceptions.EveTypeError(
f"Automatic type coertion for {type_annotation} types is not supported."
f"Automatic type coercion for {type_annotation} types is not supported."
)


Expand Down Expand Up @@ -1085,7 +1085,7 @@ def _make_datamodel(
)

else:
# Create field converter if automatic coertion is enabled
# Create field converter if automatic coercion is enabled
converter: TypeConverter = cast(
TypeConverter,
_make_type_converter(type_hint, qualified_field_name) if coerce_field else None,
Expand All @@ -1099,7 +1099,7 @@ def _make_datamodel(
if isinstance(attr_value_in_cls, _KNOWN_MUTABLE_TYPES):
warnings.warn(
f"'{attr_value_in_cls.__class__.__name__}' value used as default in '{cls.__name__}.{key}'.\n"
"Mutable types should not defbe normally used as field defaults (use 'default_factory' instead).",
"Mutable types should not be used as field defaults (use 'default_factory' instead).",
stacklevel=_stacklevel_offset + 2,
)
setattr(
Expand Down
4 changes: 0 additions & 4 deletions src/gt4py/eve/extended_typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,8 @@

from __future__ import annotations

import abc as _abc
import array as _array
import collections.abc as _collections_abc
import ctypes as _ctypes
import dataclasses as _dataclasses
import enum as _enum
import functools as _functools
import inspect as _inspect
import mmap as _mmap
Expand Down
8 changes: 0 additions & 8 deletions src/gt4py/eve/trees.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,6 @@
from .type_definitions import Enum


try:
# For performance reasons, try to use cytoolz when possible (using cython)
import cytoolz as toolz
except ModuleNotFoundError:
# Fall back to pure Python toolz
import toolz # noqa: F401 [unused-import]


TreeKey = Union[int, str]


Expand Down
2 changes: 1 addition & 1 deletion src/gt4py/eve/type_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ def __call__(
# ...
#
# Since this can be an arbitrary type (not something regular like a collection) there is
# no way to check if the type parameter is verifed in the actual instance.
# no way to check if the type parameter is verified in the actual instance.
# The only check can be done at run-time is to verify that the value is an instance of
# the original type, completely ignoring the annotation. Ideally, the static type checker
# can do a better job to try figure out if the type parameter is ok ...
Expand Down
2 changes: 1 addition & 1 deletion src/gt4py/eve/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@


try:
# For perfomance reasons, try to use cytoolz when possible (using cython)
# For performance reasons, try to use cytoolz when possible (using cython)
import cytoolz as toolz
except ModuleNotFoundError:
# Fall back to pure Python toolz
Expand Down
14 changes: 5 additions & 9 deletions src/gt4py/next/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import enum
import os
import pathlib
import tempfile
from typing import Final


Expand Down Expand Up @@ -51,37 +50,34 @@ def env_flag_to_bool(name: str, default: bool) -> bool:
)


_PREFIX: Final[str] = "GT4PY"

#: Master debug flag
#: Changes defaults for all the other options to be as helpful for debugging as possible.
#: Does not override values set in environment variables.
DEBUG: Final[bool] = env_flag_to_bool(f"{_PREFIX}_DEBUG", default=False)
DEBUG: Final[bool] = env_flag_to_bool("GT4PY_DEBUG", default=False)


#: Verbose flag for DSL compilation errors
VERBOSE_EXCEPTIONS: bool = env_flag_to_bool(
f"{_PREFIX}_VERBOSE_EXCEPTIONS", default=True if DEBUG else False
"GT4PY_VERBOSE_EXCEPTIONS", default=True if DEBUG else False
)


#: Where generated code projects should be persisted.
#: Only active if BUILD_CACHE_LIFETIME is set to PERSISTENT
BUILD_CACHE_DIR: pathlib.Path = (
pathlib.Path(os.environ.get(f"{_PREFIX}_BUILD_CACHE_DIR", tempfile.gettempdir()))
/ "gt4py_cache"
pathlib.Path(os.environ.get("GT4PY_BUILD_CACHE_DIR", pathlib.Path.cwd())) / ".gt4py_cache"
)


#: Whether generated code projects should be kept around between runs.
#: - SESSION: generated code projects get destroyed when the interpreter shuts down
#: - PERSISTENT: generated code projects are written to BUILD_CACHE_DIR and persist between runs
BUILD_CACHE_LIFETIME: BuildCacheLifetime = BuildCacheLifetime[
os.environ.get(f"{_PREFIX}_BUILD_CACHE_LIFETIME", "persistent" if DEBUG else "session").upper()
os.environ.get("GT4PY_BUILD_CACHE_LIFETIME", "persistent" if DEBUG else "session").upper()
]

#: Build type to be used when CMake is used to compile generated code.
#: Might have no effect when CMake is not used as part of the toolchain.
CMAKE_BUILD_TYPE: CMakeBuildType = CMakeBuildType[
os.environ.get(f"{_PREFIX}_CMAKE_BUILD_TYPE", "debug" if DEBUG else "release").upper()
os.environ.get("GT4PY_CMAKE_BUILD_TYPE", "debug" if DEBUG else "release").upper()
]
2 changes: 1 addition & 1 deletion src/gt4py/next/ffront/decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ def __call__(self, *args: Any, offset_provider: common.OffsetProvider, **kwargs:
if self.backend is None:
warnings.warn(
UserWarning(
f"Field View Program '{self.definition_stage.definition.__name__}': Using Python execution, consider selecting a perfomance backend."
f"Field View Program '{self.definition_stage.definition.__name__}': Using Python execution, consider selecting a performance backend."
),
stacklevel=2,
)
Expand Down
3 changes: 3 additions & 0 deletions src/gt4py/next/iterator/ir_utils/domain_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from gt4py.next.iterator import ir as itir
from gt4py.next.iterator.ir_utils import ir_makers as im
from gt4py.next.iterator.transforms import trace_shifts
from gt4py.next.iterator.transforms.constant_folding import ConstantFolding


def _max_domain_sizes_by_location_type(offset_provider: Mapping[str, Any]) -> dict[str, int]:
Expand Down Expand Up @@ -168,6 +169,8 @@ def domain_union(*domains: SymbolicDomain) -> SymbolicDomain:
lambda current_expr, el_expr: im.call("maximum")(current_expr, el_expr),
[domain.ranges[dim].stop for domain in domains],
)
# constant fold expression to keep the tree small
start, stop = ConstantFolding.apply(start), ConstantFolding.apply(stop) # type: ignore[assignment] # always an itir.Expr
new_domain_ranges[dim] = SymbolicRange(start, stop)

return SymbolicDomain(domains[0].grid_type, new_domain_ranges)
Loading

0 comments on commit 5831591

Please sign in to comment.