gt4py.cartesian.gtc package

Subpackages

Submodules

gt4py.cartesian.gtc.common module

class gt4py.cartesian.gtc.common.AbsoluteKIndex(*, k: int | ExprT)[source]

Bases: GenericNode, Generic[ExprT]

Access a field with absolute K

Restrictions: - Centered I/J - No data dimensions - Read-only

k: int | ExprT
offset_expr_is_int(_attribute: Attribute, value: Any) → None[source]
to_dict() → Dict[str, int | None][source]
classmethod update_forward_refs(localns: dict[str, Any] | None = None) → type[_DataModelT]

Update Data Model class meta-information replacing forwarded type annotations with actual types.

Parameters:

localns – locals dict used in the evaluation of the annotations (globals are automatically taken from model.__module__).

Returns:

The provided class (so it can be used as a decorator too).

class gt4py.cartesian.gtc.common.AbsoluteKIndex__Expr(*, k: int | Expr)

Bases: AbsoluteKIndex

k: int | Expr
classmethod update_forward_refs(localns: dict[str, Any] | None = None) → type[_DataModelT]

Update Data Model class meta-information replacing forwarded type annotations with actual types.

Parameters:

localns – locals dict used in the evaluation of the annotations (globals are automatically taken from model.__module__).

Returns:

The provided class (so it can be used as a decorator too).

class gt4py.cartesian.gtc.common.ArithmeticOperator(*values)[source]

Bases: StrEnum

Arithmetic operators.

ADD = '+'
DIV = '/'
MATMULT = '@'
MUL = '*'
SUB = '-'
class gt4py.cartesian.gtc.common.AssignStmt(*, left: TargetT, right: ExprT)[source]

Bases: GenericNode, Generic[TargetT, ExprT]

left: TargetT
right: ExprT
classmethod update_forward_refs(localns: dict[str, Any] | None = None) → type[_DataModelT]

Update Data Model class meta-information replacing forwarded type annotations with actual types.

Parameters:

localns – locals dict used in the evaluation of the annotations (globals are automatically taken from model.__module__).

Returns:

The provided class (so it can be used as a decorator too).

class gt4py.cartesian.gtc.common.AssignStmt__FieldAccess_Expr(*, left: FieldAccess, right: Expr)

Bases: AssignStmt

left: FieldAccess
right: Expr
classmethod update_forward_refs(localns: dict[str, Any] | None = None) → type[_DataModelT]

Update Data Model class meta-information replacing forwarded type annotations with actual types.

Parameters:

localns – locals dict used in the evaluation of the annotations (globals are automatically taken from model.__module__).

Returns:

The provided class (so it can be used as a decorator too).

class gt4py.cartesian.gtc.common.AssignStmt__VectorLValue_Expr(*, left: VectorLValue, right: Expr)

Bases: AssignStmt

left: VectorLValue
right: Expr
classmethod update_forward_refs(localns: dict[str, Any] | None = None) → type[_DataModelT]

Update Data Model class meta-information replacing forwarded type annotations with actual types.

Parameters:

localns – locals dict used in the evaluation of the annotations (globals are automatically taken from model.__module__).

Returns:

The provided class (so it can be used as a decorator too).

class gt4py.cartesian.gtc.common.AssignStmt__gt4py_cartesian_gtc_gtcpp_gtcpp_localaccess_gt4py_cartesian_gtc_gtcpp_gtcpp_accessorref_Expr(*, left: LocalAccess | AccessorRef, right: Expr)

Bases: AssignStmt

left: LocalAccess | AccessorRef
right: Expr
classmethod update_forward_refs(localns: dict[str, Any] | None = None) → type[_DataModelT]

Update Data Model class meta-information replacing forwarded type annotations with actual types.

Parameters:

localns – locals dict used in the evaluation of the annotations (globals are automatically taken from model.__module__).

Returns:

The provided class (so it can be used as a decorator too).

class gt4py.cartesian.gtc.common.AssignStmt__gt4py_cartesian_gtc_oir_scalaraccess_gt4py_cartesian_gtc_oir_fieldaccess_Expr(*, left: ScalarAccess | FieldAccess, right: Expr)

Bases: AssignStmt

left: ScalarAccess | FieldAccess
right: Expr
classmethod update_forward_refs(localns: dict[str, Any] | None = None) → type[_DataModelT]

Update Data Model class meta-information replacing forwarded type annotations with actual types.

Parameters:

localns – locals dict used in the evaluation of the annotations (globals are automatically taken from model.__module__).

Returns:

The provided class (so it can be used as a decorator too).

class gt4py.cartesian.gtc.common.AssignmentKind(*values)[source]

Bases: StrEnum

Kind of assignment: plain or combined with operations.

ADD = '+='
DIV = '/='
MUL = '*='
PLAIN = '='
SUB = '-='
class gt4py.cartesian.gtc.common.AxisBound(*, level: LevelMarker, offset: int = 0)[source]

Bases: BaseAxisBound

_abc_impl = <_abc._abc_data object>
classmethod end(offset: int = 0) → AxisBound[source]
classmethod from_end(offset: int) → AxisBound[source]
classmethod from_start(offset: int) → AxisBound[source]
level: LevelMarker
offset: int
classmethod start(offset: int = 0) → AxisBound[source]
classmethod update_forward_refs(localns: dict[str, Any] | None = None) → type[_DataModelT]

Update Data Model class meta-information replacing forwarded type annotations with actual types.

Parameters:

localns – locals dict used in the evaluation of the annotations (globals are automatically taken from model.__module__).

Returns:

The provided class (so it can be used as a decorator too).

class gt4py.cartesian.gtc.common.BaseAxisBound(*, level: LevelMarker, offset: ScalarAccess | FieldAccess | int)[source]

Bases: Node, ABC

_abc_impl = <_abc._abc_data object>
level: LevelMarker
offset: ScalarAccess | FieldAccess | int
classmethod update_forward_refs(localns: dict[str, Any] | None = None) → type[_DataModelT]

Update Data Model class meta-information replacing forwarded type annotations with actual types.

Parameters:

localns – locals dict used in the evaluation of the annotations (globals are automatically taken from model.__module__).

Returns:

The provided class (so it can be used as a decorator too).

class gt4py.cartesian.gtc.common.BinaryOp(*, op: ArithmeticOperator | ComparisonOperator | LogicalOperator, left: ExprT, right: ExprT)[source]

Bases: GenericNode, Generic[ExprT]

Generic binary operation with type propagation.

The generic BinaryOp already contains logic for - strict type checking if the dtype for left and right is set. - type propagation (taking operator type into account).

classmethod kind_propagation(instance: BinaryOp) → None[source]
left: ExprT
op: ArithmeticOperator | ComparisonOperator | LogicalOperator
right: ExprT
classmethod update_forward_refs(localns: dict[str, Any] | None = None) → type[_DataModelT]

Update Data Model class meta-information replacing forwarded type annotations with actual types.

Parameters:

localns – locals dict used in the evaluation of the annotations (globals are automatically taken from model.__module__).

Returns:

The provided class (so it can be used as a decorator too).

class gt4py.cartesian.gtc.common.BinaryOp__Expr(*, op: ArithmeticOperator | ComparisonOperator | LogicalOperator, left: Expr, right: Expr)

Bases: BinaryOp

left: Expr
right: Expr
classmethod update_forward_refs(localns: dict[str, Any] | None = None) → type[_DataModelT]

Update Data Model class meta-information replacing forwarded type annotations with actual types.

Parameters:

localns – locals dict used in the evaluation of the annotations (globals are automatically taken from model.__module__).

Returns:

The provided class (so it can be used as a decorator too).

class gt4py.cartesian.gtc.common.BlockStmt(*, body: List[StmtT])[source]

Bases: GenericNode, SymbolTableTrait, Generic[StmtT]

body: List[StmtT]
classmethod update_forward_refs(localns: dict[str, Any] | None = None) → type[_DataModelT]

Update Data Model class meta-information replacing forwarded type annotations with actual types.

Parameters:

localns – locals dict used in the evaluation of the annotations (globals are automatically taken from model.__module__).

Returns:

The provided class (so it can be used as a decorator too).

class gt4py.cartesian.gtc.common.BlockStmt__Stmt(*, body: List[Stmt])

Bases: BlockStmt

body: List[Stmt]
classmethod update_forward_refs(localns: dict[str, Any] | None = None) → type[_DataModelT]

Update Data Model class meta-information replacing forwarded type annotations with actual types.

Parameters:

localns – locals dict used in the evaluation of the annotations (globals are automatically taken from model.__module__).

Returns:

The provided class (so it can be used as a decorator too).

class gt4py.cartesian.gtc.common.BuiltInLiteral(*values)[source]

Bases: StrEnum

FALSE = 'false'
MAX_VALUE = 'max'
MIN_VALUE = 'min'
ONE = 'one'
TRUE = 'true'
ZERO = 'zero'
class gt4py.cartesian.gtc.common.CartesianOffset(*, i: int, j: int, k: int)[source]

Bases: Node

i: int
j: int
k: int
to_dict() → Dict[str, int][source]
classmethod update_forward_refs(localns: dict[str, Any] | None = None) → type[_DataModelT]

Update Data Model class meta-information replacing forwarded type annotations with actual types.

Parameters:

localns – locals dict used in the evaluation of the annotations (globals are automatically taken from model.__module__).

Returns:

The provided class (so it can be used as a decorator too).

classmethod zero() → CartesianOffset[source]
class gt4py.cartesian.gtc.common.Cast(*, dtype: DataType, expr: ExprT)[source]

Bases: GenericNode, Generic[ExprT]

dtype: DataType
expr: ExprT
classmethod kind_propagation(instance: Cast) → None[source]
classmethod update_forward_refs(localns: dict[str, Any] | None = None) → type[_DataModelT]

Update Data Model class meta-information replacing forwarded type annotations with actual types.

Parameters:

localns – locals dict used in the evaluation of the annotations (globals are automatically taken from model.__module__).

Returns:

The provided class (so it can be used as a decorator too).

class gt4py.cartesian.gtc.common.Cast__Expr(*, dtype: DataType, expr: Expr)

Bases: Cast

expr: Expr
classmethod update_forward_refs(localns: dict[str, Any] | None = None) → type[_DataModelT]

Update Data Model class meta-information replacing forwarded type annotations with actual types.

Parameters:

localns – locals dict used in the evaluation of the annotations (globals are automatically taken from model.__module__).

Returns:

The provided class (so it can be used as a decorator too).

class gt4py.cartesian.gtc.common.ComparisonOperator(*values)[source]

Bases: StrEnum

Comparison operators.

EQ = '=='
GE = '>='
GT = '>'
LE = '<='
LT = '<'
NE = '!='
class gt4py.cartesian.gtc.common.DataType(*values)[source]

Bases: IntEnum

Data type identifier.

AUTO = 0
BOOL = 10
DEFAULT = 1
FLOAT32 = 104
FLOAT64 = 108
INT16 = 12
INT32 = 14
INT64 = 18
INT8 = 11
INVALID = -1
isbool()[source]
isfloat()[source]
isinteger()[source]
class gt4py.cartesian.gtc.common.Expr(*args: Any, **kwargs: Any)[source]

Bases: LocNode

Expression base class.

All expressions have - an optional dtype - an expression kind (scalar or field)

dtype: DataType
kind: ExprKind
classmethod update_forward_refs(localns: dict[str, Any] | None = None) → type[_DataModelT]

Update Data Model class meta-information replacing forwarded type annotations with actual types.

Parameters:

localns – locals dict used in the evaluation of the annotations (globals are automatically taken from model.__module__).

Returns:

The provided class (so it can be used as a decorator too).

class gt4py.cartesian.gtc.common.ExprKind(*values)[source]

Bases: IntEnum

FIELD = 2
SCALAR = 1
class gt4py.cartesian.gtc.common.FieldAccess(data_index: List[ExprT] = NOTHING, *, name: Any, offset: CartesianOffset | VariableKOffsetT | AbsoluteKIndex, kind: ExprKind = ExprKind.FIELD)[source]

Bases: GenericNode, Generic[ExprT, VariableKOffsetT]

classmethod centered(*, name: str, loc: SourceLocation | None = None) → FieldAccess[source]
data_index: List[ExprT]
data_index_exprs_are_int(attribute: Attribute, value: Any) → None[source]
kind: ExprKind
name: SymbolRef
offset: CartesianOffset | VariableKOffsetT | AbsoluteKIndex
classmethod update_forward_refs(localns: dict[str, Any] | None = None) → type[_DataModelT]

Update Data Model class meta-information replacing forwarded type annotations with actual types.

Parameters:

localns – locals dict used in the evaluation of the annotations (globals are automatically taken from model.__module__).

Returns:

The provided class (so it can be used as a decorator too).

class gt4py.cartesian.gtc.common.FieldAccess__Expr_VariableKOffset(data_index: List[Expr] = NOTHING, *, name: Any, kind: ExprKind = ExprKind.FIELD, offset: CartesianOffset | VariableKOffset | AbsoluteKIndex)

Bases: FieldAccess

data_index: List[Expr]
offset: CartesianOffset | VariableKOffset | AbsoluteKIndex
classmethod update_forward_refs(localns: dict[str, Any] | None = None) → type[_DataModelT]

Update Data Model class meta-information replacing forwarded type annotations with actual types.

Parameters:

localns – locals dict used in the evaluation of the annotations (globals are automatically taken from model.__module__).

Returns:

The provided class (so it can be used as a decorator too).

exception gt4py.cartesian.gtc.common.GTCPostconditionError(*, expected: str, **kwargs: Any)[source]

Bases: EveError, RuntimeError

message_template = 'GTC pass postcondition error: [{info}]'
exception gt4py.cartesian.gtc.common.GTCPreconditionError(*, expected: str, **kwargs: Any)[source]

Bases: EveError, RuntimeError

message_template = 'GTC pass precondition error: [{info}]'
class gt4py.cartesian.gtc.common.HorizontalInterval(*, start: AxisBound | None, end: AxisBound | None)[source]

Bases: Node

Represents an interval of the index space in the horizontal.

This is separate from gtir.Interval because the endpoints may be outside the compute domain.

classmethod at_endpt(level: LevelMarker, start_offset: int, end_offset: int | None = None) → HorizontalInterval[source]
classmethod check_start_before_end(instance: HorizontalInterval) → None[source]
classmethod compute_domain(start_offset: int = 0, end_offset: int = 0) → HorizontalInterval[source]
end: AxisBound | None
classmethod full() → HorizontalInterval[source]
is_single_index() → bool[source]
overlaps(other: HorizontalInterval) → bool[source]
start: AxisBound | None
classmethod update_forward_refs(localns: dict[str, Any] | None = None) → type[_DataModelT]

Update Data Model class meta-information replacing forwarded type annotations with actual types.

Parameters:

localns – locals dict used in the evaluation of the annotations (globals are automatically taken from model.__module__).

Returns:

The provided class (so it can be used as a decorator too).

class gt4py.cartesian.gtc.common.HorizontalMask(*, loc: SourceLocation | None = None, i: HorizontalInterval, j: HorizontalInterval)[source]

Bases: LocNode

Expr to represent a convex portion of the horizontal iteration space.

i: HorizontalInterval
property intervals: Tuple[HorizontalInterval, HorizontalInterval]
j: HorizontalInterval
classmethod update_forward_refs(localns: dict[str, Any] | None = None) → type[_DataModelT]

Update Data Model class meta-information replacing forwarded type annotations with actual types.

Parameters:

localns – locals dict used in the evaluation of the annotations (globals are automatically taken from model.__module__).

Returns:

The provided class (so it can be used as a decorator too).

class gt4py.cartesian.gtc.common.HorizontalRestriction(*, mask: HorizontalMask, body: List[StmtT])[source]

Bases: GenericNode, Generic[StmtT]

A specialization of the horizontal space.

body: List[StmtT]
mask: HorizontalMask
classmethod update_forward_refs(localns: dict[str, Any] | None = None) → type[_DataModelT]

Update Data Model class meta-information replacing forwarded type annotations with actual types.

Parameters:

localns – locals dict used in the evaluation of the annotations (globals are automatically taken from model.__module__).

Returns:

The provided class (so it can be used as a decorator too).

class gt4py.cartesian.gtc.common.HorizontalRestriction__Stmt(*, mask: HorizontalMask, body: List[Stmt])

Bases: HorizontalRestriction

body: List[Stmt]
classmethod update_forward_refs(localns: dict[str, Any] | None = None) → type[_DataModelT]

Update Data Model class meta-information replacing forwarded type annotations with actual types.

Parameters:

localns – locals dict used in the evaluation of the annotations (globals are automatically taken from model.__module__).

Returns:

The provided class (so it can be used as a decorator too).

class gt4py.cartesian.gtc.common.IfStmt(*, cond: ExprT, true_branch: StmtT, false_branch: StmtT | None = None)[source]

Bases: GenericNode, Generic[StmtT, ExprT]

Generic if statement.

Verifies that cond is a boolean expr (if dtype is set).

cond: ExprT
condition_is_boolean(attribute: Attribute, value: Expr) → None[source]
false_branch: StmtT | None
true_branch: StmtT
classmethod update_forward_refs(localns: dict[str, Any] | None = None) → type[_DataModelT]

Update Data Model class meta-information replacing forwarded type annotations with actual types.

Parameters:

localns – locals dict used in the evaluation of the annotations (globals are automatically taken from model.__module__).

Returns:

The provided class (so it can be used as a decorator too).

class gt4py.cartesian.gtc.common.IfStmt__BlockStmt_Expr(*, cond: Expr, true_branch: BlockStmt, false_branch: BlockStmt | None = None)

Bases: IfStmt

cond: Expr
false_branch: BlockStmt | None
true_branch: BlockStmt
classmethod update_forward_refs(localns: dict[str, Any] | None = None) → type[_DataModelT]

Update Data Model class meta-information replacing forwarded type annotations with actual types.

Parameters:

localns – locals dict used in the evaluation of the annotations (globals are automatically taken from model.__module__).

Returns:

The provided class (so it can be used as a decorator too).

class gt4py.cartesian.gtc.common.LevelMarker(*values)[source]

Bases: StrEnum

END = 'end'
START = 'start'
class gt4py.cartesian.gtc.common.Literal(*, value: BuiltInLiteral | str, dtype: DataType, kind: ExprKind = ExprKind.SCALAR)[source]

Bases: Node

dtype: DataType
kind: ExprKind
classmethod update_forward_refs(localns: dict[str, Any] | None = None) → type[_DataModelT]

Update Data Model class meta-information replacing forwarded type annotations with actual types.

Parameters:

localns – locals dict used in the evaluation of the annotations (globals are automatically taken from model.__module__).

Returns:

The provided class (so it can be used as a decorator too).

value: BuiltInLiteral | str
class gt4py.cartesian.gtc.common.LocNode(*, loc: SourceLocation | None = None)[source]

Bases: Node

loc: SourceLocation | None
classmethod update_forward_refs(localns: dict[str, Any] | None = None) → type[_DataModelT]

Update Data Model class meta-information replacing forwarded type annotations with actual types.

Parameters:

localns – locals dict used in the evaluation of the annotations (globals are automatically taken from model.__module__).

Returns:

The provided class (so it can be used as a decorator too).

class gt4py.cartesian.gtc.common.LogicalOperator(*values)[source]

Bases: StrEnum

Logical operators.

AND = 'and'
OR = 'or'
class gt4py.cartesian.gtc.common.LoopOrder(*values)[source]

Bases: StrEnum

Loop order identifier.

BACKWARD = 'backward'
FORWARD = 'forward'
PARALLEL = 'parallel'
class gt4py.cartesian.gtc.common.NativeFuncCall(*, func: NativeFunction, args: List[ExprT])[source]

Bases: GenericNode, Generic[ExprT]

args: List[ExprT]
classmethod arity_check(instance: NativeFuncCall) → None[source]
func: NativeFunction
classmethod kind_propagation(instance: NativeFuncCall) → None[source]
classmethod update_forward_refs(localns: dict[str, Any] | None = None) → type[_DataModelT]

Update Data Model class meta-information replacing forwarded type annotations with actual types.

Parameters:

localns – locals dict used in the evaluation of the annotations (globals are automatically taken from model.__module__).

Returns:

The provided class (so it can be used as a decorator too).

class gt4py.cartesian.gtc.common.NativeFuncCall__Expr(*, func: NativeFunction, args: List[Expr])

Bases: NativeFuncCall

args: List[Expr]
classmethod update_forward_refs(localns: dict[str, Any] | None = None) → type[_DataModelT]

Update Data Model class meta-information replacing forwarded type annotations with actual types.

Parameters:

localns – locals dict used in the evaluation of the annotations (globals are automatically taken from model.__module__).

Returns:

The provided class (so it can be used as a decorator too).

class gt4py.cartesian.gtc.common.NativeFunction(*values)[source]

Bases: StrEnum

ABS = 'abs'
ARCCOS = 'arccos'
ARCCOSH = 'arccosh'
ARCSIN = 'arcsin'
ARCSINH = 'arcsinh'
ARCTAN = 'arctan'
ARCTANH = 'arctanh'
CBRT = 'cbrt'
CEIL = 'ceil'
COS = 'cos'
COSH = 'cosh'
ERF = 'erf'
ERFC = 'erfc'
EXP = 'exp'
FLOAT32 = 'float32'
FLOAT64 = 'float64'
FLOOR = 'floor'
GAMMA = 'gamma'
INT32 = 'int32'
INT64 = 'int64'
IR_OP_TO_NUM_ARGS: ClassVar[Dict[NativeFunction, int]] = {NativeFunction.ABS: 1, NativeFunction.ARCCOS: 1, NativeFunction.ARCCOSH: 1, NativeFunction.ARCSIN: 1, NativeFunction.ARCSINH: 1, NativeFunction.ARCTAN: 1, NativeFunction.ARCTANH: 1, NativeFunction.CBRT: 1, NativeFunction.CEIL: 1, NativeFunction.COS: 1, NativeFunction.COSH: 1, NativeFunction.ERF: 1, NativeFunction.ERFC: 1, NativeFunction.EXP: 1, NativeFunction.FLOAT32: 1, NativeFunction.FLOAT64: 1, NativeFunction.FLOOR: 1, NativeFunction.GAMMA: 1, NativeFunction.INT32: 1, NativeFunction.INT64: 1, NativeFunction.ISFINITE: 1, NativeFunction.ISINF: 1, NativeFunction.ISNAN: 1, NativeFunction.LOG: 1, NativeFunction.LOG10: 1, NativeFunction.MAX: 2, NativeFunction.MIN: 2, NativeFunction.MOD: 2, NativeFunction.POW: 2, NativeFunction.ROUND: 1, NativeFunction.ROUND_AWAY_FROM_ZERO: 1, NativeFunction.SIN: 1, NativeFunction.SINH: 1, NativeFunction.SQRT: 1, NativeFunction.TAN: 1, NativeFunction.TANH: 1, NativeFunction.TRUNC: 1}
ISFINITE = 'isfinite'
ISINF = 'isinf'
ISNAN = 'isnan'
LOG = 'log'
LOG10 = 'log10'
MAX = 'max'
MIN = 'min'
MOD = 'mod'
POW = 'pow'
ROUND = 'round'
ROUND_AWAY_FROM_ZERO = 'round_away_from_zero'
SIN = 'sin'
SINH = 'sinh'
SQRT = 'sqrt'
TAN = 'tan'
TANH = 'tanh'
TRUNC = 'trunc'
property arity: int
class gt4py.cartesian.gtc.common.RuntimeAxisBound(*, level: LevelMarker, offset: ScalarAccess | FieldAccess)[source]

Bases: BaseAxisBound

_abc_impl = <_abc._abc_data object>
level: LevelMarker
offset: ScalarAccess | FieldAccess
classmethod update_forward_refs(localns: dict[str, Any] | None = None) → type[_DataModelT]

Update Data Model class meta-information replacing forwarded type annotations with actual types.

Parameters:

localns – locals dict used in the evaluation of the annotations (globals are automatically taken from model.__module__).

Returns:

The provided class (so it can be used as a decorator too).

class gt4py.cartesian.gtc.common.ScalarAccess(*, loc: SourceLocation | None = None, name: Any, kind: ExprKind = ExprKind.SCALAR)[source]

Bases: LocNode

kind: ExprKind
name: SymbolRef
classmethod update_forward_refs(localns: dict[str, Any] | None = None) → type[_DataModelT]

Update Data Model class meta-information replacing forwarded type annotations with actual types.

Parameters:

localns – locals dict used in the evaluation of the annotations (globals are automatically taken from model.__module__).

Returns:

The provided class (so it can be used as a decorator too).

class gt4py.cartesian.gtc.common.Stmt(*args: Any, **kwargs: Any)[source]

Bases: LocNode

classmethod update_forward_refs(localns: dict[str, Any] | None = None) → type[_DataModelT]

Update Data Model class meta-information replacing forwarded type annotations with actual types.

Parameters:

localns – locals dict used in the evaluation of the annotations (globals are automatically taken from model.__module__).

Returns:

The provided class (so it can be used as a decorator too).

class gt4py.cartesian.gtc.common.TernaryOp(*, cond: ExprT, true_expr: ExprT, false_expr: ExprT)[source]

Bases: GenericNode, Generic[ExprT]

Generic ternary operation with type propagation.

The generic TernaryOp already contains logic for - strict type checking if the dtype for true_expr and false_expr is set. - type checking for cond - type propagation.

cond: ExprT
condition_is_boolean(attribute: Attribute, value: Expr) → None[source]
false_expr: ExprT
classmethod kind_propagation(instance: TernaryOp) → None[source]
true_expr: ExprT
classmethod update_forward_refs(localns: dict[str, Any] | None = None) → type[_DataModelT]

Update Data Model class meta-information replacing forwarded type annotations with actual types.

Parameters:

localns – locals dict used in the evaluation of the annotations (globals are automatically taken from model.__module__).

Returns:

The provided class (so it can be used as a decorator too).

class gt4py.cartesian.gtc.common.TernaryOp__Expr(*, cond: Expr, true_expr: Expr, false_expr: Expr)

Bases: TernaryOp

cond: Expr
false_expr: Expr
true_expr: Expr
classmethod update_forward_refs(localns: dict[str, Any] | None = None) → type[_DataModelT]

Update Data Model class meta-information replacing forwarded type annotations with actual types.

Parameters:

localns – locals dict used in the evaluation of the annotations (globals are automatically taken from model.__module__).

Returns:

The provided class (so it can be used as a decorator too).

class gt4py.cartesian.gtc.common.UnaryOp(*, op: UnaryOperator, expr: ExprT)[source]

Bases: GenericNode, Generic[ExprT]

Generic unary operation with type propagation.

The generic UnaryOp already contains logic for type propagation.

classmethod dtype_propagation(instance: UnaryOp) → None[source]
expr: ExprT
classmethod kind_propagation(instance: UnaryOp) → None[source]
op: UnaryOperator
classmethod op_to_dtype_check(instance: UnaryOp) → None[source]
classmethod update_forward_refs(localns: dict[str, Any] | None = None) → type[_DataModelT]

Update Data Model class meta-information replacing forwarded type annotations with actual types.

Parameters:

localns – locals dict used in the evaluation of the annotations (globals are automatically taken from model.__module__).

Returns:

The provided class (so it can be used as a decorator too).

class gt4py.cartesian.gtc.common.UnaryOp__Expr(*, op: UnaryOperator, expr: Expr)

Bases: UnaryOp

expr: Expr
classmethod update_forward_refs(localns: dict[str, Any] | None = None) → type[_DataModelT]

Update Data Model class meta-information replacing forwarded type annotations with actual types.

Parameters:

localns – locals dict used in the evaluation of the annotations (globals are automatically taken from model.__module__).

Returns:

The provided class (so it can be used as a decorator too).

class gt4py.cartesian.gtc.common.UnaryOperator(*values)[source]

Bases: StrEnum

Unary operator identifier.

NEG = '-'
NOT = 'not'
POS = '+'
class gt4py.cartesian.gtc.common.VariableKOffset(*, k: ExprT)[source]

Bases: GenericNode, Generic[ExprT]

k: ExprT
offset_expr_is_int(attribute: Attribute, value: Any) → None[source]
to_dict() → Dict[str, int | None][source]
classmethod update_forward_refs(localns: dict[str, Any] | None = None) → type[_DataModelT]

Update Data Model class meta-information replacing forwarded type annotations with actual types.

Parameters:

localns – locals dict used in the evaluation of the annotations (globals are automatically taken from model.__module__).

Returns:

The provided class (so it can be used as a decorator too).

class gt4py.cartesian.gtc.common.VariableKOffset__Expr(*, k: Expr)

Bases: VariableKOffset

k: Expr
classmethod update_forward_refs(localns: dict[str, Any] | None = None) → type[_DataModelT]

Update Data Model class meta-information replacing forwarded type annotations with actual types.

Parameters:

localns – locals dict used in the evaluation of the annotations (globals are automatically taken from model.__module__).

Returns:

The provided class (so it can be used as a decorator too).

class gt4py.cartesian.gtc.common.While(*, cond: ExprT, body: List[StmtT])[source]

Bases: GenericNode, Generic[StmtT, ExprT]

Generic while loop.

Verifies that cond is a boolean expr (if dtype is set).

body: List[StmtT]
cond: ExprT
condition_is_boolean(attribute: Attribute, value: Expr) → None[source]
classmethod update_forward_refs(localns: dict[str, Any] | None = None) → type[_DataModelT]

Update Data Model class meta-information replacing forwarded type annotations with actual types.

Parameters:

localns – locals dict used in the evaluation of the annotations (globals are automatically taken from model.__module__).

Returns:

The provided class (so it can be used as a decorator too).

