Skip to content

Commit

Permalink
Renaming and update comments
Browse files Browse the repository at this point in the history
  • Loading branch information
SF-N committed Dec 30, 2024
1 parent 52c7e6e commit 5b886ce
Show file tree
Hide file tree
Showing 12 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/gt4py/next/ffront/fbuiltins.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down
6 changes: 3 additions & 3 deletions src/gt4py/next/iterator/builtins.py
Original file line number Diff line number Diff line change
Expand Up @@ -449,15 +449,15 @@ 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,
*UNARY_MATH_FP_BUILTINS,
*UNARY_MATH_FP_PREDICATE_BUILTINS,
*BINARY_MATH_NUMBER_BUILTINS,
"power",
*TYPEBUILTINS,
*TYPE_BUILTINS,
}

ARITHMETIC_BUILTINS = {
Expand Down Expand Up @@ -492,7 +492,7 @@ def bool(*args): # noqa: A001 [builtin-variable-shadowing]
"tuple_get",
"unstructured_domain",
*ARITHMETIC_BUILTINS,
*TYPEBUILTINS,
*TYPE_BUILTINS,
}

__all__ = [*BUILTINS]
2 changes: 1 addition & 1 deletion src/gt4py/next/iterator/ir_utils/ir_makers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion src/gt4py/next/iterator/transforms/infer_domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -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, {}
Expand Down
2 changes: 1 addition & 1 deletion src/gt4py/next/iterator/transforms/prune_casts.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()))

Expand Down
2 changes: 1 addition & 1 deletion src/gt4py/next/iterator/transforms/trace_shifts.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/gt4py/next/iterator/type_system/inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()))

Expand Down
2 changes: 1 addition & 1 deletion src/gt4py/next/program_processors/codegens/gtfn/codegen.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion src/gt4py/next/program_processors/codegens/gtfn/gtfn_ir.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down
2 changes: 1 addition & 1 deletion tests/next_tests/integration_tests/cases.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 5b886ce

Please sign in to comment.