Skip to content

Commit

Permalink
Implemented destructor to free up resources
Browse files Browse the repository at this point in the history
Signed-off-by: Shrinath Suresh <shrinath@ideas2it.com>
  • Loading branch information
shrinath-suresh committed Sep 5, 2023
1 parent 5c0495e commit e75a5ae
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
6 changes: 6 additions & 0 deletions cpp/src/examples/babyllama/baby_llama_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,12 @@ void LlmHandler::Postprocess(
}
}

LlmHandler::~LlmHandler() noexcept {
free_sampler(&sampler);
free_tokenizer(&tokenizer);
free_transformer(&transformer);
}

} // namespace llm

#if defined(__linux__) || defined(__APPLE__)
Expand Down
3 changes: 1 addition & 2 deletions cpp/src/examples/babyllama/baby_llama_handler.hh
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@
namespace llm {
class LlmHandler : public torchserve::torchscripted::BaseHandler {
public:

// NOLINTBEGIN(bugprone-exception-escape)
LlmHandler() = default;
// NOLINTEND(bugprone-exception-escape)
~LlmHandler() override = default;
~LlmHandler() noexcept;

void initialize_context();

Expand Down

0 comments on commit e75a5ae

Please sign in to comment.