Procházet zdrojové kódy

[unity.cpp]FORCE_ALLOC remove_last (#248)

* FORCE_ALLOC remove_last

* ggml_slice to replace remove_last (#250)
Ning před 1 rokem
rodič
revize
c5ad5e22b6

+ 1 - 5
ggml/examples/unity/fairseq2.cpp

@@ -590,11 +590,7 @@ extern "C" ggml_tensor* WaveformToFbank_forward(
     output = ggml_norm(ctx, output, 1e-5);
     output = ggml_dup(ctx, ggml_transpose(ctx, output));
     if (output->ne[1] % 2 == 1) {
-        ggml_tensor* remove_last = ggml_new_tensor_1d(ctx, GGML_TYPE_I32, output->ne[1]-1);
-        for (int i = 0; i < output->ne[1]-1; ++i) {
-            ((int32_t *) remove_last->data)[i] = i;
-        }
-        output = ggml_get_rows(ctx, output, remove_last);
+        output = ggml_dup(ctx, ggml_slice(ctx, output, 1, 0, output->ne[1]-1));
     }
     output = ggml_reshape_2d(ctx, output, output->ne[0] * 2, output->ne[1] / 2);
     return output;

+ 1 - 1
ggml/examples/unity/unity.cpp

@@ -137,7 +137,7 @@ int main(int argc, char ** argv) {
 
     // The ctx_size_mb mostly depends of input length and model dim.
     int ctx_size_mb = 128;
-    auto encoder_buf = std::vector<uint8_t>(128 * 1024 * 1024);
+    auto encoder_buf = std::vector<uint8_t>(ctx_size_mb * 1024 * 1024);
     auto encoder_fwd_buf = std::vector<uint8_t>(ctx_size_mb * 1024 * 1024);
     ggml_allocr* fwd_alloc = ggml_allocr_new(encoder_fwd_buf.data(), encoder_fwd_buf.capacity(), 8);
     char result_str[4096];