gt4py.cartesian.gtc.passes package
Subpackages
- gt4py.cartesian.gtc.passes.oir_optimizations package
- Submodules
- gt4py.cartesian.gtc.passes.oir_optimizations.caches module
- gt4py.cartesian.gtc.passes.oir_optimizations.horizontal_execution_merging module
- gt4py.cartesian.gtc.passes.oir_optimizations.inlining module
- gt4py.cartesian.gtc.passes.oir_optimizations.mask_stmt_merging module
- gt4py.cartesian.gtc.passes.oir_optimizations.pruning module
- gt4py.cartesian.gtc.passes.oir_optimizations.temporaries module
- gt4py.cartesian.gtc.passes.oir_optimizations.utils module
- gt4py.cartesian.gtc.passes.oir_optimizations.vertical_loop_merging module
- Module contents
Submodules
gt4py.cartesian.gtc.passes.gtir_definitive_assignment_analysis module
- class gt4py.cartesian.gtc.passes.gtir_definitive_assignment_analysis.DefinitiveAssignmentAnalysis[source]
Bases:
gt4py.eve.visitors.NodeVisitor
Analyse gtir stencil expression for access to undefined symbols.
A symbol is said to be defined if it was assigned to in the code-path of its usage. In other words: If a symbol is defined in both branches of an if-statement it may be used outside. If a symbol is only defined in a single branch it may only be used inside that branch unless it was already defined previously (as this is equal to assigning to the previous value again). Note that whether a symbols is defined is independent of the actual result of the condition.
- classmethod apply(gtir_stencil_expr: gt4py.cartesian.gtc.gtir.Stencil) List[gt4py.cartesian.gtc.gtir.FieldAccess] [source]
Execute analysis and return all accesses to undefined symbols.
- visit_FieldAccess(node: gt4py.cartesian.gtc.gtir.FieldAccess, *, alive_vars: Set[str], invalid_accesses: List[gt4py.cartesian.gtc.gtir.FieldAccess], **kwargs) None [source]
- gt4py.cartesian.gtc.passes.gtir_definitive_assignment_analysis.analyze(gtir_stencil_expr: gt4py.cartesian.gtc.gtir.Stencil) List[gt4py.cartesian.gtc.gtir.FieldAccess]
Execute analysis and return all accesses to undefined symbols.
- gt4py.cartesian.gtc.passes.gtir_definitive_assignment_analysis.check(gtir_stencil_expr: gt4py.cartesian.gtc.gtir.Stencil) gt4py.cartesian.gtc.gtir.Stencil [source]
Execute definitive assignment analysis and warn on errors.
gt4py.cartesian.gtc.passes.gtir_dtype_resolver module
- class gt4py.cartesian.gtc.passes.gtir_dtype_resolver._GTIRPropagateDtypeToAccess[source]
Bases:
gt4py.eve.visitors.NodeTranslator
,gt4py.eve.traits.VisitorWithSymbolTableTrait
Propagates dtype from Decl to Access.
Precondition: Decls have dtype (not None), can be AUTO or DEFAULT Postcondition: All dtypes of Access are not None
- visit_FieldAccess(node: gt4py.cartesian.gtc.gtir.FieldAccess, **kwargs: Any) gt4py.cartesian.gtc.gtir.FieldAccess [source]
- visit_ScalarAccess(node: gt4py.cartesian.gtc.gtir.ScalarAccess, *, symtable: Dict[str, Any], **kwargs: Any) gt4py.cartesian.gtc.gtir.ScalarAccess [source]
- class gt4py.cartesian.gtc.passes.gtir_dtype_resolver._GTIRResolveAuto[source]
Bases:
gt4py.eve.visitors.NodeTranslator
,gt4py.eve.traits.VisitorWithSymbolTableTrait
Replaces AUTO dtype by a concrete dtype.
Note that currently only temporaries (FieldDecl/FieldAccess) can have AUTO type.
Precondition: All dtype are set, but some can be set to AUTO Postcondition: All dtypes are concrete (no AUTO)
- visit_FieldAccess(node: gt4py.cartesian.gtc.gtir.FieldAccess, *, symtable: Dict[str, Any], **kwargs: Any) gt4py.cartesian.gtc.gtir.FieldAccess [source]
- visit_ParAssignStmt(node: gt4py.cartesian.gtc.gtir.ParAssignStmt, **kwargs: Any) gt4py.cartesian.gtc.gtir.ParAssignStmt [source]
- visit_Stencil(node: gt4py.cartesian.gtc.gtir.Stencil, **kwargs: Any) gt4py.cartesian.gtc.gtir.Stencil [source]
- gt4py.cartesian.gtc.passes.gtir_dtype_resolver.resolve_dtype(node: gt4py.cartesian.gtc.gtir.Stencil) gt4py.cartesian.gtc.gtir.Stencil [source]
gt4py.cartesian.gtc.passes.gtir_k_boundary module
- class gt4py.cartesian.gtc.passes.gtir_k_boundary.KBoundaryVisitor[source]
Bases:
gt4py.eve.visitors.NodeVisitor
For every field compute the boundary in k, e.g. (2, -1) if [k_origin-2, k_origin+k_domain-1] is accessed.
- gt4py.cartesian.gtc.passes.gtir_k_boundary.compute_k_boundary(node: gt4py.cartesian.gtc.gtir.Stencil, include_center_interval=True) Dict[str, Tuple[int, int]] [source]
- gt4py.cartesian.gtc.passes.gtir_k_boundary.compute_min_k_size(node: gt4py.cartesian.gtc.gtir.Stencil, include_center_interval=True) int [source]
Compute the required number of k levels to run a stencil.
gt4py.cartesian.gtc.passes.gtir_pipeline module
- class gt4py.cartesian.gtc.passes.gtir_pipeline.GtirPipeline(node: gt4py.cartesian.gtc.gtir.Stencil, stencil_id: gt4py.cartesian.definitions.StencilID)[source]
Bases:
object
GTIR passes pipeline runs passes in order and allows skipping.
May only call existing passes and may not contain any pass logic itself.
- apply(steps: Sequence[Callable[[gt4py.cartesian.gtc.gtir.Stencil], gt4py.cartesian.gtc.gtir.Stencil]]) gt4py.cartesian.gtc.gtir.Stencil [source]
- full(skip: Optional[Sequence[Callable[[gt4py.cartesian.gtc.gtir.Stencil], gt4py.cartesian.gtc.gtir.Stencil]]] = None) gt4py.cartesian.gtc.gtir.Stencil [source]
- property stencil_id: gt4py.cartesian.definitions.StencilID
gt4py.cartesian.gtc.passes.gtir_prune_unused_parameters module
- gt4py.cartesian.gtc.passes.gtir_prune_unused_parameters.prune_unused_parameters(node: gt4py.cartesian.gtc.gtir.Stencil) gt4py.cartesian.gtc.gtir.Stencil [source]
Remove unused parameters from the gtir signature.
(Maybe this pass should go into a later stage. If you need to touch this pass, e.g. when the definition_ir gets removed, consider moving it to a more appropriate level. Maybe to the backend IR?)
gt4py.cartesian.gtc.passes.gtir_upcaster module
- class gt4py.cartesian.gtc.passes.gtir_upcaster._GTIRUpcasting[source]
Bases:
gt4py.eve.visitors.NodeTranslator
Introduces Cast nodes (upcasting) for expr involving different datatypes.
Precondition: all dtypes are resolved (no None, Auto, Default) Postcondition: all dtype transitions are explicit via a Cast node
- visit_BinaryOp(node: gt4py.cartesian.gtc.gtir.BinaryOp, **kwargs: Any) gt4py.cartesian.gtc.gtir.BinaryOp [source]
- visit_NativeFuncCall(node: gt4py.cartesian.gtc.gtir.NativeFuncCall, **kwargs: Any) gt4py.cartesian.gtc.gtir.NativeFuncCall [source]
- visit_ParAssignStmt(node: gt4py.cartesian.gtc.gtir.ParAssignStmt, **kwargs: Any) gt4py.cartesian.gtc.gtir.ParAssignStmt [source]
- visit_TernaryOp(node: gt4py.cartesian.gtc.gtir.TernaryOp, **kwargs: Any) gt4py.cartesian.gtc.gtir.TernaryOp [source]
- visit_UnaryOp(node: gt4py.cartesian.gtc.gtir.UnaryOp, **kwargs: Any) gt4py.cartesian.gtc.gtir.UnaryOp [source]
- gt4py.cartesian.gtc.passes.gtir_upcaster._common_upcasting_rule(*dtypes)[source]
Look up upcasting behavior according to C++ casting rules.
- gt4py.cartesian.gtc.passes.gtir_upcaster._numpy_ufunc_upcasting_rule(*dtypes, ufunc: numpy.ufunc)[source]
Look up upcasting behavior according to NumPy universal function casting convention.
NumPy specifies that it chooses ufunc implementations based on input types, where the inputs are suitably cast if necessary. Mimicking this results in a behavior that can be reproduced in C++ backends but is also consistent with python in the numpy backend to the extent possible. We choose ufunc implementations according to NumPy rules while implementing C/C++ type promotion rules, restricted to supported types. See https://numpy.org/doc/stable/user/basics.ufuncs.html?highlight=index#type-casting-rules for details.
- gt4py.cartesian.gtc.passes.gtir_upcaster.upcast(node: gt4py.cartesian.gtc.gtir.Stencil) gt4py.cartesian.gtc.gtir.Stencil [source]
gt4py.cartesian.gtc.passes.horizontal_masks module
- gt4py.cartesian.gtc.passes.horizontal_masks._overlap_along_axis(extent: Tuple[int, int], interval: gt4py.cartesian.gtc.common.HorizontalInterval) Optional[Tuple[int, int]] [source]
Return a tuple of the distances to the edge of the compute domain, if overlapping.
- gt4py.cartesian.gtc.passes.horizontal_masks.compute_relative_mask(extent: gt4py.cartesian.gtc.definitions.Extent, mask: gt4py.cartesian.gtc.common.HorizontalMask) Optional[Tuple[Tuple[gt4py.cartesian.gtc.common.AxisBound, gt4py.cartesian.gtc.common.AxisBound], Tuple[gt4py.cartesian.gtc.common.AxisBound, gt4py.cartesian.gtc.common.AxisBound]]] [source]
Output a HorizontalMask that is relative to and always inside the extent instead of the compute domain.
This is used in the numpy backend to compute HorizontalMask bounds relative to the start/end bounds of the horizontal axes.
- gt4py.cartesian.gtc.passes.horizontal_masks.mask_overlap_with_extent(mask: gt4py.cartesian.gtc.common.HorizontalMask, horizontal_extent: gt4py.cartesian.gtc.definitions.Extent) Optional[gt4py.cartesian.gtc.definitions.Extent] [source]
Compute an overlap extent between a mask and horizontal extent.
gt4py.cartesian.gtc.passes.oir_access_kinds module
- class gt4py.cartesian.gtc.passes.oir_access_kinds.AccessKindComputer[source]
Bases:
gt4py.eve.visitors.NodeVisitor
- visit_AssignStmt(node: gt4py.cartesian.gtc.oir.AssignStmt, **kwargs: Any) None [source]
- visit_FieldAccess(node: gt4py.cartesian.gtc.oir.FieldAccess, **kwargs: Any) None [source]
- visit_HorizontalExecution(node: gt4py.cartesian.gtc.oir.HorizontalExecution, **kwargs: Any) None [source]
- visit_HorizontalRestriction(node: gt4py.cartesian.gtc.oir.HorizontalRestriction, *, horizontal_extent: gt4py.cartesian.gtc.definitions.Extent, **kwargs: Any) None [source]
- visit_MaskStmt(node: gt4py.cartesian.gtc.oir.MaskStmt, **kwargs: Any) None [source]
- visit_ScalarAccess(node: gt4py.cartesian.gtc.oir.ScalarAccess, **kwargs: Any) None [source]
- visit_Stencil(node: gt4py.cartesian.gtc.oir.Stencil) Dict[str, gt4py.cartesian.definitions.AccessKind] [source]
- visit_While(node: gt4py.cartesian.gtc.oir.While, **kwargs: Any) None [source]
- gt4py.cartesian.gtc.passes.oir_access_kinds.compute_access_kinds(stencil: gt4py.cartesian.gtc.oir.Stencil) Dict[str, gt4py.cartesian.definitions.AccessKind] [source]
gt4py.cartesian.gtc.passes.oir_pipeline module
- class gt4py.cartesian.gtc.passes.oir_pipeline.DefaultPipeline(*, skip: Optional[Sequence[Union[Callable[[gt4py.cartesian.gtc.oir.Stencil], gt4py.cartesian.gtc.oir.Stencil], Type[gt4py.eve.visitors.NodeVisitor]]]] = None, add_steps: Optional[Sequence[Union[Callable[[gt4py.cartesian.gtc.oir.Stencil], gt4py.cartesian.gtc.oir.Stencil], Type[gt4py.eve.visitors.NodeVisitor]]]] = None)[source]
Bases:
gt4py.cartesian.gtc.passes.oir_pipeline.OirPipeline
OIR passes pipeline runs passes in order and allows skipping.
May only call existing passes and may not contain any pass logic itself.
- static all_steps() Sequence[Union[Callable[[gt4py.cartesian.gtc.oir.Stencil], gt4py.cartesian.gtc.oir.Stencil], Type[gt4py.eve.visitors.NodeVisitor]]] [source]
- property steps: Sequence[Union[Callable[[gt4py.cartesian.gtc.oir.Stencil], gt4py.cartesian.gtc.oir.Stencil], Type[gt4py.eve.visitors.NodeVisitor]]]
- class gt4py.cartesian.gtc.passes.oir_pipeline.OirPipeline(*args, **kwargs)[source]
Bases:
Protocol
- abstract run(oir: gt4py.cartesian.gtc.oir.Stencil) gt4py.cartesian.gtc.oir.Stencil [source]