[Bug] Fix the bug when setting npumgr param
authorDongju Chae <dongju.chae@samsung.com>
Mon, 21 Jun 2021 03:38:10 +0000 (12:38 +0900)
committer채동주/On-Device Lab(SR)/Staff Engineer/삼성전자 <dongju.chae@samsung.com>
Mon, 21 Jun 2021 04:46:37 +0000 (13:46 +0900)
This patch fixes the bug when setting npumgr param.

Signed-off-by: Dongju Chae <dongju.chae@samsung.com>
src/core/ne-scheduler.cc
src/core/ne-scheduler.h

index eb666e4..6a37520 100644 (file)
@@ -35,6 +35,12 @@ Request::Request (npu_input_opmode opmode)
   request_id_ = Request::global_request_id_.fetch_add (1);
 }
 
+/** @brief destructor of request class */
+Request::~Request () {
+  if (npumgr_param_ != nullptr)
+    delete npumgr_param_;
+}
+
 /** @brief destructor of scheduler class */
 Scheduler::~Scheduler () {
   /** wait until all callbacks are called */
index 896fb53..5911660 100644 (file)
@@ -32,6 +32,7 @@
 class Request {
  public:
   Request (npu_input_opmode opmode);
+  ~Request ();
 
   void setModel (const Model *model) { model_ = model; }
   const Model *getModel () { return model_; }
@@ -61,6 +62,8 @@ class Request {
   npu_infer_mode getInferMode () { return infer_mode_; }
 
   void setNpumgrParam (const npumgr_param &param) {
+    if (npumgr_param_ == nullptr)
+      npumgr_param_ = new npumgr_param;
     memcpy (npumgr_param_, &param, sizeof (npumgr_param));
   }
   const npumgr_param *getNpumgrParam () { return npumgr_param_; }