Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for queried dtypes in tuples with registerCommands #3672

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 30 additions & 23 deletions src/registry/register_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,34 +162,31 @@ def info_tuple(formal):
ten = "<homog_tuple>"
actuals = list(te.actuals())

# check the tuple element type
if not (
isinstance(actuals[1], chapel.Identifier)
and actuals[1].name() in chapel_scalar_types
):
# check the tuple element type (must be an identifier - either corresponding to a scalar type or a dtype query)
if isinstance(actuals[1], chapel.Identifier):
tuple_elt_type = actuals[1].name()
else:
error_message(
f"registering '{fn.name()}'",
f"unsupported homog_tuple type expression for registration on formal '{formal.name()}'; "
+ f"tuple element type must be a scalar (one of {chapel_scalar_types.keys()})",
+ f"tuple element type must be an identifier (either a scalar type or a queried dtype)",
)
else:
tuple_elt_type = actuals[1].name()

# check the tuple size (should be an int literal or a queried domain's rank)
if isinstance(actuals[0], chapel.IntLiteral):
extra_info = (int(actuals[0].text()), tuple_elt_type)
elif (
isinstance(actuals[0], chapel.Dot)
and actuals[0].field() == "rank"
and isinstance(actuals[0].receiver(), chapel.Identifier)
):
extra_info = (actuals[0].receiver().name(), tuple_elt_type)
else:
error_message(
f"registering '{fn.name()}'",
f"unsupported homog_tuple type expression for registration on formal '{formal.name()}'; "
+ "tuple size must be an int literal or a queried domain's rank",
)
# check the tuple size (should be an int literal or a queried domain's rank)
if isinstance(actuals[0], chapel.IntLiteral):
extra_info = (int(actuals[0].text()), tuple_elt_type)
elif (
isinstance(actuals[0], chapel.Dot)
and actuals[0].field() == "rank"
and isinstance(actuals[0].receiver(), chapel.Identifier)
):
extra_info = (actuals[0].receiver().name(), tuple_elt_type)
else:
error_message(
f"registering '{fn.name()}'",
f"unsupported homog_tuple type expression for registration on formal '{formal.name()}'; "
+ "tuple size must be an int literal or a queried domain's rank",
)
else:
ten = te.name()
return (formal.name(), formal.storage_kind(), ten, extra_info)
Expand Down Expand Up @@ -546,6 +543,16 @@ def gen_arg_unpacking(formals):
if isinstance(tsize, str):
tsize = array_domain_queries[tsize]

# if the tuple type is a dtype query, use the corresponding generic dtype argument
if ttype in array_dtype_queries:
ttype = array_dtype_queries[ttype]
elif ttype not in chapel_scalar_types:
error_message(
f"registering '{fname}'",
f"unsupported homog_tuple type expression for registration on formal '{fname}'; "
+ f"tuple element type must be a scalar (one of {chapel_scalar_types.keys()}) or a dtype from a query",
)

unpack_lines.append(unpack_tuple_arg(fname, tsize, ttype))
else:
if ftype in array_dtype_queries.keys():
Expand Down
Loading