Giter Site home page Giter Site logo

gtc's Issues

Change GTC repository layout

Change the layout to have one top-level folder per sub-project.

Example:

REPO/
    gtc/
        src/
            gtc/
        docs/
        tests/
        setup.cfg
        setup.py
        pyproject.toml
        ...

    eve/
        src/
            eve/
        docs/
        tests/
        setup.cfg
        setup.py
        pyproject.toml
        ...

    gt_frontend/
        src/
        docs/
        tests/
        setup.cfg
        setup.py
        pyproject.toml
        ...

    cpputil/  # or gridtools-mesh or any other name
        cmake/
        include/
        tests/
        CMakeLists.txt
        ...

Allow type variables in Nodes

It is sometimes useful to restrict types of fields of fields of a node.

Objectives

  • Reduce the amount of verification boilerplate code inside the translators.
  • Reduce the amount of state to be passed to child nodes inside the translators
  • Elimination of redundant nodes

Pydantic supports this out of the box (see pydantic/pydantic#556 and pydantic/pydantic#595).

Open questions:

  1. How to check for a field type to be a subtype of generic type? This will be a common question if we allow this, but Python does not allow subclass checks with generic, i.e. the following does not work:
from typing import Generic, TypeVar, List
# raises: TypeError: Subscripted generics cannot be used with class and instance checks
issubclass(List[int], List[T])
  1. Consequences of changing the Node base class to GenericModel
  2. Is this compatible with mypy?

Example 1

T = TypeVar('T')
class Constant(GT4PyAstNode, Generic[T]):
    value: T

class ExampleNode:
    some_int_constant: Constant[Int]

Example 2

T = TypeVar('T')

class Stencil(GTScriptAstNode, Generic[T]):
    iteration_spec: List[Union[IterationOrder, LocationSpecification, Interval]]
    body: List[T]

class Computation(GTScriptAstNode):
    name: str
    arguments: List[Argument]
    stencils: List[Union[Stencil[Stencil[Statement]], Stencil[Statement]]]

Update code generator and test it with no mesh concept

Since lookup tables are passed by the user, and they cannot be generally generated, it makes little sense to have a concept for the mesh, and we can just take the mesh as parameter, as we do for the fields. We could treat mesh/neighbor tables as "state" of the computation.

new_infrastructure: Nodes with same field are not distinguished

If I have

class FieldAccess(Expr):
    name: Str

class VarAccess(Expr):
    name: Str

the visitor will not distinguish the 2 nodes. It will enter visit_FieldAccess even for VarAccess. This can be solved by type annotating the visit method's node argument.

However, no such workaround exists for the templates in the TemplatedGenerator. Adding an extra field in one of the 2 classes works, e.g.

class VarAccess(Expr):
    name: Str
    dummy: Optional[str]

Cartesian: SIR, GTGenIR, KSwapIR

  • Extent SIR for structured grids
  • Implement a GTGenIR (an IR close to GridTools code)
  • Implement an IR which allows optimization which are not compatible with GridTools

Change in behavior in "New infrastructure"

In the new_infrastructure branch there is a change in behavior in the code generator.

For a field like
a_field: Optional[List[SomeNode]], if optional is None, the code generator will now expand to N o n e instead of skipping over it. In the template I used ''.join(a_field)

Caching "derived information"

Just as a reminder to discuss it at some point...

Dawn has the concept of derived information which is some extra information computed from the IR and re-used by several transformations. (Things that are expensive to recompute.) Would be interesting to discuss if we could implement such a thing with automatic invalidation.

One example could be dependency graphs.
You would give_me_dependency(some_expression) and it will retrieve it from cache or compute it and store in cache.

This would be only a compiler performance optimization which we shouldn't do now.

Mypy checks with enums

I create this issue to reference from gt4py comments.

@enum.unique
class MyEnum(eve.IntEnum):
    member: 0

reveal(MyEnum.member) # <- int but should be MyEnum

Run this in outside of the eve package (maybe problem also inside?).

@egparedes and I couldn't figure out what's going on, in a short debugging session, but we stopped as it should go away in the next refactoring.

Enums are not typesafe

In my unstructured sir -> naive example I can assign sir.LocationType to a field which requires a naive.LocationType.

Mesh traits and concept helpers

  • is_connectivity

  • maybe has_connectivities (has_iterationspace)

  • type for max_neighbors etc

  • move to mesh.hpp and define LocationType tags (namespace topology)

Validate model from assignment

Currently we only validate a Node on construction, but not if a field is assigned.

For validators this can be enabled in pydantic's config by setting

validate_assignment = True

However it seems this doesn't apply to root_validators. Bug in pydantic?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.