Skip to content

Commit 6739eb8

Browse files
authored
whisper : handle empty mel (ggml-org#2324)
1 parent f68298c commit 6739eb8

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/whisper.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -1920,7 +1920,7 @@ static struct ggml_cgraph * whisper_build_graph_conv(
19201920
ggml_set_input(mel_inp);
19211921

19221922
ggml_tensor * mel;
1923-
{
1923+
if (ggml_nelements(mel_inp) > 0) {
19241924
const int n_len = int(mel_inp->ne[0]);
19251925
const int out_s = 2 * n_ctx;
19261926
const int i0 = std::min(mel_offset, n_len);
@@ -1937,6 +1937,9 @@ static struct ggml_cgraph * whisper_build_graph_conv(
19371937
} else {
19381938
mel = ggml_cont(ctx0, cur);
19391939
}
1940+
} else {
1941+
// empty mel - just create a dummy tensor with the correct size
1942+
mel = ggml_new_tensor_2d(ctx0, GGML_TYPE_F32, 2*n_ctx, n_mels);
19401943
}
19411944

19421945
ggml_set_name(mel, "mel");

0 commit comments

Comments
 (0)