class gt4py.cartesian.gtc.common.While__Stmt_Expr(*, cond: Expr, body: List[Stmt])

Bases: While

body: List[Stmt]
cond: Expr
classmethod update_forward_refs(localns: dict[str, Any] | None = None) → type[_DataModelT]

Update Data Model class meta-information replacing forwarded type annotations with actual types.

Parameters:

localns – locals dict used in the evaluation of the annotations (globals are automatically taken from model.__module__).

Returns:

The provided class (so it can be used as a decorator too).

class gt4py.cartesian.gtc.common._LvalueDimsValidator(vertical_loop_type: Type[Node], decl_type: Type[Node])[source]

Bases: VisitorWithSymbolTableTrait

_allowed_flags(loop_order: LoopOrder) → List[Tuple[bool, bool, bool]][source]
_node_visitor_cache_: ClassVar[dict[type, str] | None] = {}

Cache for visitor method names per node class to speed up dispatching. Note that we cache the visitor method name, not the bound method itself, to avoid implicitly caching the visitor state, which could lead to unexpected behavior.

visit_AssignStmt(node: AssignStmt, *, loop_order: LoopOrder, symtable: Dict[str, Any], **kwargs: Any) → None[source]
visit_Node(node: Node, *, loop_order: LoopOrder | None = None, **kwargs: Any) → None[source]
gt4py.cartesian.gtc.common._make_root_validator(impl: Callable[[type[_DM], _DM], None]) → Callable[[type[_DM], _DM], None][source]
gt4py.cartesian.gtc.common.assign_stmt_dtype_validation(*, strict: bool) → Callable[[type[_DM], _DM], None][source]
gt4py.cartesian.gtc.common.binary_op_dtype_propagation(*, strict: bool) → Callable[[type[_DM], _DM], None][source]
gt4py.cartesian.gtc.common.compute_kind(*values: Expr) → ExprKind[source]
gt4py.cartesian.gtc.common.data_type_to_typestr(dtype: DataType) → str[source]
gt4py.cartesian.gtc.common.native_func_call_dtype_propagation(*, strict: bool = True) → Callable[[type[_DM], _DM], None][source]
gt4py.cartesian.gtc.common.op_to_ufunc(op: UnaryOperator | ArithmeticOperator | ComparisonOperator | LogicalOperator | NativeFunction) → ufunc[source]
gt4py.cartesian.gtc.common.ternary_op_dtype_propagation(*, strict: bool) → Callable[[type[_DM], _DM], None][source]
gt4py.cartesian.gtc.common.typestr_to_data_type(typestr: str) → DataType[source]
gt4py.cartesian.gtc.common.validate_dtype_is_set() → Callable[[type[_DM], _DM], None][source]
gt4py.cartesian.gtc.common.validate_lvalue_dims(vertical_loop_type: Type[Node], decl_type: Type[Node]) → Callable[[type[_DM], _DM], None][source]

Validate lvalue dimensions using the root node symbol table.

The following tree structure is expected:

Root(`SymTableTrait`)
|- *
   |- `vertical_loop_type`
       |- loop_order: `LoopOrder`
       |- *
          |- AssignStmt(`AssignStmt`)
          |- left: `Node`, validated only if reference to `decl_type` in symtable
|- symtable_: Symtable[name, Union[`decl_type`, *]]

DeclType
|- dimensions: `Tuple[bool, bool, bool]`
Parameters:
  • vertical_loop_type – A node type with an LoopOrder attribute named loop_order

  • decl_type – A declaration type with field dimension information in the format Tuple[bool, bool, bool] in an attribute named dimensions.

gt4py.cartesian.gtc.common.verify_and_get_common_dtype(node_cls: Type[DataModel], exprs: List[Expr], *, strict: bool = True) → DataType | None[source]
gt4py.cartesian.gtc.common.verify_condition_is_boolean(parent_node_cls: DataModel, cond: Expr) → None[source]

gt4py.cartesian.gtc.definitions module

class gt4py.cartesian.gtc.definitions.Boundary(ranges, *args, ndims=None)[source]

Bases: FrameTuple

Frame size around one central origin (pairs of integers).

Negative numbers represent a boundary region subtracting from the wrapped area.

classmethod _check_value(value, ndims)[source]
property frame_size

Sizes of the boundary area, i.e., excluding the central element of the frame.

classmethod from_offset(offset)[source]
property shape

Total shape of the frame area.

class gt4py.cartesian.gtc.definitions.CartesianSpace[source]

Bases: object

class Axis(*values)[source]

Bases: Enum

I = 0
J = 1
K = 2
names: Final[list[str]] = ['I', 'J', 'K']
ndim = 3
class gt4py.cartesian.gtc.definitions.CenteredExtent(ranges, *args, ndims=None)[source]

Bases: Extent

Region defined by the largest negative offset (or zero) and the largest positive offset (or zero).

Size of boundary regions are expressed as minimum and maximum relative offsets related to the computation position. For example the frame for a stencil accessing 3 elements at the left of computation point and two at the right in the X axis would be: (-3, 2). If the stencil only has accesses with negative indices, the upper boundary would be 0.

classmethod _check_value(value, ndims)[source]
classmethod empty(ndims=3)[source]
classmethod from_offset(offset)[source]
to_boundary()[source]
class gt4py.cartesian.gtc.definitions.Extent(ranges, *args, ndims=None)[source]

Bases: FrameTuple

Region defined by the smallest and the largest offsets.

Size of boundary regions are expressed as minimum and maximum relative offsets related to the computation position. For example the frame for a stencil accessing 3 elements at the left of computation point and two at the right in the X axis would be: (-3, 2). If the stencil only has accesses with negative indices, the upper boundary would be then a negative value.

_apply(other, left_func, right_func=None)[source]
classmethod _check_value(value, ndims)[source]
classmethod empty(ndims=3)[source]
property frame_size

Sizes of the boundary area, i.e., excluding the central element of the frame.

classmethod from_offset(offset)[source]
property shape

Total shape of the frame area.

to_boundary()[source]
class gt4py.cartesian.gtc.definitions.FrameTuple(ranges, *args, ndims=None)[source]

Bases: tuple

N-dimensional list of pairs of numbers representing offsets around one central origin.

_apply(other, left_func, right_func=None)[source]
_broadcast(value)[source]
classmethod _check_value(value, ndims)[source]
_compare(other, left_op, right_op=None)[source]
_reduce(reduce_func, out_type=<class 'tuple'>)[source]
append(point)[source]
concatenate(other)[source]
classmethod from_k(value_pair, ndims=3)[source]
classmethod from_lower_upper(lower, upper)[source]
intersection(other)[source]
property is_symmetric
classmethod is_valid(value, *, ndims=(1, None))[source]
property is_zero
property lower_indices
property ndims
classmethod ones(ndims=3)[source]
union(other)[source]
property upper_indices
classmethod zeros(ndims=3)[source]
class gt4py.cartesian.gtc.definitions.Index(sizes, *args, ndims=None)[source]

Bases: NumericTuple

Index in a grid (all elements are ints).

classmethod _check_value(value, ndims)[source]
class gt4py.cartesian.gtc.definitions.NumericTuple(sizes, *args, ndims=None)[source]

Bases: tuple

N-dimensional like vector implemented as a subclass of the tuple builtin.

_DEFAULT = 0
_apply(other, func)[source]
_broadcast(value)[source]
classmethod _check_value(value, ndims)[source]
_compare(other, op, reduction_op)[source]
filter_mask(mask)[source]
classmethod from_k(value, ndims=3)[source]
classmethod from_mask(seq, mask, default=None)[source]
classmethod from_value(value)[source]
intersection(other)[source]
classmethod is_valid(value, *, ndims=(1, None))[source]
property ndims
classmethod ones(ndims=3)[source]
union(other)[source]
classmethod zeros(ndims=3)[source]
class gt4py.cartesian.gtc.definitions.Shape(sizes, *args, ndims=None)[source]

Bases: NumericTuple

Shape of a n-dimensional grid (all elements are int >= 0).

_DEFAULT = 1
classmethod _check_value(value, ndims)[source]

gt4py.cartesian.gtc.gtir module

GridTools Intermediate Representation.

GTIR represents a computation with the semantics of the GTScript parallel model <https://github.com/GridTools/concepts/wiki/GTScript-Parallel-model>.

Type constraints and validators narrow the IR as much as reasonable to valid (executable) IR.

Analysis is required to generate valid code (complying with the parallel model) - extent analysis to define the extended compute domain - FieldIfStmt expansion to comply with the parallel model

class gt4py.cartesian.gtc.gtir.AbsoluteKIndex(*, k: int | Expr)[source]

Bases: AbsoluteKIndex__Expr

See gtc.common.AbsoluteKIndex

classmethod update_forward_refs(localns: dict[str, Any] | None = None) → type[_DataModelT]

Update Data Model class meta-information replacing forwarded type annotations with actual types.

Parameters:

localns – locals dict used in the evaluation of the annotations (globals are automatically taken from model.__module__).

Returns:

The provided class (so it can be used as a decorator too).

class gt4py.cartesian.gtc.gtir.Argument(*, name: str, is_keyword: bool, default: str)[source]

Bases: Node

default: str
is_keyword: bool
name: str
classmethod update_forward_refs(localns: dict[str, Any] | None = None) → type[_DataModelT]

Update Data Model class meta-information replacing forwarded type annotations with actual types.

Parameters:

localns – locals dict used in the evaluation of the annotations (globals are automatically taken from model.__module__).

Returns:

The provided class (so it can be used as a decorator too).

class gt4py.cartesian.gtc.gtir.BinaryOp(*, loc: SourceLocation | None = None, kind: ExprKind = ExprKind.FIELD, dtype: DataType = DataType.AUTO, op: ArithmeticOperator | ComparisonOperator | LogicalOperator, left: Expr, right: Expr)[source]

Bases: BinaryOp__Expr, Expr

classmethod _dtype_validator(instance: BinaryOp) → None
classmethod update_forward_refs(localns: dict[str, Any] | None = None) → type[_DataModelT]

Update Data Model class meta-information replacing forwarded type annotations with actual types.

