From 5b886ce0ff5db00bba808e36c2714ea5c2863e89 Mon Sep 17 00:00:00 2001 From: Sara Faghih-Naini Date: Mon, 30 Dec 2024 16:03:25 +0100 Subject: [PATCH] Renaming and update comments --- src/gt4py/next/ffront/fbuiltins.py | 2 +- src/gt4py/next/iterator/builtins.py | 6 +++--- src/gt4py/next/iterator/ir_utils/ir_makers.py | 2 +- src/gt4py/next/iterator/transforms/infer_domain.py | 2 +- src/gt4py/next/iterator/transforms/prune_casts.py | 2 +- src/gt4py/next/iterator/transforms/trace_shifts.py | 2 +- src/gt4py/next/iterator/type_system/inference.py | 2 +- src/gt4py/next/program_processors/codegens/gtfn/codegen.py | 2 +- src/gt4py/next/program_processors/codegens/gtfn/gtfn_ir.py | 2 +- .../program_processors/codegens/gtfn/itir_to_gtfn_ir.py | 2 +- .../runners/dace_fieldview/gtir_python_codegen.py | 2 +- tests/next_tests/integration_tests/cases.py | 2 +- 12 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/gt4py/next/ffront/fbuiltins.py b/src/gt4py/next/ffront/fbuiltins.py index ba98c80f6b..cef7fc101f 100644 --- a/src/gt4py/next/ffront/fbuiltins.py +++ b/src/gt4py/next/ffront/fbuiltins.py @@ -40,7 +40,7 @@ float32, float64, *PYTHON_TYPE_BUILTINS, -] # TODO(tehrengruber): validate matches itir type builtins? +] # TODO(tehrengruber): validate matches iterator.builtins.TYPE_BUILTINS? TYPE_BUILTIN_NAMES = [t.__name__ for t in TYPE_BUILTINS] diff --git a/src/gt4py/next/iterator/builtins.py b/src/gt4py/next/iterator/builtins.py index 02f6ebbe5c..b20b64e7da 100644 --- a/src/gt4py/next/iterator/builtins.py +++ b/src/gt4py/next/iterator/builtins.py @@ -449,7 +449,7 @@ def bool(*args): # noqa: A001 [builtin-variable-shadowing] "uint64", } # Todo: should we distinguish int and uint? FLOATING_POINT_BUILTINS = {"float32", "float64"} -TYPEBUILTINS = {*INTEGER_BUILTINS, *FLOATING_POINT_BUILTINS, "bool"} +TYPE_BUILTINS = {*INTEGER_BUILTINS, *FLOATING_POINT_BUILTINS, "bool"} MATH_BUILTINS = { *UNARY_MATH_NUMBER_BUILTINS, @@ -457,7 +457,7 @@ def bool(*args): # noqa: A001 [builtin-variable-shadowing] *UNARY_MATH_FP_PREDICATE_BUILTINS, *BINARY_MATH_NUMBER_BUILTINS, "power", - *TYPEBUILTINS, + *TYPE_BUILTINS, } ARITHMETIC_BUILTINS = { @@ -492,7 +492,7 @@ def bool(*args): # noqa: A001 [builtin-variable-shadowing] "tuple_get", "unstructured_domain", *ARITHMETIC_BUILTINS, - *TYPEBUILTINS, + *TYPE_BUILTINS, } __all__ = [*BUILTINS] diff --git a/src/gt4py/next/iterator/ir_utils/ir_makers.py b/src/gt4py/next/iterator/ir_utils/ir_makers.py index 18d72f394b..c5cf2efa5a 100644 --- a/src/gt4py/next/iterator/ir_utils/ir_makers.py +++ b/src/gt4py/next/iterator/ir_utils/ir_makers.py @@ -335,7 +335,7 @@ def literal_from_value(val: core_defs.Scalar) -> itir.Literal: assert isinstance(type_spec, ts.ScalarType) typename = type_spec.kind.name.lower() - assert typename in builtins.TYPEBUILTINS + assert typename in builtins.TYPE_BUILTINS return literal(str(val), typename) diff --git a/src/gt4py/next/iterator/transforms/infer_domain.py b/src/gt4py/next/iterator/transforms/infer_domain.py index 3a52569829..f3c3185225 100644 --- a/src/gt4py/next/iterator/transforms/infer_domain.py +++ b/src/gt4py/next/iterator/transforms/infer_domain.py @@ -384,7 +384,7 @@ def _infer_expr( return _infer_if(expr, domain, **kwargs) elif ( cpm.is_call_to(expr, builtins.ARITHMETIC_BUILTINS) - or cpm.is_call_to(expr, builtins.TYPEBUILTINS) + or cpm.is_call_to(expr, builtins.TYPE_BUILTINS) or cpm.is_call_to(expr, ("cast_", "index", "unstructured_domain", "cartesian_domain")) ): return expr, {} diff --git a/src/gt4py/next/iterator/transforms/prune_casts.py b/src/gt4py/next/iterator/transforms/prune_casts.py index 409b5ee556..3276f47042 100644 --- a/src/gt4py/next/iterator/transforms/prune_casts.py +++ b/src/gt4py/next/iterator/transforms/prune_casts.py @@ -31,7 +31,7 @@ def visit_FunCall(self, node: ir.FunCall) -> ir.Node: assert ( value.type and isinstance(type_constructor, ir.SymRef) - and (type_constructor.id in builtins.TYPEBUILTINS) + and (type_constructor.id in builtins.TYPE_BUILTINS) ) dtype = ts.ScalarType(kind=getattr(ts.ScalarKind, type_constructor.id.upper())) diff --git a/src/gt4py/next/iterator/transforms/trace_shifts.py b/src/gt4py/next/iterator/transforms/trace_shifts.py index 38ab398941..4c44d660f6 100644 --- a/src/gt4py/next/iterator/transforms/trace_shifts.py +++ b/src/gt4py/next/iterator/transforms/trace_shifts.py @@ -278,7 +278,7 @@ def visit_Literal(self, node: ir.SymRef, *, ctx: dict[str, Any]) -> Any: def visit_SymRef(self, node: ir.SymRef, *, ctx: dict[str, Any]) -> Any: if node.id in ctx: return ctx[node.id] - elif node.id in builtins.TYPEBUILTINS: + elif node.id in builtins.TYPE_BUILTINS: return Sentinel.TYPE elif node.id in (builtins.ARITHMETIC_BUILTINS | {"list_get", "make_const_list", "cast_"}): return _combine diff --git a/src/gt4py/next/iterator/type_system/inference.py b/src/gt4py/next/iterator/type_system/inference.py index b7e0729a4b..0b69293f3a 100644 --- a/src/gt4py/next/iterator/type_system/inference.py +++ b/src/gt4py/next/iterator/type_system/inference.py @@ -580,7 +580,7 @@ def visit_FunCall( self.visit(value, ctx=ctx) # ensure types in value are also inferred assert ( isinstance(type_constructor, itir.SymRef) - and type_constructor.id in builtins.TYPEBUILTINS + and type_constructor.id in builtins.TYPE_BUILTINS ) return ts.ScalarType(kind=getattr(ts.ScalarKind, type_constructor.id.upper())) diff --git a/src/gt4py/next/program_processors/codegens/gtfn/codegen.py b/src/gt4py/next/program_processors/codegens/gtfn/codegen.py index 6b0ead5239..eb71eabc3c 100644 --- a/src/gt4py/next/program_processors/codegens/gtfn/codegen.py +++ b/src/gt4py/next/program_processors/codegens/gtfn/codegen.py @@ -107,7 +107,7 @@ def visit_Literal(self, node: gtfn_ir.Literal, **kwargs: Any) -> str: case "bool": return node.value.lower() case _: - # TODO: we should probably shouldn't just allow anything here. revisit. + # TODO(tehrengruber): we should probably shouldn't just allow anything here. Revisit. return node.value IntegralConstant = as_fmt("{value}_c") diff --git a/src/gt4py/next/program_processors/codegens/gtfn/gtfn_ir.py b/src/gt4py/next/program_processors/codegens/gtfn/gtfn_ir.py index 39ac04ecc0..831694791a 100644 --- a/src/gt4py/next/program_processors/codegens/gtfn/gtfn_ir.py +++ b/src/gt4py/next/program_processors/codegens/gtfn/gtfn_ir.py @@ -231,7 +231,7 @@ class TemporaryAllocation(Node): "index", ] ARITHMETIC_BUILTINS = builtins.ARITHMETIC_BUILTINS -TYPEBUILTINS = builtins.TYPEBUILTINS +TYPEBUILTINS = builtins.TYPE_BUILTINS BUILTINS = {*GTFN_BUILTINS, *ARITHMETIC_BUILTINS, *TYPEBUILTINS} diff --git a/src/gt4py/next/program_processors/codegens/gtfn/itir_to_gtfn_ir.py b/src/gt4py/next/program_processors/codegens/gtfn/itir_to_gtfn_ir.py index ed1cf77904..d688138905 100644 --- a/src/gt4py/next/program_processors/codegens/gtfn/itir_to_gtfn_ir.py +++ b/src/gt4py/next/program_processors/codegens/gtfn/itir_to_gtfn_ir.py @@ -64,7 +64,7 @@ def pytype_to_cpptype(t: ts.ScalarType | str) -> Optional[str]: "uint64": "std::uint64_t", "bool": "bool", "string": "string", - "axis_literal": None, # TODO: domain? + "axis_literal": None, # TODO(tehrengruber): domain? }[t] except KeyError: raise TypeError(f"Unsupported type '{t}'.") from None diff --git a/src/gt4py/next/program_processors/runners/dace_fieldview/gtir_python_codegen.py b/src/gt4py/next/program_processors/runners/dace_fieldview/gtir_python_codegen.py index 883f2f946b..c5ba0d9551 100644 --- a/src/gt4py/next/program_processors/runners/dace_fieldview/gtir_python_codegen.py +++ b/src/gt4py/next/program_processors/runners/dace_fieldview/gtir_python_codegen.py @@ -75,7 +75,7 @@ def builtin_cast(*args: Any) -> str: val, target_type = args - assert target_type in builtins.TYPEBUILTINS + assert target_type in builtins.TYPE_BUILTINS return MATH_BUILTINS_MAPPING[target_type].format(val) diff --git a/tests/next_tests/integration_tests/cases.py b/tests/next_tests/integration_tests/cases.py index 98103fe901..5070dd71a5 100644 --- a/tests/next_tests/integration_tests/cases.py +++ b/tests/next_tests/integration_tests/cases.py @@ -192,7 +192,7 @@ class UniqueInitializer(DataInitializer): data containers. """ - start: int = 1 # PR comment: do not start from zero as this has the same value as zero-initialized memory + start: int = 1 @property def scalar_value(self) -> ScalarValue: