Skip to content

Commit

Permalink
fix(//core/conversion/conversionctx): Fix memory leak in conversion
Browse files Browse the repository at this point in the history
context engine serialization

h/t: @SakodaShintaro

Signed-off-by: Naren Dasan <[email protected]>
Signed-off-by: Naren Dasan <[email protected]>
  • Loading branch information
narendasan committed Feb 25, 2021
1 parent 04188a8 commit 6f83b41
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion core/conversion/conversionctx/ConversionCtx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,9 @@ std::string ConversionCtx::SerializeEngine() {
auto engine = builder->buildEngineWithConfig(*net, *cfg);
auto serialized_engine = engine->serialize();
engine->destroy();
return std::string((const char*)serialized_engine->data(), serialized_engine->size());
auto engine_str = std::string((const char*)serialized_engine->data(), serialized_engine->size());
serialized_engine->destroy();
return engine_str;
}

bool ConversionCtx::CheckLayerAddition(const torch::jit::Node* n) {
Expand Down

0 comments on commit 6f83b41

Please sign in to comment.