Skip to content
Snippets Groups Projects
Commit e827d9cd authored by Frederik Hennig's avatar Frederik Hennig
Browse files

rename KernelCreationOptions to CreateKernelConfig

parent 62e47f74
Branches
Tags
No related merge requests found
Pipeline #61647 failed
from .options import KernelCreationOptions from .config import CreateKernelConfig
from .kernelcreation import create_kernel from .kernelcreation import create_kernel
from .context import KernelCreationContext from .context import KernelCreationContext
...@@ -14,7 +14,7 @@ from .iteration_space import ( ...@@ -14,7 +14,7 @@ from .iteration_space import (
) )
__all__ = [ __all__ = [
"KernelCreationOptions", "CreateKernelConfig",
"create_kernel", "create_kernel",
"KernelCreationContext", "KernelCreationContext",
"KernelAnalysis", "KernelAnalysis",
......
...@@ -11,7 +11,7 @@ from .defaults import Sympy as SpDefaults ...@@ -11,7 +11,7 @@ from .defaults import Sympy as SpDefaults
@dataclass @dataclass
class KernelCreationOptions: class CreateKernelConfig:
"""Options for create_kernel.""" """Options for create_kernel."""
target: Target = Target.CPU target: Target = Target.CPU
......
...@@ -9,7 +9,7 @@ from ..types.quick import make_type ...@@ -9,7 +9,7 @@ from ..types.quick import make_type
from ..constraints import PsKernelConstraint from ..constraints import PsKernelConstraint
from ..exceptions import PsInternalCompilerError, KernelConstraintsError from ..exceptions import PsInternalCompilerError, KernelConstraintsError
from .options import KernelCreationOptions from .config import CreateKernelConfig
from .iteration_space import IterationSpace, FullIterationSpace, SparseIterationSpace from .iteration_space import IterationSpace, FullIterationSpace, SparseIterationSpace
...@@ -44,7 +44,7 @@ class KernelCreationContext: ...@@ -44,7 +44,7 @@ class KernelCreationContext:
or full iteration space. or full iteration space.
""" """
def __init__(self, options: KernelCreationOptions): def __init__(self, options: CreateKernelConfig):
self._options = options self._options = options
self._arrays: dict[Field, PsLinearizedArray] = dict() self._arrays: dict[Field, PsLinearizedArray] = dict()
self._constraints: list[PsKernelConstraint] = [] self._constraints: list[PsKernelConstraint] = []
...@@ -53,7 +53,7 @@ class KernelCreationContext: ...@@ -53,7 +53,7 @@ class KernelCreationContext:
self._ispace: IterationSpace | None = None self._ispace: IterationSpace | None = None
@property @property
def options(self) -> KernelCreationOptions: def options(self) -> CreateKernelConfig:
return self._options return self._options
@property @property
......
...@@ -7,7 +7,7 @@ from .context import KernelCreationContext ...@@ -7,7 +7,7 @@ from .context import KernelCreationContext
from .analysis import KernelAnalysis from .analysis import KernelAnalysis
from .freeze import FreezeExpressions from .freeze import FreezeExpressions
from .typification import Typifier from .typification import Typifier
from .options import KernelCreationOptions from .config import CreateKernelConfig
from .iteration_space import ( from .iteration_space import (
create_sparse_iteration_space, create_sparse_iteration_space,
create_full_iteration_space, create_full_iteration_space,
...@@ -17,7 +17,7 @@ from .transformations import EraseAnonymousStructTypes ...@@ -17,7 +17,7 @@ from .transformations import EraseAnonymousStructTypes
def create_kernel( def create_kernel(
assignments: AssignmentCollection, assignments: AssignmentCollection,
options: KernelCreationOptions = KernelCreationOptions(), options: CreateKernelConfig = CreateKernelConfig(),
): ):
ctx = KernelCreationContext(options) ctx = KernelCreationContext(options)
......
...@@ -4,7 +4,7 @@ from pystencils.field import Field ...@@ -4,7 +4,7 @@ from pystencils.field import Field
from pystencils.nbackend.kernelcreation import ( from pystencils.nbackend.kernelcreation import (
KernelCreationContext, KernelCreationContext,
KernelCreationOptions, CreateKernelConfig,
FullIterationSpace FullIterationSpace
) )
...@@ -14,7 +14,7 @@ from pystencils.nbackend.kernelcreation.platform import BasicCpu ...@@ -14,7 +14,7 @@ from pystencils.nbackend.kernelcreation.platform import BasicCpu
@pytest.mark.parametrize("layout", ["fzyx", "zyxf", "c", "f"]) @pytest.mark.parametrize("layout", ["fzyx", "zyxf", "c", "f"])
def test_loop_nest(layout): def test_loop_nest(layout):
ctx = KernelCreationContext(KernelCreationOptions()) ctx = KernelCreationContext(CreateKernelConfig())
body = PsBlock([PsComment("Loop body goes here")]) body = PsBlock([PsComment("Loop body goes here")])
platform = BasicCpu(ctx) platform = BasicCpu(ctx)
......
...@@ -13,7 +13,7 @@ from pystencils.nbackend.ast import ( ...@@ -13,7 +13,7 @@ from pystencils.nbackend.ast import (
from pystencils.nbackend.typed_expressions import PsTypedConstant, PsTypedVariable from pystencils.nbackend.typed_expressions import PsTypedConstant, PsTypedVariable
from pystencils.nbackend.arrays import PsArrayAccess from pystencils.nbackend.arrays import PsArrayAccess
from pystencils.nbackend.kernelcreation import ( from pystencils.nbackend.kernelcreation import (
KernelCreationOptions, CreateKernelConfig,
KernelCreationContext, KernelCreationContext,
FreezeExpressions, FreezeExpressions,
FullIterationSpace, FullIterationSpace,
...@@ -21,7 +21,7 @@ from pystencils.nbackend.kernelcreation import ( ...@@ -21,7 +21,7 @@ from pystencils.nbackend.kernelcreation import (
def test_freeze_simple(): def test_freeze_simple():
options = KernelCreationOptions() options = CreateKernelConfig()
ctx = KernelCreationContext(options) ctx = KernelCreationContext(options)
freeze = FreezeExpressions(ctx) freeze = FreezeExpressions(ctx)
...@@ -37,7 +37,7 @@ def test_freeze_simple(): ...@@ -37,7 +37,7 @@ def test_freeze_simple():
def test_freeze_fields(): def test_freeze_fields():
options = KernelCreationOptions() options = CreateKernelConfig()
ctx = KernelCreationContext(options) ctx = KernelCreationContext(options)
zero = PsTypedConstant(0, ctx.index_dtype) zero = PsTypedConstant(0, ctx.index_dtype)
......
...@@ -4,7 +4,7 @@ import sympy as sp ...@@ -4,7 +4,7 @@ import sympy as sp
import numpy as np import numpy as np
from pystencils import Assignment, Field, FieldType, AssignmentCollection 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 from pystencils.cpu.cpujit import compile_and_load
def test_indexed_kernel(): def test_indexed_kernel():
...@@ -21,7 +21,7 @@ def test_indexed_kernel(): ...@@ -21,7 +21,7 @@ def test_indexed_kernel():
Assignment(normal_field[0, 0], index_field('value')) 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) ast = create_kernel(update_rule, options)
kernel = compile_and_load(ast) kernel = compile_and_load(ast)
......
...@@ -2,7 +2,7 @@ from pystencils.field import Field ...@@ -2,7 +2,7 @@ from pystencils.field import Field
from pystencils.nbackend.kernelcreation import ( from pystencils.nbackend.kernelcreation import (
KernelCreationContext, KernelCreationContext,
KernelCreationOptions, CreateKernelConfig,
FullIterationSpace FullIterationSpace
) )
...@@ -10,7 +10,7 @@ from pystencils.nbackend.kernelcreation.defaults import Pymbolic as PbDefaults ...@@ -10,7 +10,7 @@ from pystencils.nbackend.kernelcreation.defaults import Pymbolic as PbDefaults
def test_loop_order(): def test_loop_order():
ctx = KernelCreationContext(KernelCreationOptions()) ctx = KernelCreationContext(CreateKernelConfig())
ctr_symbols = PbDefaults.spatial_counters ctr_symbols = PbDefaults.spatial_counters
# FZYX Order # FZYX Order
......
...@@ -2,8 +2,8 @@ import pytest ...@@ -2,8 +2,8 @@ import pytest
from pystencils.field import Field, FieldType from pystencils.field import Field, FieldType
from pystencils.nbackend.types.quick import * from pystencils.nbackend.types.quick import *
from pystencils.nbackend.kernelcreation.options import ( from pystencils.nbackend.kernelcreation.config import (
KernelCreationOptions, CreateKernelConfig,
PsOptionsError, PsOptionsError,
) )
...@@ -13,11 +13,11 @@ def test_invalid_iteration_region_options(): ...@@ -13,11 +13,11 @@ def test_invalid_iteration_region_options():
"idx", spatial_dimensions=1, field_type=FieldType.INDEXED "idx", spatial_dimensions=1, field_type=FieldType.INDEXED
) )
with pytest.raises(PsOptionsError): with pytest.raises(PsOptionsError):
KernelCreationOptions( CreateKernelConfig(
ghost_layers=2, iteration_slice=(slice(1, -1), slice(1, -1)) ghost_layers=2, iteration_slice=(slice(1, -1), slice(1, -1))
) )
with pytest.raises(PsOptionsError): 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(): def test_index_field_options():
...@@ -25,4 +25,4 @@ def test_index_field_options(): ...@@ -25,4 +25,4 @@ def test_index_field_options():
idx_field = Field.create_generic( idx_field = Field.create_generic(
"idx", spatial_dimensions=1, field_type=FieldType.GENERIC "idx", spatial_dimensions=1, field_type=FieldType.GENERIC
) )
KernelCreationOptions(index_field=idx_field) CreateKernelConfig(index_field=idx_field)
...@@ -6,17 +6,17 @@ import pymbolic.primitives as pb ...@@ -6,17 +6,17 @@ import pymbolic.primitives as pb
from pystencils import Assignment, TypedSymbol, Field, FieldType from pystencils import Assignment, TypedSymbol, Field, FieldType
from pystencils.nbackend.ast import PsDeclaration 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.types.quick import *
from pystencils.nbackend.typed_expressions import PsTypedConstant, PsTypedVariable 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.context import KernelCreationContext
from pystencils.nbackend.kernelcreation.freeze import FreezeExpressions from pystencils.nbackend.kernelcreation.freeze import FreezeExpressions
from pystencils.nbackend.kernelcreation.typification import Typifier, TypificationError from pystencils.nbackend.kernelcreation.typification import Typifier, TypificationError
def test_typify_simple(): def test_typify_simple():
options = KernelCreationOptions() options = CreateKernelConfig()
ctx = KernelCreationContext(options) ctx = KernelCreationContext(options)
freeze = FreezeExpressions(ctx) freeze = FreezeExpressions(ctx)
typify = Typifier(ctx) typify = Typifier(ctx)
...@@ -47,7 +47,7 @@ def test_typify_simple(): ...@@ -47,7 +47,7 @@ def test_typify_simple():
def test_typify_structs(): def test_typify_structs():
options = KernelCreationOptions(default_dtype=Fp(32)) options = CreateKernelConfig(default_dtype=Fp(32))
ctx = KernelCreationContext(options) ctx = KernelCreationContext(options)
freeze = FreezeExpressions(ctx) freeze = FreezeExpressions(ctx)
typify = Typifier(ctx) typify = Typifier(ctx)
...@@ -69,7 +69,7 @@ def test_typify_structs(): ...@@ -69,7 +69,7 @@ def test_typify_structs():
def test_contextual_typing(): def test_contextual_typing():
options = KernelCreationOptions() options = CreateKernelConfig()
ctx = KernelCreationContext(options) ctx = KernelCreationContext(options)
freeze = FreezeExpressions(ctx) freeze = FreezeExpressions(ctx)
typify = Typifier(ctx) typify = Typifier(ctx)
...@@ -95,7 +95,7 @@ def test_contextual_typing(): ...@@ -95,7 +95,7 @@ def test_contextual_typing():
def test_erronous_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) ctx = KernelCreationContext(options)
freeze = FreezeExpressions(ctx) freeze = FreezeExpressions(ctx)
typify = Typifier(ctx) typify = Typifier(ctx)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment