Skip to content

Commit 2bdc847

Browse files
committed
Use ggml_pad instead of concat with empty tensor
1 parent 5a96b09 commit 2bdc847

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

flux.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -884,7 +884,7 @@ namespace Flux {
884884
vec = approx->forward(ctx, vec); // [344, N, hidden_size]
885885

886886
if (y != NULL) {
887-
txt_img_mask = ggml_concat(ctx, y, ggml_scale_inplace(ctx, ggml_new_tensor_1d(ctx, GGML_TYPE_F32, img->ne[1]), 0), 0);
887+
txt_img_mask = ggml_pad(ctx, y, img->ne[1], 0, 0, 0);
888888
}
889889
} else {
890890
auto time_in = std::dynamic_pointer_cast<MLPEmbedder>(blocks["time_in"]);

t5.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,7 @@ class T5UniGramTokenizer {
434434
tokens.insert(tokens.end(), length - tokens.size(), pad_token_id);
435435
weights.insert(weights.end(), length - weights.size(), 1.0);
436436
if (attention_mask != nullptr) {
437+
// maybe keep some padding tokens unmasked?
437438
attention_mask->insert(attention_mask->end(), length - attention_mask->size(), -HUGE_VALF);
438439
}
439440
}
@@ -594,7 +595,7 @@ class T5Attention : public GGMLBlock {
594595
}
595596
if (past_bias != NULL) {
596597
if (mask != NULL) {
597-
mask = ggml_repeat(ctx,mask,past_bias);
598+
mask = ggml_repeat(ctx, mask, past_bias);
598599
mask = ggml_add(ctx, mask, past_bias);
599600
} else {
600601
mask = past_bias;

0 commit comments

Comments
 (0)