Skip to content

Comments

[Bugfix][IR][AIE] using cpp-style implicit type casting rule for aie backend#485

Merged
chhzh123 merged 17 commits intocornell-zhang:mainfrom
Fangtangtang:aie-type-casting
Dec 14, 2025
Merged

[Bugfix][IR][AIE] using cpp-style implicit type casting rule for aie backend#485
chhzh123 merged 17 commits intocornell-zhang:mainfrom
Fangtangtang:aie-type-casting

Conversation

@Fangtangtang
Copy link
Collaborator

@Fangtangtang Fangtangtang commented Dec 12, 2025

Description

  1. updates and bugfix to be compatible with the new LLVM version updated in [Version] Bump LLVM to main (v21.1.7+) #483.
  2. This PR fixes [BUG][IR][AIE] Inappropriate type casting for aie backend #484.

Problems

  1. described in [BUG][IR][AIE] Inappropriate type casting for aie backend #484

Proposed Solutions

  1. using cpp-style implicit type casting for aie backend.

Checklist

Please make sure to review and check all of these items:

  • PR's title starts with a category (e.g. [Bugfix], [IR], [Builder], etc)
  • All changes have test coverage (It would be good to provide ~2 different test cases to test the robustness of your code)
  • Pass the formatting check locally
  • Code is well-documented

@Fangtangtang Fangtangtang marked this pull request as draft December 13, 2025 06:55
@Fangtangtang
Copy link
Collaborator Author

Fangtangtang commented Dec 13, 2025

Compatibility issue 1:
operations like

linalg.fill ins(%c1_i32 : i32) outs(%alloc : memref<i16>)

become invalid after llvm version update.

During construction, it now raises the following error:

ValueError: Cannot overwrite type mapping T = i32 by type i16.

According to linalg.fill dialect doc

The value operand type must match the element type of the output.

…e to match the element type of the output.
@Fangtangtang
Copy link
Collaborator Author

Compatibility issue 2:

mlir object equality check seems different. e.g., stream_put.parent is stream_get.parent is not the same as stream_put.parent == stream_get.parent

@Fangtangtang Fangtangtang marked this pull request as ready for review December 13, 2025 18:03
@chhzh123
Copy link
Member

chhzh123 commented Dec 14, 2025

Compatibility issue 2:

mlir object equality check seems different. e.g., stream_put.parent is stream_get.parent is not the same as stream_put.parent == stream_get.parent

In this case we should use ==?

@Fangtangtang
Copy link
Collaborator Author

Compatibility issue 2:
mlir object equality check seems different. e.g., stream_put.parent is stream_get.parent is not the same as stream_put.parent == stream_get.parent

In this case we should use ==?

right

Copy link
Member

@chhzh123 chhzh123 left a comment

Choose a reason for hiding this comment

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

LGTM. Let me know when it is ready to merge.

Comment on lines 1251 to 1256
global_vars: dict = None,
instantiate: list = None,
context: Context = None,
typing_rule_set="default",
unroll: bool = True,
) -> Schedule:
Copy link
Member

Choose a reason for hiding this comment

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

Could you also help add a docstring to document what the arguments mean in this customize function?

@Fangtangtang
Copy link
Collaborator Author

ready to merge

@chhzh123 chhzh123 merged commit 4cabfad into cornell-zhang:main Dec 14, 2025
2 checks passed
@Fangtangtang Fangtangtang deleted the aie-type-casting branch December 14, 2025 18:52
@chhzh123
Copy link
Member

Is this PR a replacement of #462? Can I close that one?

@Fangtangtang
Copy link
Collaborator Author

partially. It only addresses type casting issues for aie backend. Some redundant type casting in the hls backend is not handled here.
actually I’m not sure whether keeping these casts in allo IR has any performance impact for hls backend. if the backend applies sufficient optimization passes, leaving them in our IR may be fine.

I think #462 can be closed. If we do want to clean up some redundant type casting in our IR, #462 is not an elegant solution, we should consider alternative approaches.

@zhangzhiru
Copy link

Let's keep #462 open then

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG][IR][AIE] Inappropriate type casting for aie backend

3 participants