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

[dataflow] Unified Systolic Array #232

Merged
merged 6 commits into from
Oct 27, 2024
Merged

Conversation

AdrianLiu00
Copy link
Contributor

Description

The implementation of unified systolic array to achieve GEMM with output-stationary or weight-stationary dataflow.

Examples

Numpy tests are included.

Checklist

  • PR's title starts with a category (e.g. [Bugfix], [IR], [Builder], etc)
  • Changes are complete (i.e. I finished coding on this PR)
  • All changes have test coverage (It would be better to provide ~2 different test cases to test the robustness of your code)
  • Code is well-documented

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.

Thanks for contributing! Just some minor issues.

for ri in range(Rtimes, name="row_loop"):
for ci in range(Ctimes, name="column_loop"):
# corner
with allo.meta_if(i in [0, Rt + 1] and j in [0, Ct + 1]):
Copy link
Member

Choose a reason for hiding this comment

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

This statement is a bit confusing. For example, for i in [0, Rt + 1], are you saying i is either 0 or Rt+1? In this case, it would be better to write it as a set (to be consistent with the math notation), i.e., i in {0, Rt+1}.

r: int32 = in_R.get()
c: int32 = in_C.get()
# Core MAC
acti: int32 = r
Copy link
Member

Choose a reason for hiding this comment

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

Write the full name (activation) or use a proper shorthand (act).

acti: int32 = r
weight: int32 = c if flowtag else s
psum: int32 = s if flowtag else c
accu: int32 = acti * weight + psum
Copy link
Member

Choose a reason for hiding this comment

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

Similarly, use acc or accumulation

if hls.is_available("vitis_hls"):
gemm(A_flat, B_flat, insts, C_flat)
print(C_flat)
C_tru = np.dot(A, B).flatten()
Copy link
Member

Choose a reason for hiding this comment

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

C_true?

@AdrianLiu00
Copy link
Contributor Author

I have fixed the naming issues. Let me know if there are any problems.



@df.kernel(mapping=[P0, P1])
def gemm(A: int32[M, K], B: int32[K, N], inst: int8[2], C: int32[M, N]):
Copy link
Member

Choose a reason for hiding this comment

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

Can you pull the latest commit (need to rebuild) and see whether a single bool inst now works for both LLVM and HLS backend? If so, you can use inst: bool.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure. I'll try this later.

@AdrianLiu00
Copy link
Contributor Author

The test of scalar interface looks good for csim. I've changed the interface to a single bool argument.

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! Thx

@chhzh123 chhzh123 merged commit 1c47204 into cornell-zhang:main Oct 27, 2024
1 check passed
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