コード例 #1
0
ファイル: concepts.py プロジェクト: tehrengruber/gt4py
# All rights reserved.
#
# This file is part the GT4Py project and the GridTools framework.
# GT4Py is free software: you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the
# Free Software Foundation, either version 3 of the License, or any later
# version. See the LICENSE.txt file at the top-level directory of this
# distribution for a copy of the license or check <https://www.gnu.org/licenses/>.
#
# SPDX-License-Identifier: GPL-3.0-or-later

import abc

from gt4py import utils as gt_utils

REGISTRY = gt_utils.Registry()


def from_name(name: str):
    return REGISTRY.get(name, None)


def register(frontend_cls):
    assert issubclass(frontend_cls, Frontend) and frontend_cls.name is not None
    return REGISTRY.register(frontend_cls.name, frontend_cls)


class Frontend(abc.ABC):
    name = None

    @classmethod
コード例 #2
0
# distribution for a copy of the license or check <https://www.gnu.org/licenses/>.
#
# SPDX-License-Identifier: GPL-3.0-or-later

import numpy as np

import gt4py as gt
from gt4py import analysis as gt_analysis
from gt4py import backend as gt_backend
from gt4py import gtscript
from gt4py import ir as gt_ir
from gt4py import storage as gt_storage
from gt4py import utils as gt_utils
from gt4py.definitions import Extent, StencilID

REGISTRY = gt_utils.Registry()
EXTERNALS_REGISTRY = gt_utils.Registry()


def register(func=None, *, externals=None, name=None):
    def _register_decorator(actual_func):
        EXTERNALS_REGISTRY.register(name or actual_func.__name__, externals
                                    or {})
        REGISTRY.register(name or actual_func.__name__, actual_func)
        return actual_func

    return _register_decorator(func) if func else _register_decorator


Field3D = gtscript.Field[np.float_]
Field3DBool = gtscript.Field[np.bool_]