You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2017/11/07 21:43:17 UTC

[GitHub] rahul003 closed pull request #8580: fix some memory leaks, and initializes a variable

rahul003 closed pull request #8580: fix some memory leaks, and initializes a variable
URL: https://github.com/apache/incubator-mxnet/pull/8580
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/cpp-package/example/charRNN.cpp b/cpp-package/example/charRNN.cpp
index 218d11efc9..c0239f9694 100644
--- a/cpp-package/example/charRNN.cpp
+++ b/cpp-package/example/charRNN.cpp
@@ -501,6 +501,7 @@ void train(const string file, int batch_size, int max_epoch, int start_epoch) {
     string filepath = prefix + "-" + to_string(epoch) + ".params";
     SaveCheckpoint(filepath, RNN, exe);
   }
+  delete exe;
 }
 
 /*The original example, rnn_cell_demo.py, uses default Xavier as initalizer, which relies on
@@ -580,6 +581,7 @@ void trainWithBuiltInRNNOp(const string file, int batch_size, int max_epoch, int
     string filepath = prefix + "-" + to_string(epoch) + ".params";
     SaveCheckpoint(filepath, RNN, exe);
   }
+  delete exe;
 }
 
 void predict(wstring* ptext, int sequence_length, const string param_file,
@@ -642,6 +644,7 @@ void predict(wstring* ptext, int sequence_length, const string param_file,
     next = charIndices[n];
     ptext->push_back(next);
   }
+  delete exe;
 }
 
 void predictWithBuiltInRNNOp(wstring* ptext, int sequence_length, const string param_file,
@@ -696,6 +699,7 @@ void predictWithBuiltInRNNOp(wstring* ptext, int sequence_length, const string p
     next = charIndices[n];
     ptext->push_back(next);
   }
+  delete exe;
 }
 
 int main(int argc, char** argv) {
diff --git a/src/engine/profiler.cc b/src/engine/profiler.cc
index 99504f61ce..20b4d2cec1 100644
--- a/src/engine/profiler.cc
+++ b/src/engine/profiler.cc
@@ -71,6 +71,10 @@ Profiler::Profiler()
   }
 }
 
+Profiler::~Profiler(){
+  delete this->profile_stat;
+}
+
 Profiler* Profiler::Get() {
 #if MXNET_USE_PROFILER
   static Profiler inst;
@@ -112,6 +116,7 @@ OprExecStat *Profiler::AddOprStat(int dev_type, uint32_t dev_id) {
       idx = cpu_num_ + gpu_num_;
       break;
     default:
+      delete opr_stat;
       LOG(FATAL) << "Unkown dev_type";
       return NULL;
   }
diff --git a/src/engine/profiler.h b/src/engine/profiler.h
index b7f8e0e1f0..334984b8b4 100644
--- a/src/engine/profiler.h
+++ b/src/engine/profiler.h
@@ -117,6 +117,7 @@ class Profiler {
  protected:
   /*! \brief make constructor protected. */
   Profiler();
+  ~Profiler();
 
  private:
   /*! \brief generate device information following chrome profile file format */
diff --git a/src/engine/stream_manager.h b/src/engine/stream_manager.h
index cd6db53f14..c4633c1da7 100644
--- a/src/engine/stream_manager.h
+++ b/src/engine/stream_manager.h
@@ -90,6 +90,9 @@ RunContext StreamManager<kNumGpus, kStreams>::GetRunContext(
       LOG(FATAL) << MXNET_GPU_NOT_ENABLED_ERROR;
 #endif  // MXNET_USE_CUDA
     }
+    default:
+      LOG(FATAL) << "Undefined dev_mask "<<ctx.dev_mask();
+      break;
   }
   return ret;
 }
@@ -117,6 +120,9 @@ RunContext StreamManager<kNumGpus, kStreams>::GetIORunContext(
       LOG(FATAL) << MXNET_GPU_NOT_ENABLED_ERROR;
 #endif  // MXNET_USE_CUDA
     }
+    default:
+      LOG(FATAL) << "Undefined dev_mask "<<ctx.dev_mask();
+      break;
   }
   return ret;
 }
diff --git a/src/operator/upsampling.cc b/src/operator/upsampling.cc
index 653b5709f1..8025ccecc0 100644
--- a/src/operator/upsampling.cc
+++ b/src/operator/upsampling.cc
@@ -52,6 +52,7 @@ Operator *CreateOp<cpu>(UpSamplingParam param, int dtype) {
       p.stride = TShape(shape, shape + 2);
       shape[0] = shape[1] = pad;
       p.pad = TShape(shape, shape + 2);
+      p.cudnn_off = false;
       op = new DeconvolutionOp<cpu, DType>(p);
     } else {
       LOG(FATAL) << "Unknown sample type";


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services