Parameters:

localns – locals dict used in the evaluation of the annotations (globals are automatically taken from model.__module__).

Returns:

The provided class (so it can be used as a decorator too).

class gt4py.cartesian.gtc.gtir.BlockStmt(*, loc: SourceLocation | None = None, body: List[Stmt])[source]

Bases: BlockStmt__Stmt, Stmt

classmethod update_forward_refs(localns: dict[str, Any] | None = None) → type[_DataModelT]

Update Data Model class meta-information replacing forwarded type annotations with actual types.

Parameters:

localns – locals dict used in the evaluation of the annotations (globals are automatically taken from model.__module__).

Returns:

The provided class (so it can be used as a decorator too).

class gt4py.cartesian.gtc.gtir.Cast(*, loc: SourceLocation | None = None, kind: ExprKind = ExprKind.FIELD, dtype: DataType, expr: Expr)[source]

Bases: Cast__Expr, Expr

classmethod update_forward_refs(localns: dict[str, Any] | None = None) → type[_DataModelT]

Update Data Model class meta-information replacing forwarded type annotations with actual types.

Parameters:

localns – locals dict used in the evaluation of the annotations (globals are automatically taken from model.__module__).

Returns:

The provided class (so it can be used as a decorator too).

class gt4py.cartesian.gtc.gtir.Decl(*args: Any, **kwargs: Any)[source]

Bases: LocNode

dtype: DataType
name: SymbolName
classmethod update_forward_refs(localns: dict[str, Any] | None = None) → type[_DataModelT]

Update Data Model class meta-information replacing forwarded type annotations with actual types.

Parameters:

localns – locals dict used in the evaluation of the annotations (globals are automatically taken from model.__module__).

Returns:

The provided class (so it can be used as a decorator too).

class gt4py.cartesian.gtc.gtir.Expr(*args: Any, **kwargs: Any)[source]

Bases: Expr

classmethod update_forward_refs(localns: dict[str, Any] | None = None) → type[_DataModelT]

Update Data Model class meta-information replacing forwarded type annotations with actual types.

Parameters:

localns – locals dict used in the evaluation of the annotations (globals are automatically taken from model.__module__).

Returns:

The provided class (so it can be used as a decorator too).

class gt4py.cartesian.gtc.gtir.FieldAccess(data_index: List[Expr] = NOTHING, *, loc: SourceLocation | None = None, dtype: DataType = DataType.AUTO, name: Any, kind: ExprKind = ExprKind.FIELD, offset: CartesianOffset | VariableKOffset | AbsoluteKIndex)[source]

Bases: FieldAccess__Expr_VariableKOffset, Expr

classmethod update_forward_refs(localns: dict[str, Any] | None = None) → type[_DataModelT]

Update Data Model class meta-information replacing forwarded type annotations with actual types.

Parameters:

localns – locals dict used in the evaluation of the annotations (globals are automatically taken from model.__module__).

Returns:

The provided class (so it can be used as a decorator too).

class gt4py.cartesian.gtc.gtir.FieldDecl(data_dims: Tuple[Integral, ...] = NOTHING, *, loc: SourceLocation | None = None, name: Any, dtype: DataType, dimensions: Tuple[bool, bool, bool])[source]

Bases: Decl

data_dims: Tuple[Integral, ...]
dimensions: Tuple[bool, bool, bool]
classmethod update_forward_refs(localns: dict[str, Any] | None = None) → type[_DataModelT]

Update Data Model class meta-information replacing forwarded type annotations with actual types.

Parameters:

localns – locals dict used in the evaluation of the annotations (globals are automatically taken from model.__module__).

Returns:

The provided class (so it can be used as a decorator too).

class gt4py.cartesian.gtc.gtir.FieldIfStmt(*, loc: SourceLocation | None = None, true_branch: BlockStmt, false_branch: BlockStmt | None = None, cond: Expr)[source]

Bases: IfStmt__BlockStmt_Expr, Stmt

If statement with a field expression as condition.

  • The condition is evaluated for all gridpoints and stored in a mask.

  • Each statement inside the if and else branches is executed according to the same rules as statements outside of branches.

The following restriction applies:

  • Inside the if and else blocks the same field cannot be written to and read with an offset in the parallel axes (order does not matter).

See parallel model <https://github.com/GridTools/concepts/wiki/GTScript-Parallel-model#conditionals-on-field-expressions>

cond: Expr
classmethod update_forward_refs(localns: dict[str, Any] | None = None) → type[_DataModelT]

Update Data Model class meta-information replacing forwarded type annotations with actual types.

Parameters:

localns – locals dict used in the evaluation of the annotations (globals are automatically taken from model.__module__).

Returns:

The provided class (so it can be used as a decorator too).

verify_scalar_condition(attribute: Attribute, value: Expr) → None[source]
class gt4py.cartesian.gtc.gtir.HorizontalRestriction(*, loc: SourceLocation | None = None, mask: HorizontalMask, body: List[Stmt])[source]

Bases: HorizontalRestriction__Stmt, Stmt

classmethod update_forward_refs(localns: dict[str, Any] | None = None) → type[_DataModelT]

Update Data Model class meta-information replacing forwarded type annotations with actual types.

Parameters:

localns – locals dict used in the evaluation of the annotations (globals are automatically taken from model.__module__).

Returns:

The provided class (so it can be used as a decorator too).

class gt4py.cartesian.gtc.gtir.Interval(*, loc: SourceLocation | None = None, start: BaseAxisBound, end: BaseAxisBound)[source]

Bases: LocNode

end: BaseAxisBound
has_runtime_access()[source]
start: BaseAxisBound
classmethod update_forward_refs(localns: dict[str, Any] | None = None) → type[_DataModelT]

Update Data Model class meta-information replacing forwarded type annotations with actual types.

Parameters:

localns – locals dict used in the evaluation of the annotations (globals are automatically taken from model.__module__).

Returns:

The provided class (so it can be used as a decorator too).

class gt4py.cartesian.gtc.gtir.IteratorAccess(*, loc: SourceLocation | None = None, dtype: DataType = DataType.AUTO, name: AxisName, kind: ExprKind = ExprKind.SCALAR)[source]

Bases: Expr

class AxisName(*values)[source]

Bases: StrEnum

I = 'I'
J = 'J'
K = 'K'
kind: ExprKind
name: AxisName
classmethod update_forward_refs(localns: dict[str, Any] | None = None) → type[_DataModelT]

Update Data Model class meta-information replacing forwarded type annotations with actual types.

Parameters:

localns – locals dict used in the evaluation of the annotations (globals are automatically taken from model.__module__).

Returns:

The provided class (so it can be used as a decorator too).

class gt4py.cartesian.gtc.gtir.Literal(*, loc: SourceLocation | None = None, value: BuiltInLiteral | str, dtype: DataType, kind: ExprKind = ExprKind.SCALAR)[source]

Bases: Literal, Expr

classmethod update_forward_refs(localns: dict[str, Any] | None = None) → type[_DataModelT]

Update Data Model class meta-information replacing forwarded type annotations with actual types.

Parameters:

localns – locals dict used in the evaluation of the annotations (globals are automatically taken from model.__module__).

Returns:

The provided class (so it can be used as a decorator too).

class gt4py.cartesian.gtc.gtir.NativeFuncCall(*, loc: SourceLocation | None = None, kind: ExprKind = ExprKind.FIELD, dtype: DataType = DataType.AUTO, func: NativeFunction, args: List[Expr])[source]

Bases: NativeFuncCall__Expr, Expr

classmethod _dtype_propagation(instance: NativeFuncCall) → None
classmethod update_forward_refs(localns: dict[str, Any] | None = None) → type[_DataModelT]

Update Data Model class meta-information replacing forwarded type annotations with actual types.

Parameters:

localns – locals dict used in the evaluation of the annotations (globals are automatically taken from model.__module__).

Returns:

The provided class (so it can be used as a decorator too).

class gt4py.cartesian.gtc.gtir.ParAssignStmt(*, loc: SourceLocation | None = None, right: Expr, left: FieldAccess)[source]

Bases: AssignStmt__FieldAccess_Expr, Stmt

Parallel assignment.

R.h.s. is evaluated for all points and the resulting field is assigned (GTScript parallel model). Scalar variables on the l.h.s. are not allowed, as the only scalar variables are read-only stencil parameters.

classmethod _dtype_validation(instance: DataModel) → None
left: FieldAccess
no_horizontal_offset_in_assignment(attribute: Attribute, value: FieldAccess) → None[source]
classmethod no_write_and_read_with_offset_of_same_field(instance: ParAssignStmt) → None[source]
classmethod update_forward_refs(localns: dict[str, Any] | None = None) → type[_DataModelT]

Update Data Model class meta-information replacing forwarded type annotations with actual types.

Parameters:

localns – locals dict used in the evaluation of the annotations (globals are automatically taken from model.__module__).

Returns:

The provided class (so it can be used as a decorator too).

class gt4py.cartesian.gtc.gtir.ScalarAccess(*, loc: SourceLocation | None = None, dtype: DataType = DataType.AUTO, name: Any, kind: ExprKind = ExprKind.SCALAR)[source]

Bases: ScalarAccess, Expr

classmethod update_forward_refs(localns: dict[str, Any] | None = None) → type[_DataModelT]

Update Data Model class meta-information replacing forwarded type annotations with actual types.

Parameters:

localns – locals dict used in the evaluation of the annotations (globals are automatically taken from model.__module__).

Returns:

The provided class (so it can be used as a decorator too).

class gt4py.cartesian.gtc.gtir.ScalarDecl(*, loc: SourceLocation | None = None, name: Any, dtype: DataType)[source]

Bases: Decl

classmethod update_forward_refs(localns: dict[str, Any] | None = None) → type[_DataModelT]

Update Data Model class meta-information replacing forwarded type annotations with actual types.

Parameters:

localns – locals dict used in the evaluation of the annotations (globals are automatically taken from model.__module__).

Returns:

The provided class (so it can be used as a decorator too).

