Skip to content

[mlir][spirv] Ignore extra comma for category_args in gen_spirv_dialect.py #111776

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

Merged
merged 1 commit into from
Oct 30, 2024
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
1 change: 1 addition & 0 deletions mlir/utils/spirv/gen_spirv_dialect.py
Original file line number Diff line number Diff line change
Expand Up @@ -988,6 +988,7 @@ def extract_td_op_info(op_def):
op_tmpl_params, _ = get_string_between_nested(op_def, "<", ">")
opstringname, rest = get_string_between(op_tmpl_params, '"', '"')
category_args = rest.split("[", 1)[0]
category_args = category_args.rsplit(",", 1)[0]
Copy link
Member

@kuhar kuhar Oct 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you paste an example of how rest looks like and what you want category_args to be?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For example, when the function is looking at the following op_def (showing just the start):

def SPIRV_VectorTimesScalarOp : SPIRV_Op<"VectorTimesScalar", [Pure]> {
  • rest is , [Pure]
  • we want category_args to be empty

And in this other op_def (again just the start):

def SPIRV_UDivOp : SPIRV_ArithmeticBinaryOp<"UDiv",
                                        SPIRV_Integer, [UnsignedOp, UsableInSpecConstantOp]> {
  • rest is , SPIRV_Integer, [UsableInSpecConstantOp] (whitespace compressed for clarity)
  • we want category_args to be , SPIRV_Integer.

There are different ways to handle this, e.g. store category args as an array and re-join at its users, but would've been larger changes without clear extra benefit.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kuhar ping


# Get traits
traits, _ = get_string_between_nested(rest, "[", "]")
Expand Down
Loading