Skip to content

Commit

Permalink
fix memory leak
Browse files Browse the repository at this point in the history
  • Loading branch information
xczhai committed Oct 24, 2023
1 parent f5f9072 commit 94d9fb9
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/frontends/paddle/tests/read_paddle_model_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,19 @@ TEST(Paddle_Reader_Tests, LoadModelMemoryToCore) {
size = ftell(sFile);
uint8_t* ss = (uint8_t*)malloc(size);
rewind(sFile);
fread(&ss[0], 1, size, sFile);
const size_t length = fread(&ss[0], 1, size, sFile);
if (size != length) {
std::cerr << "file size is not correct\n";
}
fclose(sFile);
return ss;
};

size_t xml_size, bin_size;
auto xml_str = read_file(model, xml_size);
auto bin_str = read_file(param, bin_size);
ov::Tensor weight_tensor = ov::Tensor(ov::element::u8, {1, bin_size}, bin_str);
std::string model_str = std::string((char*)xml_str, xml_size);
auto xml_ptr = read_file(model, xml_size);
auto bin_ptr = read_file(param, bin_size);
ov::Tensor weight_tensor = ov::Tensor(ov::element::u8, {1, bin_size}, bin_ptr);
std::string model_str = std::string((char*)xml_ptr, xml_size);
auto function = core.read_model(model_str, weight_tensor);

const auto inputType = ov::element::f32;
Expand All @@ -65,6 +68,8 @@ TEST(Paddle_Reader_Tests, LoadModelMemoryToCore) {
const FunctionsComparator func_comparator = FunctionsComparator::with_default().enable(FunctionsComparator::NONE);
const FunctionsComparator::Result res = func_comparator(function, reference);
ASSERT_TRUE(res.valid) << res.message;
free(xml_ptr);
free(bin_ptr);
}

TEST(Paddle_Reader_Tests, ImportBasicModelToCore) {
Expand Down

0 comments on commit 94d9fb9

Please sign in to comment.