From cb17d7661c467d8b490b7b73e46c6f83824999fa Mon Sep 17 00:00:00 2001 From: Pierre-Antoine Bannier Date: Sat, 26 Oct 2024 11:07:38 +0200 Subject: [PATCH] intiial --- encodec.cpp | 4 +++- quantizer.h | 3 +-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/encodec.cpp b/encodec.cpp index 2a1b779..5967cb2 100644 --- a/encodec.cpp +++ b/encodec.cpp @@ -705,7 +705,9 @@ void encodec_build_graph(struct encodec_context *ectx, const int32_t *codes, static void encodec_zero_tensor(struct ggml_cgraph *gf, const char *name) { struct ggml_tensor *tensor = ggml_graph_get_tensor(gf, name); - ggml_set_zero(tensor); + // create a zero array + // ggml_backend_tensor_set(tensor, zeros, 0, tensor->ne * ggml_element_size(tensor)); + // ggml_set_zero(tensor); } bool encodec_eval_internal(struct encodec_context *ectx, const float * raw_audio, diff --git a/quantizer.h b/quantizer.h index 9986561..f7eb02e 100644 --- a/quantizer.h +++ b/quantizer.h @@ -58,9 +58,8 @@ struct ggml_tensor *encodec_forward_quantizer_encode( // [seq_length, n_bins] struct ggml_tensor *dist = ggml_add(ctx0, ggml_repeat(ctx0, sqr_inp_nrm, dp), dp); dist = ggml_add(ctx0, ggml_repeat(ctx0, ggml_transpose(ctx0, sqr_embed_nrm), dist), dist); - dist = ggml_neg(ctx0, dist); + dist = ggml_scale(ctx0, dist, -1.0f); - // take the argmax over the column dimension // [seq_length] indices = ggml_argmax(ctx0, dist);