-
Notifications
You must be signed in to change notification settings - Fork 10
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
Various enhancements and refactorings on caten/ajit #110
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Owner
hikettei
commented
Sep 20, 2024
•
edited
Loading
edited
- Fix: Optimize gemm (no extra copy by !contiguous)
- Fix: pass all tests
- Scheduler: Fuse nested loops
- Merge inner (:LOCAL) Loop to get an optimal solution of Embedding
- 同一のタスクにScheduleする条件をゆるくした方がいいかもしれない (MultiExpr or buffer-intersect-p)
- Fix: 4D Tensor ScaledDotProductAttention
- Add: ConvND Testing
- say goodbye to double corruption
- Scheduler: ISLのASTでなるべくFuseしておく
- IR: merge viewを考える
- segv/randn w/ 2~3d inputs are failing
- INDEX-COMPONENT is always scalar
- stあるからone-shotでカーネル求めれないかのぅ
- よくわかんなくなってきた
- すぐ治したい: transpose matmulのtransposeがzero_costじゃない (Broadcastも...)
- Improve the debugger visualization
Embedding in a single kernel!!! (If I propagate :INDEX_COMPONENTS, it should be an optimal solution)
|
we have to revise the semantic of !reshape ...
|
JIT in Caten(文章化してちゃんと考える ...)
Polyhedral IR in Caten of Embedding, (gained by SERIALIZE=1).
|
TODO: Remaining Task
|
Softmax (old vs new) /*
Arrays:
- B[uint32]: NIL // INPUT, SHAPE
- A[uint32]: NIL // INPUT, SHAPE
- val_34[float32]: (A B) // IO, TMP
*/
void main862852_e30_k0(uint32_t b, uint32_t a, float* val_34);
void main862852_e30_k0(uint32_t b, uint32_t a, float* val_34) {
for(int _gid0=0;(_gid0<a);_gid0+=1) {
float val_25 = 0.0;
for(int _gid1=0;((_gid1+4)<=b);_gid1+=4) {
val_25 = max(val_25, val_34[b*_gid0+(_gid1+0)]);
val_25 = max(val_25, val_34[b*_gid0+(_gid1+1)]);
val_25 = max(val_25, val_34[b*_gid0+(_gid1+2)]);
val_25 = max(val_25, val_34[b*_gid0+(_gid1+3)]);
}
for(int _gid1=(b-(b%4));(_gid1<b);_gid1+=1) {
val_25 = max(val_25, val_34[b*_gid0+_gid1]);
}
float val_26 = -(val_25);
val_25 = 0.0;
for(int _gid1=0;((_gid1+4)<=b);_gid1+=4) {
val_34[b*_gid0+(_gid1+0)] = exp2(((val_34[b*_gid0+(_gid1+0)]+val_26)*1.442695));
val_34[b*_gid0+(_gid1+1)] = exp2(((val_34[b*_gid0+(_gid1+1)]+val_26)*1.442695));
val_34[b*_gid0+(_gid1+2)] = exp2(((val_34[b*_gid0+(_gid1+2)]+val_26)*1.442695));
val_34[b*_gid0+(_gid1+3)] = exp2(((val_34[b*_gid0+(_gid1+3)]+val_26)*1.442695));
val_25 = (val_25+val_34[b*_gid0+(_gid1+0)]);
val_25 = (val_25+val_34[b*_gid0+(_gid1+1)]);
val_25 = (val_25+val_34[b*_gid0+(_gid1+2)]);
val_25 = (val_25+val_34[b*_gid0+(_gid1+3)]);
}
for(int _gid1=(b-(b%4));(_gid1<b);_gid1+=1) {
val_34[b*_gid0+_gid1] = exp2(((val_34[b*_gid0+_gid1]+val_26)*1.442695));
val_25 = (val_25+val_34[b*_gid0+_gid1]);
}
float val_11 = 1/(val_25);
for(int _gid1=0;((_gid1+4)<=b);_gid1+=4) {
val_34[b*_gid0+(_gid1+0)] = (val_34[b*_gid0+(_gid1+0)]*val_11);
val_34[b*_gid0+(_gid1+1)] = (val_34[b*_gid0+(_gid1+1)]*val_11);
val_34[b*_gid0+(_gid1+2)] = (val_34[b*_gid0+(_gid1+2)]*val_11);
val_34[b*_gid0+(_gid1+3)] = (val_34[b*_gid0+(_gid1+3)]*val_11);
}
for(int _gid1=(b-(b%4));(_gid1<b);_gid1+=1) {
val_34[b*_gid0+_gid1] = (val_34[b*_gid0+_gid1]*val_11);
}
}
} /*
Arrays:
- B[uint32]: NIL // INPUT, SHAPE
- A[uint32]: NIL // INPUT, SHAPE
- val_34[float32]: (A B) // IO, TMP
*/
void main736348_e30_k0(uint32_t b, uint32_t a, float* val_34);
void main736348_e30_k0(uint32_t b, uint32_t a, float* val_34) {
for(int _gid0=0;(_gid0<a);_gid0+=1) {
float val_11 = 0.0;
float val_26 = 0.0;
for(int _gid1=0;((_gid1+4)<=b);_gid1+=4) {
val_26 = max(val_26, val_34[((b*_gid0)+(_gid1+0))]);
val_26 = max(val_26, val_34[((b*_gid0)+(_gid1+1))]);
val_26 = max(val_26, val_34[((b*_gid0)+(_gid1+2))]);
val_26 = max(val_26, val_34[((b*_gid0)+(_gid1+3))]);
}
for(int _gid1=(b-(b%4));(_gid1<b);_gid1+=1) {
val_26 = max(val_26, val_34[((b*_gid0)+_gid1)]);
}
val_26 = -(val_26);
for(int _gid1=0;((_gid1+4)<=b);_gid1+=4) {
val_34[((b*_gid0)+(_gid1+0))] = exp2(((val_34[((b*_gid0)+(_gid1+0))]+val_26)*1.442695));
val_34[((b*_gid0)+(_gid1+1))] = exp2(((val_34[((b*_gid0)+(_gid1+1))]+val_26)*1.442695));
val_34[((b*_gid0)+(_gid1+2))] = exp2(((val_34[((b*_gid0)+(_gid1+2))]+val_26)*1.442695));
val_34[((b*_gid0)+(_gid1+3))] = exp2(((val_34[((b*_gid0)+(_gid1+3))]+val_26)*1.442695));
}
for(int _gid1=(b-(b%4));(_gid1<b);_gid1+=1) {
val_34[((b*_gid0)+_gid1)] = exp2(((val_34[((b*_gid0)+_gid1)]+val_26)*1.442695));
}
for(int _gid1=0;((_gid1+4)<=b);_gid1+=4) {
val_11 = (val_11+val_34[((b*_gid0)+(_gid1+0))]);
val_11 = (val_11+val_34[((b*_gid0)+(_gid1+1))]);
val_11 = (val_11+val_34[((b*_gid0)+(_gid1+2))]);
val_11 = (val_11+val_34[((b*_gid0)+(_gid1+3))]);
}
for(int _gid1=(b-(b%4));(_gid1<b);_gid1+=1) {
val_11 = (val_11+val_34[((b*_gid0)+_gid1)]);
}
val_11 = 1/(val_11);
for(int _gid1=0;((_gid1+4)<=b);_gid1+=4) {
val_34[((b*_gid0)+(_gid1+0))] = (val_34[((b*_gid0)+(_gid1+0))]*val_11);
val_34[((b*_gid0)+(_gid1+1))] = (val_34[((b*_gid0)+(_gid1+1))]*val_11);
val_34[((b*_gid0)+(_gid1+2))] = (val_34[((b*_gid0)+(_gid1+2))]*val_11);
val_34[((b*_gid0)+(_gid1+3))] = (val_34[((b*_gid0)+(_gid1+3))]*val_11);
}
for(int _gid1=(b-(b%4));(_gid1<b);_gid1+=1) {
val_34[((b*_gid0)+_gid1)] = (val_34[((b*_gid0)+_gid1)]*val_11);
}
}
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.