Skip to content

Commit e99b9e5

Browse files
committed
Fix issues related to changes in whisper.cpp
1 parent d6f4d7a commit e99b9e5

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

whisper.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6685,7 +6685,7 @@ static void whisper_exp_compute_token_level_timestamps(
66856685
// based on
66866686
// https://github.com/openai/whisper/blob/main/whisper/timing.py#L83
66876687
static ggml_tensor * dtw_and_backtrace(ggml_context * ctx, ggml_tensor * x) {
6688-
WHISPER_ASSERT(x->n_dims == 2);
6688+
WHISPER_ASSERT(ggml_n_dims(x) == 2);
66896689

66906690
int64_t N = x->ne[0];
66916691
int64_t M = x->ne[1];
@@ -6773,7 +6773,7 @@ static ggml_tensor * dtw_and_backtrace(ggml_context * ctx, ggml_tensor * x) {
67736773
static ggml_tensor * median_filter(ggml_context * ctx, ggml_tensor * x, int filter_width) {
67746774
WHISPER_ASSERT(filter_width < x->ne[2]);
67756775
WHISPER_ASSERT(filter_width % 2);
6776-
WHISPER_ASSERT(x->n_dims == 3);
6776+
WHISPER_ASSERT(ggml_n_dims(x) == 3);
67776777
WHISPER_ASSERT(x->type == GGML_TYPE_F32);
67786778

67796779
std::vector<float> filter;
@@ -6918,7 +6918,7 @@ static void whisper_exp_compute_token_level_timestamps_dtw(
69186918
// operation (after median filter)
69196919
// IN: Tensor with N_TOKENS*N_AUDIO_TOKENS*N_ALIGNMENT_HEADS dims
69206920
// OUT: Tensor with N_ALIGNMENT_HEADS*N_TOKENS*N_AUDIO_TOKENS dims
6921-
w = ggml_norm(gctx, w, 0);
6921+
w = ggml_norm(gctx, w, 1e-9);
69226922
w = ggml_permute(gctx, ggml_permute(gctx, w, 2, 1, 0 ,3), 0, 2, 1, 3);
69236923
struct ggml_cgraph * gf = ggml_new_graph(gctx);
69246924
ggml_build_forward_expand(gf, w);
@@ -6933,9 +6933,7 @@ static void whisper_exp_compute_token_level_timestamps_dtw(
69336933
// IN: Tensor with N_ALIGNMENT_HEADS*N_TOKENS*N_AUDIO_TOKENS dims
69346934
// OUT: Tensor with N_TOKENS*N_AUDIO_TOKENS dims
69356935
w = ggml_mean(gctx, w);
6936-
ggml_tensor * scale = ggml_new_tensor_1d(gctx, GGML_TYPE_F32, 1);
6937-
ggml_set_f32_1d(scale, 0, -1);
6938-
w = ggml_scale(gctx, w, scale);
6936+
w = ggml_scale(gctx, w, -1.0);
69396937
w = ggml_reshape_2d(gctx, w, w->ne[1], w->ne[2]);
69406938
struct ggml_cgraph * gf2 = ggml_new_graph(gctx);
69416939
ggml_build_forward_expand(gf2, w);

0 commit comments

Comments
 (0)