-
Notifications
You must be signed in to change notification settings - Fork 15
Add relu.cpp example in test/neura/for_loop #127
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| // RUN: mlir-neura-opt %s | FileCheck %s | ||
|
|
||
| #include <stdio.h> | ||
|
|
||
| #define N 32 | ||
|
|
||
| float input[N] = { | ||
tancheng marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| -1.0, 0.0, 1.0, 2.0, -3.0, 4.0, -5.0, 6.0, | ||
| -7.0, 8.0, -9.0, 10.0, -11.0, 12.0, -13.0, 14.0, | ||
| -15.0, 16.0, -17.0, 18.0, -19.0, 20.0, -21.0, 22.0, | ||
| -23.0, 24.0, -25.0, 26.0, -27.0, 28.0, -29.0, 30.0 | ||
| }; | ||
|
|
||
| float output[N]; | ||
|
|
||
| void kernel(float input[], float output[]); | ||
|
|
||
| int main(){ | ||
| //init output | ||
| for(int i=0; i<N; i++){ | ||
| output[i]=0.0; | ||
| } | ||
|
|
||
| kernel(intput, output); | ||
|
|
||
| //print outputs | ||
| for(int i=0; i<N; i++){ | ||
| print("output[%d] = %f\n", i, output[i]); | ||
| } | ||
|
|
||
| return 0; | ||
| } | ||
|
|
||
| void kernel(float input[], float output []){ | ||
| for(int i = 0; i<N; ++i){ | ||
| if(input[i]>0){ | ||
| output[i] += input[i]; | ||
| } else { | ||
| output[i] += 0; | ||
tancheng marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
| } | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Provide a mlir test for this c++, plz refer to https://github.com/coredac/dataflow/blob/main/test/neura/for_loop/test.mlir
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi, cheng. I’ve modified other parts of relu.cpp, but I’ll need a bit more time to provide the MLIR test.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure, take your time. The corresponding mlir test has no mlir IRs there, it is just a bunch of commands to transform your provided C++ to our neura dialect.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you mean that we only need to provide the RUN part, but not the CHECK part?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
the
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, I see. I will try to make a mlir test for relu.cpp. |
||
Uh oh!
There was an error while loading. Please reload this page.