From e827d9cde204bdf630609a2f534c190cfe47a7e8 Mon Sep 17 00:00:00 2001 From: Frederik Hennig <frederik.hennig@fau.de> Date: Fri, 2 Feb 2024 13:48:22 +0100 Subject: [PATCH] rename KernelCreationOptions to CreateKernelConfig --- src/pystencils/nbackend/kernelcreation/__init__.py | 4 ++-- .../kernelcreation/{options.py => config.py} | 2 +- src/pystencils/nbackend/kernelcreation/context.py | 6 +++--- .../nbackend/kernelcreation/kernelcreation.py | 4 ++-- .../kernelcreation/platform/test_basic_cpu.py | 4 ++-- tests/nbackend/kernelcreation/test_freeze.py | 6 +++--- tests/nbackend/kernelcreation/test_index_kernels.py | 4 ++-- .../nbackend/kernelcreation/test_iteration_space.py | 4 ++-- tests/nbackend/kernelcreation/test_options.py | 10 +++++----- tests/nbackend/kernelcreation/test_typification.py | 12 ++++++------ 10 files changed, 28 insertions(+), 28 deletions(-) rename src/pystencils/nbackend/kernelcreation/{options.py => config.py} (99%) diff --git a/src/pystencils/nbackend/kernelcreation/__init__.py b/src/pystencils/nbackend/kernelcreation/__init__.py index 18b1acc48..1f7aad5ad 100644 --- a/src/pystencils/nbackend/kernelcreation/__init__.py +++ b/src/pystencils/nbackend/kernelcreation/__init__.py @@ -1,4 +1,4 @@ -from .options import KernelCreationOptions +from .config import CreateKernelConfig from .kernelcreation import create_kernel from .context import KernelCreationContext @@ -14,7 +14,7 @@ from .iteration_space import ( ) __all__ = [ - "KernelCreationOptions", + "CreateKernelConfig", "create_kernel", "KernelCreationContext", "KernelAnalysis", diff --git a/src/pystencils/nbackend/kernelcreation/options.py b/src/pystencils/nbackend/kernelcreation/config.py similarity index 99% rename from src/pystencils/nbackend/kernelcreation/options.py rename to src/pystencils/nbackend/kernelcreation/config.py index 53fbbd640..53f4d95cc 100644 --- a/src/pystencils/nbackend/kernelcreation/options.py +++ b/src/pystencils/nbackend/kernelcreation/config.py @@ -11,7 +11,7 @@ from .defaults import Sympy as SpDefaults @dataclass -class KernelCreationOptions: +class CreateKernelConfig: """Options for create_kernel.""" target: Target = Target.CPU diff --git a/src/pystencils/nbackend/kernelcreation/context.py b/src/pystencils/nbackend/kernelcreation/context.py index 29eeb0265..b46fbeb96 100644 --- a/src/pystencils/nbackend/kernelcreation/context.py +++ b/src/pystencils/nbackend/kernelcreation/context.py @@ -9,7 +9,7 @@ from ..types.quick import make_type from ..constraints import PsKernelConstraint from ..exceptions import PsInternalCompilerError, KernelConstraintsError -from .options import KernelCreationOptions +from .config import CreateKernelConfig from .iteration_space import IterationSpace, FullIterationSpace, SparseIterationSpace @@ -44,7 +44,7 @@ class KernelCreationContext: or full iteration space. """ - def __init__(self, options: KernelCreationOptions): + def __init__(self, options: CreateKernelConfig): self._options = options self._arrays: dict[Field, PsLinearizedArray] = dict() self._constraints: list[PsKernelConstraint] = [] @@ -53,7 +53,7 @@ class KernelCreationContext: self._ispace: IterationSpace | None = None @property - def options(self) -> KernelCreationOptions: + def options(self) -> CreateKernelConfig: return self._options @property diff --git a/src/pystencils/nbackend/kernelcreation/kernelcreation.py b/src/pystencils/nbackend/kernelcreation/kernelcreation.py index 705d10e82..9d2f2996d 100644 --- a/src/pystencils/nbackend/kernelcreation/kernelcreation.py +++ b/src/pystencils/nbackend/kernelcreation/kernelcreation.py @@ -7,7 +7,7 @@ from .context import KernelCreationContext from .analysis import KernelAnalysis from .freeze import FreezeExpressions from .typification import Typifier -from .options import KernelCreationOptions +from .config import CreateKernelConfig from .iteration_space import ( create_sparse_iteration_space, create_full_iteration_space, @@ -17,7 +17,7 @@ from .transformations import EraseAnonymousStructTypes def create_kernel( assignments: AssignmentCollection, - options: KernelCreationOptions = KernelCreationOptions(), + options: CreateKernelConfig = CreateKernelConfig(), ): ctx = KernelCreationContext(options) diff --git a/tests/nbackend/kernelcreation/platform/test_basic_cpu.py b/tests/nbackend/kernelcreation/platform/test_basic_cpu.py index c0fb70625..540985a2a 100644 --- a/tests/nbackend/kernelcreation/platform/test_basic_cpu.py +++ b/tests/nbackend/kernelcreation/platform/test_basic_cpu.py @@ -4,7 +4,7 @@ from pystencils.field import Field from pystencils.nbackend.kernelcreation import ( KernelCreationContext, - KernelCreationOptions, + CreateKernelConfig, FullIterationSpace ) @@ -14,7 +14,7 @@ from pystencils.nbackend.kernelcreation.platform import BasicCpu @pytest.mark.parametrize("layout", ["fzyx", "zyxf", "c", "f"]) def test_loop_nest(layout): - ctx = KernelCreationContext(KernelCreationOptions()) + ctx = KernelCreationContext(CreateKernelConfig()) body = PsBlock([PsComment("Loop body goes here")]) platform = BasicCpu(ctx) diff --git a/tests/nbackend/kernelcreation/test_freeze.py b/tests/nbackend/kernelcreation/test_freeze.py index 2d608ac8b..ca3a470a5 100644 --- a/tests/nbackend/kernelcreation/test_freeze.py +++ b/tests/nbackend/kernelcreation/test_freeze.py @@ -13,7 +13,7 @@ from pystencils.nbackend.ast import ( from pystencils.nbackend.typed_expressions import PsTypedConstant, PsTypedVariable from pystencils.nbackend.arrays import PsArrayAccess from pystencils.nbackend.kernelcreation import ( - KernelCreationOptions, + CreateKernelConfig, KernelCreationContext, FreezeExpressions, FullIterationSpace, @@ -21,7 +21,7 @@ from pystencils.nbackend.kernelcreation import ( def test_freeze_simple(): - options = KernelCreationOptions() + options = CreateKernelConfig() ctx = KernelCreationContext(options) freeze = FreezeExpressions(ctx) @@ -37,7 +37,7 @@ def test_freeze_simple(): def test_freeze_fields(): - options = KernelCreationOptions() + options = CreateKernelConfig() ctx = KernelCreationContext(options) zero = PsTypedConstant(0, ctx.index_dtype) diff --git a/tests/nbackend/kernelcreation/test_index_kernels.py b/tests/nbackend/kernelcreation/test_index_kernels.py index fde27632e..e8a32b6b4 100644 --- a/tests/nbackend/kernelcreation/test_index_kernels.py +++ b/tests/nbackend/kernelcreation/test_index_kernels.py @@ -4,7 +4,7 @@ import sympy as sp import numpy as np from pystencils import Assignment, Field, FieldType, AssignmentCollection -from pystencils.nbackend.kernelcreation import create_kernel, KernelCreationOptions +from pystencils.nbackend.kernelcreation import create_kernel, CreateKernelConfig from pystencils.cpu.cpujit import compile_and_load def test_indexed_kernel(): @@ -21,7 +21,7 @@ def test_indexed_kernel(): Assignment(normal_field[0, 0], index_field('value')) ]) - options = KernelCreationOptions(index_field=index_field) + options = CreateKernelConfig(index_field=index_field) ast = create_kernel(update_rule, options) kernel = compile_and_load(ast) diff --git a/tests/nbackend/kernelcreation/test_iteration_space.py b/tests/nbackend/kernelcreation/test_iteration_space.py index 935bf4e70..e785b64a2 100644 --- a/tests/nbackend/kernelcreation/test_iteration_space.py +++ b/tests/nbackend/kernelcreation/test_iteration_space.py @@ -2,7 +2,7 @@ from pystencils.field import Field from pystencils.nbackend.kernelcreation import ( KernelCreationContext, - KernelCreationOptions, + CreateKernelConfig, FullIterationSpace ) @@ -10,7 +10,7 @@ from pystencils.nbackend.kernelcreation.defaults import Pymbolic as PbDefaults def test_loop_order(): - ctx = KernelCreationContext(KernelCreationOptions()) + ctx = KernelCreationContext(CreateKernelConfig()) ctr_symbols = PbDefaults.spatial_counters # FZYX Order diff --git a/tests/nbackend/kernelcreation/test_options.py b/tests/nbackend/kernelcreation/test_options.py index 7f26288d4..77b13da0c 100644 --- a/tests/nbackend/kernelcreation/test_options.py +++ b/tests/nbackend/kernelcreation/test_options.py @@ -2,8 +2,8 @@ import pytest from pystencils.field import Field, FieldType from pystencils.nbackend.types.quick import * -from pystencils.nbackend.kernelcreation.options import ( - KernelCreationOptions, +from pystencils.nbackend.kernelcreation.config import ( + CreateKernelConfig, PsOptionsError, ) @@ -13,11 +13,11 @@ def test_invalid_iteration_region_options(): "idx", spatial_dimensions=1, field_type=FieldType.INDEXED ) with pytest.raises(PsOptionsError): - KernelCreationOptions( + CreateKernelConfig( ghost_layers=2, iteration_slice=(slice(1, -1), slice(1, -1)) ) with pytest.raises(PsOptionsError): - KernelCreationOptions(ghost_layers=2, index_field=idx_field) + CreateKernelConfig(ghost_layers=2, index_field=idx_field) def test_index_field_options(): @@ -25,4 +25,4 @@ def test_index_field_options(): idx_field = Field.create_generic( "idx", spatial_dimensions=1, field_type=FieldType.GENERIC ) - KernelCreationOptions(index_field=idx_field) + CreateKernelConfig(index_field=idx_field) diff --git a/tests/nbackend/kernelcreation/test_typification.py b/tests/nbackend/kernelcreation/test_typification.py index e5e88b2f6..26d702b23 100644 --- a/tests/nbackend/kernelcreation/test_typification.py +++ b/tests/nbackend/kernelcreation/test_typification.py @@ -6,17 +6,17 @@ import pymbolic.primitives as pb from pystencils import Assignment, TypedSymbol, Field, FieldType from pystencils.nbackend.ast import PsDeclaration -from pystencils.nbackend.types import constify, deconstify, PsStructType +from pystencils.nbackend.types import constify from pystencils.nbackend.types.quick import * from pystencils.nbackend.typed_expressions import PsTypedConstant, PsTypedVariable -from pystencils.nbackend.kernelcreation.options import KernelCreationOptions +from pystencils.nbackend.kernelcreation.config import CreateKernelConfig from pystencils.nbackend.kernelcreation.context import KernelCreationContext from pystencils.nbackend.kernelcreation.freeze import FreezeExpressions from pystencils.nbackend.kernelcreation.typification import Typifier, TypificationError def test_typify_simple(): - options = KernelCreationOptions() + options = CreateKernelConfig() ctx = KernelCreationContext(options) freeze = FreezeExpressions(ctx) typify = Typifier(ctx) @@ -47,7 +47,7 @@ def test_typify_simple(): def test_typify_structs(): - options = KernelCreationOptions(default_dtype=Fp(32)) + options = CreateKernelConfig(default_dtype=Fp(32)) ctx = KernelCreationContext(options) freeze = FreezeExpressions(ctx) typify = Typifier(ctx) @@ -69,7 +69,7 @@ def test_typify_structs(): def test_contextual_typing(): - options = KernelCreationOptions() + options = CreateKernelConfig() ctx = KernelCreationContext(options) freeze = FreezeExpressions(ctx) typify = Typifier(ctx) @@ -95,7 +95,7 @@ def test_contextual_typing(): def test_erronous_typing(): - options = KernelCreationOptions(default_dtype=make_numeric_type(np.float64)) + options = CreateKernelConfig(default_dtype=make_numeric_type(np.float64)) ctx = KernelCreationContext(options) freeze = FreezeExpressions(ctx) typify = Typifier(ctx) -- GitLab