class gt4py.cartesian.gtc.gtir.ScalarIfStmt(*, loc: SourceLocation | None = None, true_branch: BlockStmt, false_branch: BlockStmt | None = None, cond: Expr)[source]

Bases: IfStmt__BlockStmt_Expr, Stmt

If statement with a scalar expression as condition.

No special rules apply.

cond: Expr
classmethod update_forward_refs(localns: dict[str, Any] | None = None) → type[_DataModelT]

Update Data Model class meta-information replacing forwarded type annotations with actual types.

Parameters:

localns – locals dict used in the evaluation of the annotations (globals are automatically taken from model.__module__).

Returns:

The provided class (so it can be used as a decorator too).

verify_scalar_condition(attribute: Attribute, value: Expr) → None[source]
class gt4py.cartesian.gtc.gtir.Stencil(*, loc: SourceLocation | None = None, name: str, api_signature: List[Argument], params: List[Decl], vertical_loops: List[VerticalLoop], externals: Dict[str, Literal], sources: Dict[str, str], docstring: str)[source]

Bases: LocNode, ValidatedSymbolTableTrait

classmethod _validate_lvalue_dims(instance: DataModel) → None
api_signature: List[Argument]
docstring: str
externals: Dict[str, Literal]
name: str
property param_names: List[str]
params: List[Decl]
sources: Dict[str, str]
classmethod update_forward_refs(localns: dict[str, Any] | None = None) → type[_DataModelT]

Update Data Model class meta-information replacing forwarded type annotations with actual types.

Parameters:

localns – locals dict used in the evaluation of the annotations (globals are automatically taken from model.__module__).

Returns:

The provided class (so it can be used as a decorator too).

vertical_loops: List[VerticalLoop]
class gt4py.cartesian.gtc.gtir.Stmt(*args: Any, **kwargs: Any)[source]

Bases: Stmt

classmethod update_forward_refs(localns: dict[str, Any] | None = None) → type[_DataModelT]

Update Data Model class meta-information replacing forwarded type annotations with actual types.

Parameters:

localns – locals dict used in the evaluation of the annotations (globals are automatically taken from model.__module__).

Returns:

The provided class (so it can be used as a decorator too).

class gt4py.cartesian.gtc.gtir.TernaryOp(*, loc: SourceLocation | None = None, kind: ExprKind = ExprKind.FIELD, dtype: DataType = DataType.AUTO, cond: Expr, true_expr: Expr, false_expr: Expr)[source]

Bases: TernaryOp__Expr, Expr

classmethod _dtype_propagation(instance: TernaryOp) → None
classmethod update_forward_refs(localns: dict[str, Any] | None = None) → type[_DataModelT]

Update Data Model class meta-information replacing forwarded type annotations with actual types.

Parameters:

localns – locals dict used in the evaluation of the annotations (globals are automatically taken from model.__module__).

Returns:

The provided class (so it can be used as a decorator too).

class gt4py.cartesian.gtc.gtir.UnaryOp(*, loc: SourceLocation | None = None, kind: ExprKind = ExprKind.FIELD, dtype: DataType = DataType.AUTO, op: UnaryOperator, expr: Expr)[source]

Bases: UnaryOp__Expr, Expr

classmethod update_forward_refs(localns: dict[str, Any] | None = None) → type[_DataModelT]

Update Data Model class meta-information replacing forwarded type annotations with actual types.

Parameters:

localns – locals dict used in the evaluation of the annotations (globals are automatically taken from model.__module__).

Returns:

The provided class (so it can be used as a decorator too).

class gt4py.cartesian.gtc.gtir.VariableKOffset(*, k: Expr)[source]

Bases: VariableKOffset__Expr

classmethod update_forward_refs(localns: dict[str, Any] | None = None) → type[_DataModelT]

Update Data Model class meta-information replacing forwarded type annotations with actual types.

Parameters:

localns – locals dict used in the evaluation of the annotations (globals are automatically taken from model.__module__).

Returns:

The provided class (so it can be used as a decorator too).

class gt4py.cartesian.gtc.gtir.VerticalLoop(*, loc: SourceLocation | None = None, interval: Interval, loop_order: LoopOrder, temporaries: List[FieldDecl], body: List[Stmt])[source]

Bases: LocNode

classmethod _no_write_and_read_with_horizontal_offset(instance: VerticalLoop) → None[source]

In the same VerticalLoop a field must not be written and read with a horizontal offset.

Temporaries don’t have this constraint. Backends are required to implement them using block-private halos.

classmethod _vertical_offset_in_parallel(instance: VerticalLoop) → None[source]

In a parallel vertical loop we disallow writing and reading the same field with a non-zero offset.

To write and read with non-zero offset creates a race condition in parallel. There’s an exception for vertical loops with size one, e.g. interval(0, 1).

body: List[Stmt]
interval: Interval
loop_order: LoopOrder
temporaries: List[FieldDecl]
classmethod update_forward_refs(localns: dict[str, Any] | None = None) → type[_DataModelT]

Update Data Model class meta-information replacing forwarded type annotations with actual types.

Parameters:

localns – locals dict used in the evaluation of the annotations (globals are automatically taken from model.__module__).

Returns:

The provided class (so it can be used as a decorator too).

class gt4py.cartesian.gtc.gtir.While(*, loc: SourceLocation | None = None, cond: Expr, body: List[Stmt])[source]

Bases: While__Stmt_Expr, Stmt

While loop with a field or scalar expression as condition.

_no_write_and_read_with_horizontal_offset_all(attribute: Attribute, value: List[Stmt]) → None[source]

In a while loop all variables must not be written and read with a horizontal offset.

body: List[Stmt]
classmethod update_forward_refs(localns: dict[str, Any] | None = None) → type[_DataModelT]

Update Data Model class meta-information replacing forwarded type annotations with actual types.

Parameters:

localns – locals dict used in the evaluation of the annotations (globals are automatically taken from model.__module__).

Returns:

The provided class (so it can be used as a decorator too).

gt4py.cartesian.gtc.gtir._cartesian_fieldaccess(node) → bool[source]
gt4py.cartesian.gtc.gtir._written_and_read_with_offset(stmts: List[Stmt]) → Set[str][source]

Return a list of names that are written to and read with offset.

gt4py.cartesian.gtc.gtir_to_oir module

class gt4py.cartesian.gtc.gtir_to_oir.GTIRToOIR[source]

Bases: NodeTranslator

class Context(local_scalars: List[gt4py.cartesian.gtc.oir.ScalarDecl] = <factory>, temp_fields: List[gt4py.cartesian.gtc.oir.FieldDecl] = <factory>)[source]

Bases: object

local_scalars: List[ScalarDecl]
reset_local_scalars()[source]
temp_fields: List[FieldDecl]
_node_visitor_cache_: ClassVar[dict[type, str] | None] = {}

Cache for visitor method names per node class to speed up dispatching. Note that we cache the visitor method name, not the bound method itself, to avoid implicitly caching the visitor state, which could lead to unexpected behavior.

visit_AbsoluteKIndex(node: AbsoluteKIndex) → AbsoluteKIndex[source]
visit_BinaryOp(node: BinaryOp) → BinaryOp[source]
visit_Cast(node: Cast) → Cast[source]
visit_FieldAccess(node: FieldAccess) → FieldAccess[source]
visit_FieldDecl(node: FieldDecl) → FieldDecl[source]
visit_FieldIfStmt(node: FieldIfStmt, *, ctx: Context, **kwargs: Any) → List[AssignStmt | MaskStmt][source]
visit_HorizontalRestriction(node: HorizontalRestriction, **kwargs: Any) → HorizontalRestriction[source]
visit_Interval(node: Interval) → Interval[source]
visit_IteratorAccess(iterator_access: IteratorAccess) → IteratorAccess[source]
visit_Literal(node: Literal) → Literal[source]
visit_NativeFuncCall(node: NativeFuncCall) → NativeFuncCall[source]
visit_ParAssignStmt(node: ParAssignStmt, **kwargs: Any) → AssignStmt[source]
visit_ScalarAccess(node: ScalarAccess) → ScalarAccess[source]
visit_ScalarDecl(node: ScalarDecl) → ScalarDecl[source]
visit_ScalarIfStmt(node: ScalarIfStmt, *, ctx: Context, **kwargs: Any) → List[MaskStmt][source]
visit_Stencil(node: Stencil) → Stencil[source]
visit_TernaryOp(node: TernaryOp) → TernaryOp[source]
visit_UnaryOp(node: UnaryOp) → UnaryOp[source]
visit_VariableKOffset(node: VariableKOffset) → VariableKOffset[source]
visit_VerticalLoop(node: VerticalLoop, *, ctx: Context) → VerticalLoop[source]
visit_While(node: While, **kwargs: Any) → While[source]
gt4py.cartesian.gtc.gtir_to_oir.validate_stencil_memory_accesses(node: Stencil) → Stencil[source]

Check that no memory races occur in GridTools backends.

Since this is required for GridTools backends, it’s imposed on all backends at the OIR level. This is similar to the check at the gtir level for read-with-offset and writes, but more complete because it involves extent analysis, so it catches indirect read-with-offset through temporaries.

gt4py.cartesian.gtc.oir module

Optimizable Intermediate Representation (working title).

OIR represents a computation at the level of GridTools stages and multistages, e.g. stage merging, staged computations to compute-on-the-fly, cache annotations, etc.

class gt4py.cartesian.gtc.oir.AbsoluteKIndex(*, k: int | Expr)[source]

Bases: AbsoluteKIndex__Expr

See gtc.common.AbsoluteKIndex

classmethod update_forward_refs(localns: dict[str, Any] | None = None) → type[_DataModelT]

Update Data Model class meta-information replacing forwarded type annotations with actual types.

Parameters:

localns – locals dict used in the evaluation of the annotations (globals are automatically taken from model.__module__).

Returns:

The provided class (so it can be used as a decorator too).

class gt4py.cartesian.gtc.oir.AssignStmt(*, loc: SourceLocation | None = None, right: Expr, left: ScalarAccess | FieldAccess)[source]

