Skip to content

Commit c5ad5e2

Browse files
authored
[unity.cpp]FORCE_ALLOC remove_last (#248)
* FORCE_ALLOC remove_last * ggml_slice to replace remove_last (#250)
1 parent 42365df commit c5ad5e2

File tree

2 files changed

+2
-6
lines changed

2 files changed

+2
-6
lines changed

ggml/examples/unity/fairseq2.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -590,11 +590,7 @@ extern "C" ggml_tensor* WaveformToFbank_forward(
590590
output = ggml_norm(ctx, output, 1e-5);
591591
output = ggml_dup(ctx, ggml_transpose(ctx, output));
592592
if (output->ne[1] % 2 == 1) {
593-
ggml_tensor* remove_last = ggml_new_tensor_1d(ctx, GGML_TYPE_I32, output->ne[1]-1);
594-
for (int i = 0; i < output->ne[1]-1; ++i) {
595-
((int32_t *) remove_last->data)[i] = i;
596-
}
597-
output = ggml_get_rows(ctx, output, remove_last);
593+
output = ggml_dup(ctx, ggml_slice(ctx, output, 1, 0, output->ne[1]-1));
598594
}
599595
output = ggml_reshape_2d(ctx, output, output->ne[0] * 2, output->ne[1] / 2);
600596
return output;

ggml/examples/unity/unity.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ int main(int argc, char ** argv) {
137137

138138
// The ctx_size_mb mostly depends of input length and model dim.
139139
int ctx_size_mb = 128;
140-
auto encoder_buf = std::vector<uint8_t>(128 * 1024 * 1024);
140+
auto encoder_buf = std::vector<uint8_t>(ctx_size_mb * 1024 * 1024);
141141
auto encoder_fwd_buf = std::vector<uint8_t>(ctx_size_mb * 1024 * 1024);
142142
ggml_allocr* fwd_alloc = ggml_allocr_new(encoder_fwd_buf.data(), encoder_fwd_buf.capacity(), 8);
143143
char result_str[4096];

0 commit comments

Comments
 (0)