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

avoid mixed usage of Array<T, N> and T[N] when passing to template function #1475

Merged
merged 6 commits into from
Feb 22, 2024

Conversation

liqiangxl
Copy link
Collaborator

@liqiangxl liqiangxl commented Dec 7, 2023

Issue: #1470
In the generated code of the case posted in the issue page:
nvfuser_index_t T5[4] is aliased as Array<float, 4> T9. float T4[4] is aliased as auto& T10 = T4.
Then T9 and T10 are used to call welfordGroupOuter and causes a compilation error due to type mismatch: T9 is a custom array type, while T10 is a native float array.

Fix: always pass the regular array of registers to template function.

@liqiangxl
Copy link
Collaborator Author

!build --diff --diff-bench

@liqiangxl liqiangxl force-pushed the llu/aliasing_different_types branch from 2d1225f to 3adc823 Compare December 8, 2023 14:30
@liqiangxl liqiangxl changed the title when aliasing different types, cast to T* instead of Array<T, N> when aliasing different types, use Array<T, N> or T[N] depends on how the original tv was allocated Dec 8, 2023
@liqiangxl
Copy link
Collaborator Author

!build --diff --diff-bench

@liqiangxl liqiangxl marked this pull request as ready for review December 8, 2023 17:49
@liqiangxl liqiangxl requested a review from zasdfgbnm December 8, 2023 17:49
@liqiangxl liqiangxl removed the request for review from zasdfgbnm February 16, 2024 22:12
@liqiangxl liqiangxl marked this pull request as draft February 16, 2024 22:12
@liqiangxl liqiangxl force-pushed the llu/aliasing_different_types branch from d4183d6 to 6fc67f9 Compare February 17, 2024 00:00
@liqiangxl liqiangxl force-pushed the llu/aliasing_different_types branch from 2a8fabd to 7905dde Compare February 17, 2024 01:49
@liqiangxl liqiangxl changed the title when aliasing different types, use Array<T, N> or T[N] depends on how the original tv was allocated avoid mixed usage of Array<T, N> and T[N] when passing to template function Feb 21, 2024
@liqiangxl
Copy link
Collaborator Author

!build --diff --diff-bench

@liqiangxl
Copy link
Collaborator Author

codediff in matmul cases are caused by Cleanup matmul test utilities (#1804)

@liqiangxl liqiangxl marked this pull request as ready for review February 22, 2024 01:18
@liqiangxl liqiangxl requested a review from zasdfgbnm February 22, 2024 01:18
csrc/codegen.cpp Outdated
// array. This avoid the type mismatch in template functions when one of the
// arguments is an aligned array (Array<T,N>) while the other is a regular
// array T[N].
std::string genVarForTemplateFunction(Val* v) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should this be named something like maybeConvertAlignedArrayToRawArray?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I rename to genVariableNameConvertAlignedArray to reflect its two functions: (1) call genVariableName and (2) ConvertAlignedArrayToRawArray

@liqiangxl liqiangxl merged commit e2d3be1 into main Feb 22, 2024
4 checks passed
@liqiangxl liqiangxl deleted the llu/aliasing_different_types branch February 22, 2024 17:09
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.

2 participants