Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: memory leak cause unclear static flat and mask vector #12

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/bert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ void bert_batch_tokens::init_input_ids(std::vector<std::vector<int>> &input_ids,
{
static std::vector<bert_vocab_id> flat{};
static std::vector<int32_t> mask{};
flat.clear();
mask.clear();
for (const auto &ids : input_ids)
{
flat.insert(flat.end(), ids.begin(), ids.end());
Expand Down
2 changes: 1 addition & 1 deletion test/test_batch_inference.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
int main(int argc, char **argv)
{
const std::string path = "/media/E/lichunyu/bert.cpp/data/test_tokenizer/tokenizer.json";
const std::string fname = "/media/E/lichunyu/bert.cpp/data/ggml-model/ggml_model.gguf";
const std::string fname = "/media/E/lichunyu/bert.cpp/data/ggml-model/ggml_model.ggml";
const std::string text1 = "卫生间抽纸";
const std::string text2 = "卫生间抽纸";
const std::string text3 = "卫生间抽纸";
Expand Down
2 changes: 1 addition & 1 deletion test/test_inference.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
int main(int argc, char **argv)
{
const std::string path = "/media/E/lichunyu/bert.cpp/data/test_tokenizer/tokenizer.json";
const std::string fname = "/media/E/lichunyu/bert.cpp/data/ggml-model/ggml_model.gguf";
const std::string fname = "/media/E/lichunyu/bert.cpp/data/ggml-model/ggml_model.ggml";
auto start_cpp_total = std::chrono::high_resolution_clock::now();
bert_ctx *ctx = new bert_ctx();
bert_model_load_from_ggml(fname, ctx->model);
Expand Down
2 changes: 1 addition & 1 deletion test/test_model_load.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
int main(int argc, char **argv)
{
bert_model model;
std::string fname = "/media/E/lichunyu/bert.cpp/data/ggml-model/ggml_model.gguf";
std::string fname = "/media/E/lichunyu/bert.cpp/data/ggml-model/ggml_model.ggml";
if (!bert_model_load_from_ggml(fname, model))
{
fprintf(stderr, "%s: failed to load model from %s", __func__, fname.c_str());
Expand Down
2 changes: 1 addition & 1 deletion test/test_py_entrance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

int main(int argc, char **argv)
{
const char *fname = "/media/E/lichunyu/bert.cpp/data/ggml-model/ggml_model.gguf";
const char *fname = "/media/E/lichunyu/bert.cpp/data/ggml-model/ggml_model.ggml";
const char *tokenizer_json_fname = "/media/E/lichunyu/bert.cpp/data/test_tokenizer/tokenizer.json";
int32_t buf_compute = 320;
bert_ctx *ctx = py_bert_ctx_load_from_file(fname, tokenizer_json_fname, buf_compute);
Expand Down