-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- steel_attenion.metal (new) was missing from the build
- Loading branch information
1 parent
7f02cd8
commit 70dbb62
Showing
3 changed files
with
60 additions
and
2 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
Source/Cmlx/mlx-generated/metal/steel/attn/kernels/steel_attention.metal
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Copyright © 2024 Apple Inc. | ||
|
||
// clang-format off | ||
#include "../../../utils.h" | ||
|
||
#include "../../../steel/attn/attn.h" | ||
#include "../../../steel/attn/kernels/steel_attention.h" | ||
|
||
#define instantiate_attn(tname, dtype, bq, bk, bd, wm, wn) \ | ||
template [[host_name("steel_attention_" #tname "_bq" #bq "_bk" #bk "_bd" #bd "_wm" #wm "_wn" #wn)]] \ | ||
[[kernel]] void attention<dtype, bq, bk, bd, wm, wn, float>( \ | ||
const device dtype* Q [[buffer(0)]], \ | ||
const device dtype* K [[buffer(1)]], \ | ||
const device dtype* V [[buffer(2)]], \ | ||
device dtype* O [[buffer(3)]],\ | ||
const constant AttnParams* params [[buffer(4)]], \ | ||
uint simd_lane_id [[thread_index_in_simdgroup]], \ | ||
uint simd_group_id [[simdgroup_index_in_threadgroup]], \ | ||
uint3 tid [[threadgroup_position_in_grid]], \ | ||
uint3 lid [[thread_position_in_threadgroup]]); | ||
|
||
#define instantiate_attn_shapes_helper(iname, itype) \ | ||
instantiate_attn(iname, itype, 32, 16, 128, 4, 1) \ | ||
instantiate_attn(iname, itype, 32, 32, 80, 4, 1) \ | ||
instantiate_attn(iname, itype, 32, 32, 64, 4, 1) | ||
|
||
instantiate_attn_shapes_helper(float16, half); | ||
instantiate_attn_shapes_helper(bfloat16, bfloat16_t); | ||
|
||
instantiate_attn_shapes_helper(float32, float); | ||
// clang-format on |
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
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