Bases: AssignStmt__gt4py_cartesian_gtc_oir_scalaraccess_gt4py_cartesian_gtc_oir_fieldaccess_Expr, Stmt

classmethod _dtype_validation(instance: DataModel) → None
left: ScalarAccess | FieldAccess
no_horizontal_offset_in_assignment(attribute: Attribute, value: ScalarAccess | FieldAccess) → None[source]
classmethod update_forward_refs(localns: dict[str, Any] | None = None) → type[_DataModelT]

Update Data Model class meta-information replacing forwarded type annotations with actual types.

Parameters:

localns – locals dict used in the evaluation of the annotations (globals are automatically taken from model.__module__).

Returns:

The provided class (so it can be used as a decorator too).

class gt4py.cartesian.gtc.oir.BinaryOp(*, loc: SourceLocation | None = None, kind: ExprKind = ExprKind.FIELD, dtype: DataType = DataType.AUTO, op: ArithmeticOperator | ComparisonOperator | LogicalOperator, left: Expr, right: Expr)[source]

Bases: BinaryOp__Expr, Expr

classmethod _dtype_propagation(instance: BinaryOp) → None
classmethod update_forward_refs(localns: dict[str, Any] | None = None) → type[_DataModelT]

Update Data Model class meta-information replacing forwarded type annotations with actual types.

Parameters:

localns – locals dict used in the evaluation of the annotations (globals are automatically taken from model.__module__).

Returns:

The provided class (so it can be used as a decorator too).

class gt4py.cartesian.gtc.oir.CacheDesc(*, loc: SourceLocation | None = None, name: Any)[source]

Bases: LocNode

name: SymbolRef
classmethod update_forward_refs(localns: dict[str, Any] | None = None) → type[_DataModelT]

Update Data Model class meta-information replacing forwarded type annotations with actual types.

Parameters:

localns – locals dict used in the evaluation of the annotations (globals are automatically taken from model.__module__).

Returns:

The provided class (so it can be used as a decorator too).

class gt4py.cartesian.gtc.oir.Cast(*, loc: SourceLocation | None = None, kind: ExprKind = ExprKind.FIELD, dtype: DataType, expr: Expr)[source]

Bases: Cast__Expr, Expr

classmethod update_forward_refs(localns: dict[str, Any] | None = None) → type[_DataModelT]

Update Data Model class meta-information replacing forwarded type annotations with actual types.

Parameters:

localns – locals dict used in the evaluation of the annotations (globals are automatically taken from model.__module__).

Returns:

The provided class (so it can be used as a decorator too).

class gt4py.cartesian.gtc.oir.CodeBlock(*, loc: SourceLocation | None = None, body: List[Stmt], label: str)[source]

Bases: BlockStmt__Stmt, Stmt

label: str
classmethod update_forward_refs(localns: dict[str, Any] | None = None) → type[_DataModelT]

Update Data Model class meta-information replacing forwarded type annotations with actual types.

Parameters:

localns – locals dict used in the evaluation of the annotations (globals are automatically taken from model.__module__).

Returns:

The provided class (so it can be used as a decorator too).

class gt4py.cartesian.gtc.oir.Decl(*args: Any, **kwargs: Any)[source]

Bases: LocNode

dtype: DataType
name: SymbolName
classmethod update_forward_refs(localns: dict[str, Any] | None = None) → type[_DataModelT]

Update Data Model class meta-information replacing forwarded type annotations with actual types.

Parameters:

localns – locals dict used in the evaluation of the annotations (globals are automatically taken from model.__module__).

Returns:

The provided class (so it can be used as a decorator too).

class gt4py.cartesian.gtc.oir.Expr(*args: Any, **kwargs: Any)[source]

Bases: Expr

classmethod update_forward_refs(localns: dict[str, Any] | None = None) → type[_DataModelT]

Update Data Model class meta-information replacing forwarded type annotations with actual types.

Parameters:

localns – locals dict used in the evaluation of the annotations (globals are automatically taken from model.__module__).

Returns:

The provided class (so it can be used as a decorator too).

class gt4py.cartesian.gtc.oir.FieldAccess(data_index: List[Expr] = NOTHING, *, loc: SourceLocation | None = None, dtype: DataType = DataType.AUTO, name: Any, kind: ExprKind = ExprKind.FIELD, offset: CartesianOffset | VariableKOffset | AbsoluteKIndex)[source]

Bases: FieldAccess__Expr_VariableKOffset, Expr

classmethod update_forward_refs(localns: dict[str, Any] | None = None) → type[_DataModelT]

Update Data Model class meta-information replacing forwarded type annotations with actual types.

Parameters:

localns – locals dict used in the evaluation of the annotations (globals are automatically taken from model.__module__).

Returns:

The provided class (so it can be used as a decorator too).

class gt4py.cartesian.gtc.oir.FieldDecl(data_dims: Tuple[Integral, ...] = NOTHING, *, loc: SourceLocation | None = None, name: Any, dtype: DataType, dimensions: Tuple[bool, bool, bool])[source]

Bases: Decl

data_dims: Tuple[Integral, ...]
dimensions: Tuple[bool, bool, bool]
classmethod update_forward_refs(localns: dict[str, Any] | None = None) → type[_DataModelT]

Update Data Model class meta-information replacing forwarded type annotations with actual types.

Parameters:

localns – locals dict used in the evaluation of the annotations (globals are automatically taken from model.__module__).

Returns:

The provided class (so it can be used as a decorator too).

class gt4py.cartesian.gtc.oir.HorizontalExecution(*, loc: SourceLocation | None = None, body: List[Stmt], declarations: List[LocalScalar])[source]

Bases: LocNode, SymbolTableTrait

body: List[Stmt]
declarations: List[LocalScalar]
classmethod update_forward_refs(localns: dict[str, Any] | None = None) → type[_DataModelT]

Update Data Model class meta-information replacing forwarded type annotations with actual types.

Parameters:

localns – locals dict used in the evaluation of the annotations (globals are automatically taken from model.__module__).

Returns:

The provided class (so it can be used as a decorator too).

class gt4py.cartesian.gtc.oir.HorizontalRestriction(*, loc: SourceLocation | None = None, mask: HorizontalMask, body: List[Stmt])[source]

Bases: HorizontalRestriction__Stmt, Stmt

classmethod update_forward_refs(localns: dict[str, Any] | None = None) → type[_DataModelT]

Update Data Model class meta-information replacing forwarded type annotations with actual types.

Parameters:

localns – locals dict used in the evaluation of the annotations (globals are automatically taken from model.__module__).

Returns:

The provided class (so it can be used as a decorator too).

class gt4py.cartesian.gtc.oir.IJCache(*, loc: SourceLocation | None = None, name: Any)[source]

Bases: CacheDesc

classmethod update_forward_refs(localns: dict[str, Any] | None = None) → type[_DataModelT]

Update Data Model class meta-information replacing forwarded type annotations with actual types.

Parameters:

localns – locals dict used in the evaluation of the annotations (globals are automatically taken from model.__module__).

Returns:

The provided class (so it can be used as a decorator too).

class gt4py.cartesian.gtc.oir.Interval(*, loc: SourceLocation | None = None, start: BaseAxisBound, end: BaseAxisBound)[source]

Bases: LocNode

classmethod check(instance: Interval) → None[source]
covers(other: Interval) → bool[source]
end: BaseAxisBound
classmethod full()[source]
has_runtime_access() → bool[source]

Check if the interval contains runtime-accesses.

Returns:

True if there are runtime bounds to the interval.

Return type:

bool

intersects(other: Interval) → bool[source]
shifted(offset: int | None) → Interval | UnboundedInterval[source]
start: BaseAxisBound
classmethod update_forward_refs(localns: dict[str, Any] | None = None) → type[_DataModelT]

Update Data Model class meta-information replacing forwarded type annotations with actual types.

Parameters:

localns – locals dict used in the evaluation of the annotations (globals are automatically taken from model.__module__).

Returns:

The provided class (so it can be used as a decorator too).

class gt4py.cartesian.gtc.oir.IteratorAccess(*, loc: SourceLocation | None = None, kind: ExprKind = ExprKind.FIELD, dtype: DataType = DataType.AUTO, name: AxisName)[source]

Bases: Expr

class AxisName(*values)[source]

Bases: StrEnum

I = 'I'
J = 'J'
K = 'K'
name: AxisName
classmethod update_forward_refs(localns: dict[str, Any] | None = None) → type[_DataModelT]

Update Data Model class meta-information replacing forwarded type annotations with actual types.

Parameters:

localns – locals dict used in the evaluation of the annotations (globals are automatically taken from model.__module__).

Returns:

The provided class (so it can be used as a decorator too).

class gt4py.cartesian.gtc.oir.KCache(*, loc: SourceLocation | None = None, name: Any, fill: bool, flush: bool)[source]

Bases: CacheDesc

fill: bool
flush: bool
classmethod update_forward_refs(localns: dict[str, Any] | None = None) → type[_DataModelT]

Update Data Model class meta-information replacing forwarded type annotations with actual types.

Parameters:

localns – locals dict used in the evaluation of the annotations (globals are automatically taken from model.__module__).

Returns:

The provided class (so it can be used as a decorator too).

class gt4py.cartesian.gtc.oir.Literal(*, loc: SourceLocation | None = None, value: BuiltInLiteral | str, dtype: DataType, kind: ExprKind = ExprKind.SCALAR)[source]

Bases: Literal, Expr

classmethod update_forward_refs(localns: dict[str, Any] | None = None) → type[_DataModelT]

Update Data Model class meta-information replacing forwarded type annotations with actual types.

Parameters:

localns – locals dict used in the evaluation of the annotations (globals are automatically taken from model.__module__).

Returns:

The provided class (so it can be used as a decorator too).

class gt4py.cartesian.gtc.oir.LocalScalar(*, loc: SourceLocation | None = None, name: Any, dtype: DataType)[source]

Bases: Decl

classmethod update_forward_refs(localns: dict[str, Any] | None = None) → type[_DataModelT]

Update Data Model class meta-information replacing forwarded type annotations with actual types.

Parameters:

