Skip to content

Commit

Permalink
oom check
Browse files Browse the repository at this point in the history
  • Loading branch information
nihui committed Jun 19, 2024
1 parent 3532717 commit 2dd7e65
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/layer/multiheadattention.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,25 +91,25 @@ int MultiHeadAttention::forward(const std::vector<Mat>& bottom_blobs, std::vecto
Mat& top_blob = top_blobs[0];
top_blob.create(qdim, src_seqlen, 4u, opt.blob_allocator);
if (top_blob.empty())
return -1;
return -100;

Mat xq(embed_dim_per_head, src_seqlen, num_heads, 4u, opt.workspace_allocator);
if (xq.empty())
return -1;
return -100;
Mat xk(embed_dim_per_head, dst_seqlen, num_heads, 4u, opt.workspace_allocator);
if (xk.empty())
return -1;
return -100;
Mat xv(dst_seqlen, embed_dim_per_head, num_heads, 4u, opt.workspace_allocator);
if (xv.empty())
return -1;
return -100;

Mat xqk(dst_seqlen, src_seqlen, num_heads, 4u, opt.workspace_allocator);
if (xqk.empty())
return -1;
return -100;

Mat xqkv(embed_dim_per_head, num_heads, src_seqlen, 4u, opt.workspace_allocator);
if (xqkv.empty())
return -1;
return -100;

const float inv_sqrt_embed_dim_per_head = 1.f / sqrtf(embed_dim_per_head);

Expand Down

0 comments on commit 2dd7e65

Please sign in to comment.