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

Enhancement: Symbolic Loop Merge Dims #358

Merged
merged 3 commits into from
Dec 20, 2024
Merged

Enhancement: Symbolic Loop Merge Dims #358

merged 3 commits into from
Dec 20, 2024

Conversation

hikettei
Copy link
Owner

@hikettei hikettei commented Dec 20, 2024

  • Write tests
  • Transformer Speed Improvement

@hikettei hikettei marked this pull request as ready for review December 20, 2024 06:52
@hikettei
Copy link
Owner Author

In this schedule, _gid1 and _gid2 is mergeable?

void fused_sumnode_softmax_maxreduce_attention_softmax2321523(float* val_593, float* val_610, const int64_t n, const int64_t s, const float* restrict val_599) {
  for (int _gid1=0; _gid1<12; _gid1+=1) {
    for (int _gid2=0; _gid2<s; _gid2+=1) {
      float val_363 = 0.0;
      float val_365 = _negative_infinity;
      for (int _gid3=0; _gid3<(n+s); _gid3+=1) {
        val_593[(((((n+s)*s)*_gid1)+((n+s)*_gid2))+_gid3)] = ((val_593[(((((n+s)*s)*_gid1)+((n+s)*_gid2))+_gid3)]*0.125)+val_599[(((n+s)*_gid2)+_gid3)]);
        val_365 = max(val_365, val_593[(((((n+s)*s)*_gid1)+((n+s)*_gid2))+_gid3)]);
      }
      for (int _gid3=0; _gid3<(n+s); _gid3+=1) {
        val_593[(((((n+s)*s)*_gid1)+((n+s)*_gid2))+_gid3)] = exp2(((val_593[(((((n+s)*s)*_gid1)+((n+s)*_gid2))+_gid3)]+-(val_365))*1.442695));
        val_363 = (val_363+val_593[(((((n+s)*s)*_gid1)+((n+s)*_gid2))+_gid3)]);
      }
      for (int _gid3=0; _gid3<(n+s); _gid3+=1) {
        val_610[(((((n+s)*s)*_gid1)+((n+s)*_gid2))+_gid3)] = (val_593[(((((n+s)*s)*_gid1)+((n+s)*_gid2))+_gid3)]*1.0/(val_363));
      }
    }
  }
}

@hikettei hikettei merged commit 1ace718 into main Dec 20, 2024
8 checks passed
@hikettei hikettei deleted the symbolic-merge-loops branch December 20, 2024 07:07
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.

1 participant