Skip to content

Commit

Permalink
Merge branch 'main' into cartesian/fix/function_inliner_for_while
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianDeconinck authored Sep 27, 2024
2 parents 454cc43 + fb1d494 commit f519b12
Show file tree
Hide file tree
Showing 83 changed files with 2,375 additions and 1,443 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ repos:
- id: insert-license
exclude: ^\..*$
types: [python]
args: [--comment-style, "|#|", --license-filepath, ./LICENSE_HEADER.txt, --fuzzy-match-generates-todo]
args: [--comment-style, "|#|", --license-filepath, ./HEADER.txt, --fuzzy-match-generates-todo]

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
Expand Down
2 changes: 1 addition & 1 deletion CODING_GUIDELINES.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ We highly encourage the [doctest][doctest] format for code examples in docstring
In general, you should structure new Python modules in the following way:

1. _shebang_ line: `#! /usr/bin/env python3` (only for **executable scripts**!).
2. License header (see `LICENSE_HEADER.txt`).
2. License header (see `HEADER.txt`).
3. Module docstring.
4. Imports, alphabetically ordered within each block (fixed automatically by `ruff-formatter`):
1. Block of imports from the standard library.
Expand Down
File renamed without changes.
2 changes: 0 additions & 2 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
GT4Py - GridTools Framework

Copyright (c) 2014-2024, ETH Zurich
All rights reserved.

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ The following backends are supported:

GT4Py can be installed as a regular Python package using `pip` (or any other PEP-517 frontend). As usual, we strongly recommended to create a new virtual environment to work on this project.

The performance backends also require the `Boost <https://www.boost.org/>`\_\_ library, a dependency of [GridTools C++](https://github.com/GridTools/gridtools), which needs to be installed by the user.
The performance backends also require the [Boost](https://www.boost.org) library, a dependency of [GridTools C++](https://github.com/GridTools/gridtools), which needs to be installed by the user.

## ⚙ Configuration

Expand All @@ -54,7 +54,7 @@ Other commonly used environment variables are:
- `GT_CACHE_DIR_NAME`: Name of the compiler's cache directory (defaults to `.gt_cache`)
- `GT_CACHE_ROOT`: Path to the compiler cache (defaults to `./`)

More options and details are available in [`config.py`](https://github.com/GridTools/gt4py/blob/main/src/gt4py/cartesian/config.py>).
More options and details are available in [`config.py`](https://github.com/GridTools/gt4py/blob/main/src/gt4py/cartesian/config.py).

## 📖 Documentation

Expand Down
49 changes: 21 additions & 28 deletions docs/user/next/advanced/HackTheToolchain.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import dataclasses
import typing

from gt4py import next as gtx
from gt4py.next.otf import workflow
from gt4py.next.otf import toolchain, workflow
from gt4py.next.ffront import stages as ff_stages
from gt4py import eve
```

Expand All @@ -13,43 +14,35 @@ from gt4py import eve
## Replace Steps

```python
cached_lowering_toolchain = gtx.backend.DEFAULT_PROG_TRANSFORMS.replace(
past_to_itir=workflow.CachedStep(
step=gtx.ffront.past_to_itir.PastToItirFactory(),
hash_function=eve.utils.content_hash
)
cached_lowering_toolchain = gtx.backend.DEFAULT_TRANSFORMS.replace(
past_to_itir=gtx.ffront.past_to_itir.past_to_itir_factory(cached=False)
)
```

## Skip Steps / Change Order

```python
gtx.backend.DEFAULT_PROG_TRANSFORMS.step_order
DUMMY_FOP = toolchain.CompilableProgram(data=ff_stages.FieldOperatorDefinition(definition=None), args=None)
```

['func_to_past',
'past_lint',
'past_inject_args',
'past_transform_args',
'past_to_itir']
```python
gtx.backend.DEFAULT_TRANSFORMS.step_order(DUMMY_FOP)
```

```python
@dataclasses.dataclass(frozen=True)
class SkipLinting(gtx.backend.ProgramTransformWorkflow):
@property
def step_order(self):
return [
"func_to_past",
# not running "past_lint"
"past_inject_args",
"past_transform_args",
"past_to_itir",
]

same_steps = dataclasses.asdict(gtx.backend.DEFAULT_PROG_TRANSFORMS)
class SkipLinting(gtx.backend.Transforms):
def step_order(self, inp):
order = super().step_order(inp)
if "past_lint" in order:
order.remove("past_lint") # not running "past_lint"
return order

same_steps = dataclasses.asdict(gtx.backend.DEFAULT_TRANSFORMS)
skip_linting_transforms = SkipLinting(
**same_steps
)
skip_linting_transforms.step_order(DUMMY_FOP)
```

## Alternative Factory
Expand All @@ -63,7 +56,7 @@ class Cpp2BindingsGen:

class PureCpp2WorkflowFactory(gtx.program_processors.runners.gtfn.GTFNCompileWorkflowFactory):
translation: workflow.Workflow[
gtx.otf.stages.ProgramCall, gtx.otf.stages.ProgramSource] = MyCodeGen()
gtx.otf.stages.AOTProgram, gtx.otf.stages.ProgramSource] = MyCodeGen()
bindings: workflow.Workflow[
gtx.otf.stages.ProgramSource, gtx.otf.stages.CompilableSource] = Cpp2BindingsGen()

Expand All @@ -72,12 +65,12 @@ PureCpp2WorkflowFactory(cmake_build_type=gtx.config.CMAKE_BUILD_TYPE.DEBUG)

## Invent new Workflow Types

````mermaid
```mermaid
graph LR
IN_T --> i{{split}} --> A_T --> a{{track_a}} --> B_T --> o{{combine}} --> OUT_T
i --> X_T --> x{{track_x}} --> Y_T --> o
```

```python
IN_T = typing.TypeVar("IN_T")
Expand Down Expand Up @@ -126,4 +119,4 @@ class PartiallyModularDiamond(
b=self.track_a(a),
y=self.track_x(x)
)
````
```
Loading

0 comments on commit f519b12

Please sign in to comment.