Skip to content

Commit

Permalink
[unity.cpp]FORCE_ALLOC remove_last (#248)
Browse files Browse the repository at this point in the history
* FORCE_ALLOC remove_last

* ggml_slice to replace remove_last (#250)
  • Loading branch information
cndn authored Dec 8, 2023
1 parent 42365df commit c5ad5e2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
6 changes: 1 addition & 5 deletions ggml/examples/unity/fairseq2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion ggml/examples/unity/unity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down

0 comments on commit c5ad5e2

Please sign in to comment.