localns – locals dict used in the evaluation of the annotations (globals are automatically taken from model.__module__).

Returns:

The provided class (so it can be used as a decorator too).

class gt4py.cartesian.gtc.oir.MaskStmt(*, loc: SourceLocation | None = None, mask: Expr, body: List[Stmt])[source]

Bases: Stmt

body: List[Stmt]
mask: Expr
mask_is_boolean_field_expr(attribute: Attribute, v: Expr) → None[source]
classmethod update_forward_refs(localns: dict[str, Any] | None = None) → type[_DataModelT]

Update Data Model class meta-information replacing forwarded type annotations with actual types.

Parameters:

localns – locals dict used in the evaluation of the annotations (globals are automatically taken from model.__module__).

Returns:

The provided class (so it can be used as a decorator too).

class gt4py.cartesian.gtc.oir.NativeFuncCall(*, loc: SourceLocation | None = None, kind: ExprKind = ExprKind.FIELD, dtype: DataType = DataType.AUTO, func: NativeFunction, args: List[Expr])[source]

Bases: NativeFuncCall__Expr, Expr

classmethod _dtype_propagation(instance: NativeFuncCall) → None
classmethod update_forward_refs(localns: dict[str, Any] | None = None) → type[_DataModelT]

Update Data Model class meta-information replacing forwarded type annotations with actual types.

Parameters:

localns – locals dict used in the evaluation of the annotations (globals are automatically taken from model.__module__).

Returns:

The provided class (so it can be used as a decorator too).

class gt4py.cartesian.gtc.oir.ScalarAccess(*, loc: SourceLocation | None = None, dtype: DataType = DataType.AUTO, name: Any, kind: ExprKind = ExprKind.SCALAR)[source]

Bases: ScalarAccess, Expr

classmethod update_forward_refs(localns: dict[str, Any] | None = None) → type[_DataModelT]

Update Data Model class meta-information replacing forwarded type annotations with actual types.

Parameters:

localns – locals dict used in the evaluation of the annotations (globals are automatically taken from model.__module__).

Returns:

The provided class (so it can be used as a decorator too).

class gt4py.cartesian.gtc.oir.ScalarDecl(*, loc: SourceLocation | None = None, name: Any, dtype: DataType)[source]

Bases: Decl

classmethod update_forward_refs(localns: dict[str, Any] | None = None) → type[_DataModelT]

Update Data Model class meta-information replacing forwarded type annotations with actual types.

Parameters:

localns – locals dict used in the evaluation of the annotations (globals are automatically taken from model.__module__).

Returns:

The provided class (so it can be used as a decorator too).

class gt4py.cartesian.gtc.oir.Stencil(*, loc: SourceLocation | None = None, name: str, params: List[Decl], vertical_loops: List[VerticalLoop], declarations: List[Temporary])[source]

Bases: LocNode, ValidatedSymbolTableTrait

classmethod _validate_dtype_is_set(instance: ExprT) → None
classmethod _validate_lvalue_dims(instance: DataModel) → None
declarations: List[Temporary]
name: str
params: List[Decl]
classmethod update_forward_refs(localns: dict[str, Any] | None = None) → type[_DataModelT]

Update Data Model class meta-information replacing forwarded type annotations with actual types.

Parameters:

localns – locals dict used in the evaluation of the annotations (globals are automatically taken from model.__module__).

Returns:

The provided class (so it can be used as a decorator too).

vertical_loops: List[VerticalLoop]
class gt4py.cartesian.gtc.oir.Stmt(*args: Any, **kwargs: Any)[source]

Bases: Stmt

classmethod update_forward_refs(localns: dict[str, Any] | None = None) → type[_DataModelT]

Update Data Model class meta-information replacing forwarded type annotations with actual types.

Parameters:

localns – locals dict used in the evaluation of the annotations (globals are automatically taken from model.__module__).

Returns:

The provided class (so it can be used as a decorator too).

class gt4py.cartesian.gtc.oir.Temporary(data_dims: Tuple[Integral, ...] = NOTHING, *, loc: SourceLocation | None = None, name: Any, dtype: DataType, dimensions: Tuple[bool, bool, bool])[source]

Bases: FieldDecl

classmethod update_forward_refs(localns: dict[str, Any] | None = None) → type[_DataModelT]

Update Data Model class meta-information replacing forwarded type annotations with actual types.

Parameters:

localns – locals dict used in the evaluation of the annotations (globals are automatically taken from model.__module__).

Returns:

The provided class (so it can be used as a decorator too).

class gt4py.cartesian.gtc.oir.TernaryOp(*, loc: SourceLocation | None = None, kind: ExprKind = ExprKind.FIELD, dtype: DataType = DataType.AUTO, cond: Expr, true_expr: Expr, false_expr: Expr)[source]

Bases: TernaryOp__Expr, Expr

classmethod _dtype_propagation(instance: TernaryOp) → None
classmethod update_forward_refs(localns: dict[str, Any] | None = None) → type[_DataModelT]

Update Data Model class meta-information replacing forwarded type annotations with actual types.

Parameters:

localns – locals dict used in the evaluation of the annotations (globals are automatically taken from model.__module__).

Returns:

The provided class (so it can be used as a decorator too).

class gt4py.cartesian.gtc.oir.UnaryOp(*, loc: SourceLocation | None = None, kind: ExprKind = ExprKind.FIELD, dtype: DataType = DataType.AUTO, op: UnaryOperator, expr: Expr)[source]

Bases: UnaryOp__Expr, Expr

classmethod update_forward_refs(localns: dict[str, Any] | None = None) → type[_DataModelT]

Update Data Model class meta-information replacing forwarded type annotations with actual types.

Parameters:

localns – locals dict used in the evaluation of the annotations (globals are automatically taken from model.__module__).

Returns:

The provided class (so it can be used as a decorator too).

class gt4py.cartesian.gtc.oir.UnboundedInterval[source]

Bases: object

classmethod check(instance: UnboundedInterval) → None[source]
covers(other: Interval | UnboundedInterval) → bool[source]
end: AxisBound | None = None
classmethod full()[source]
intersects(other: Interval | UnboundedInterval) → bool[source]
shifted(offset: int | None) → UnboundedInterval[source]
start: AxisBound | None = None
class gt4py.cartesian.gtc.oir.VariableKOffset(*, k: Expr)[source]

Bases: VariableKOffset__Expr

classmethod update_forward_refs(localns: dict[str, Any] | None = None) → type[_DataModelT]

Update Data Model class meta-information replacing forwarded type annotations with actual types.

Parameters:

localns – locals dict used in the evaluation of the annotations (globals are automatically taken from model.__module__).

Returns:

The provided class (so it can be used as a decorator too).

class gt4py.cartesian.gtc.oir.VerticalLoop(caches: List[CacheDesc] = NOTHING, *, loc: SourceLocation | None = None, loop_order: LoopOrder, sections: List[VerticalLoopSection])[source]

Bases: LocNode

caches: List[CacheDesc]
loop_order: LoopOrder
nonempty_loop(attribute: Attribute, v: List[VerticalLoopSection]) → None[source]
sections: List[VerticalLoopSection]
classmethod update_forward_refs(localns: dict[str, Any] | None = None) → type[_DataModelT]

Update Data Model class meta-information replacing forwarded type annotations with actual types.

Parameters:

localns – locals dict used in the evaluation of the annotations (globals are automatically taken from model.__module__).

Returns:

The provided class (so it can be used as a decorator too).

classmethod valid_section_intervals(instance: VerticalLoop) → None[source]
class gt4py.cartesian.gtc.oir.VerticalLoopSection(*, loc: SourceLocation | None = None, interval: Interval, horizontal_executions: List[HorizontalExecution])[source]

Bases: LocNode

horizontal_executions: List[HorizontalExecution]
interval: Interval
classmethod update_forward_refs(localns: dict[str, Any] | None = None) → type[_DataModelT]

Update Data Model class meta-information replacing forwarded type annotations with actual types.

Parameters:

localns – locals dict used in the evaluation of the annotations (globals are automatically taken from model.__module__).

Returns:

The provided class (so it can be used as a decorator too).

class gt4py.cartesian.gtc.oir.While(*, loc: SourceLocation | None = None, cond: Expr, body: List[Stmt])[source]

Bases: While__Stmt_Expr, Stmt

classmethod update_forward_refs(localns: dict[str, Any] | None = None) → type[_DataModelT]

Update Data Model class meta-information replacing forwarded type annotations with actual types.

Parameters:

localns – locals dict used in the evaluation of the annotations (globals are automatically taken from model.__module__).

Returns:

The provided class (so it can be used as a decorator too).

gt4py.cartesian.gtc.oir._check_interval(instance: Interval | UnboundedInterval) → None[source]

gt4py.cartesian.gtc.ufuncs module

gt4py.cartesian.gtc.ufuncs._round_away_from_zero(num)[source]

Computes the nearest integer value to num, rounding halfway cases away from zero.

gt4py.cartesian.gtc.ufuncs.round_away_from_zero(num)

Computes the nearest integer value to num, rounding halfway cases away from zero.

gt4py.cartesian.gtc.ufuncs.round_away_from_zero_(num)

Computes the nearest integer value to num, rounding halfway cases away from zero.

gt4py.cartesian.gtc.utils module

gt4py.cartesian.gtc.utils.dimension_flags_to_names(mask: Tuple[bool, bool, bool]) → str[source]
gt4py.cartesian.gtc.utils.filter_mask(seq: Sequence[Any], mask: Sequence[bool]) → Tuple[Any, ...][source]

Return a reduced-size tuple, with indices where mask[i]=False removed.

Example: >>> a = (1, 2, 3) >>> mask = (False, True, False) >>> filter_mask(a, mask) (2,)

gt4py.cartesian.gtc.utils.interpolate_mask(seq: Sequence[Any], mask: Sequence[bool], default) → Tuple[Any, ...][source]

Replace True values by those from the seq in the mask, else default.

Example: >>> default = 0 >>> a = (1, 2) >>> mask = (False, True, False, True) >>> interpolate_mask(a, mask, 0) (0, 1, 0, 2)

Module contents