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 2018/03/30 23:10:50 UTC

[GitHub] cjolivier01 closed pull request #10326: TEST -- DO NO MERGE

cjolivier01 closed pull request #10326: TEST -- DO NO MERGE
URL: https://github.com/apache/incubator-mxnet/pull/10326
 
 
   

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/example/gluon/image_classification.py b/example/gluon/image_classification.py
index a67a31790a0..9acfda51d17 100644
--- a/example/gluon/image_classification.py
+++ b/example/gluon/image_classification.py
@@ -22,7 +22,6 @@
 
 import mxnet as mx
 from mxnet import gluon
-from mxnet import profiler
 from mxnet.gluon import nn
 from mxnet.gluon.model_zoo import vision as models
 from mxnet import autograd as ag
@@ -97,7 +96,6 @@
 parser.add_argument('--profile', action='store_true',
                     help='Option to turn on memory profiling for front-end, '\
                          'and prints out the memory usage by python function at the end.')
-parser.add_argument('--builtin-profiler', type=int, default=0, help='Enable built-in profiler (0=off, 1=on)')
 opt = parser.parse_args()
 
 # global variables
@@ -196,9 +194,6 @@ def train(opt, ctx):
                             kvstore = kv)
     loss = gluon.loss.SoftmaxCrossEntropyLoss()
 
-
-    total_time = 0
-    num_epochs = 0
     best_acc = [0]
     for epoch in range(opt.start_epoch, opt.epochs):
         trainer = update_learning_rate(opt.lr, trainer, epoch, opt.lr_factor, lr_steps)
@@ -228,29 +223,16 @@ def train(opt, ctx):
                                epoch, i, batch_size/(time.time()-btic), name[0], acc[0], name[1], acc[1]))
             btic = time.time()
 
-        epoch_time = time.time()-tic
-
-        # First epoch will usually be much slower than the subsequent epics,
-        # so don't factor into the average
-        if num_epochs > 0:
-          total_time = total_time + epoch_time
-        num_epochs = num_epochs + 1
-
         name, acc = metric.get()
         logger.info('[Epoch %d] training: %s=%f, %s=%f'%(epoch, name[0], acc[0], name[1], acc[1]))
-        logger.info('[Epoch %d] time cost: %f'%(epoch, epoch_time))
+        logger.info('[Epoch %d] time cost: %f'%(epoch, time.time()-tic))
         name, val_acc = test(ctx, val_data)
         logger.info('[Epoch %d] validation: %s=%f, %s=%f'%(epoch, name[0], val_acc[0], name[1], val_acc[1]))
 
         # save model if meet requirements
         save_checkpoint(epoch, val_acc[0], best_acc)
-    if num_epochs > 1:
-        print('Average epoch time: {}'.format(float(total_time)/(num_epochs - 1)))
 
 def main():
-    if opt.builtin_profiler > 0:
-        profiler.set_config(profile_all=True, aggregate_stats=True)
-        profiler.set_state('run')
     if opt.mode == 'symbolic':
         data = mx.sym.var('data')
         out = net(data)
@@ -272,9 +254,6 @@ def main():
         if opt.mode == 'hybrid':
             net.hybridize()
         train(opt, context)
-    if opt.builtin_profiler > 0:
-        profiler.set_state('stop')
-        print(profiler.dumps())
 
 if __name__ == '__main__':
     if opt.profile:
diff --git a/src/engine/threaded_engine.cc b/src/engine/threaded_engine.cc
index ca5602bb482..77b14b43a7b 100644
--- a/src/engine/threaded_engine.cc
+++ b/src/engine/threaded_engine.cc
@@ -326,7 +326,8 @@ void ThreadedEngine::PushSync(SyncFn exec_fn, Context exec_ctx,
                               FnProperty prop,
                               int priority,
                               const char* opr_name) {
-  if (!bulk_size() || prop != FnProperty::kNormal || priority) {
+  BulkStatus& bulk_status = *BulkStatusStore::Get();
+  if (!bulk_status.bulk_size || prop != FnProperty::kNormal || priority) {
     this->PushAsync([exec_fn](RunContext ctx, CallbackOnComplete on_complete) {
         exec_fn(ctx);
         on_complete();
@@ -334,9 +335,9 @@ void ThreadedEngine::PushSync(SyncFn exec_fn, Context exec_ctx,
     return;
   }
 
-  const BulkStatus& bulk_status = *BulkStatusStore::Get();
   if (bulk_status.count && exec_ctx != bulk_status.ctx) BulkFlush();
   BulkAppend(exec_fn, exec_ctx, const_vars, mutable_vars);
+  return;
 }
 
 void ThreadedEngine::DeleteVariable(SyncFn delete_fn,
diff --git a/src/engine/threaded_engine.h b/src/engine/threaded_engine.h
index d72784d0498..1b9453f903b 100644
--- a/src/engine/threaded_engine.h
+++ b/src/engine/threaded_engine.h
@@ -398,7 +398,7 @@ class ThreadedEngine : public Engine {
   }
 
   int bulk_size() const override {
-    return profiler::Profiler::Get()->AggregateRunning() ? 0 :  BulkStatusStore::Get()->bulk_size;
+    return BulkStatusStore::Get()->bulk_size;
   }
 
   int set_bulk_size(int bulk_size) override {
diff --git a/src/executor/graph_executor.cc b/src/executor/graph_executor.cc
index fa5931e5c84..ee97649768b 100644
--- a/src/executor/graph_executor.cc
+++ b/src/executor/graph_executor.cc
@@ -1348,8 +1348,7 @@ void GraphExecutor::InitOpSegs() {
   // Generate segments based on the graph structure
   bool prefer_bulk_exec_inference = dmlc::GetEnv("MXNET_EXEC_BULK_EXEC_INFERENCE", true);
   // Whether to perform bulk exec for training
-  bool prefer_bulk_exec = dmlc::GetEnv("MXNET_EXEC_BULK_EXEC_TRAIN", 1)
-                          && !profiler::Profiler::Get()->AggregateEnabled();
+  bool prefer_bulk_exec = dmlc::GetEnv("MXNET_EXEC_BULK_EXEC_TRAIN", 1);
 
   bool is_training = num_forward_nodes_ != total_num_nodes;
 
@@ -1360,6 +1359,8 @@ void GraphExecutor::InitOpSegs() {
   if (prefer_bulk_exec_inference && !is_training) {
     this->BulkInferenceOpSegs();
   }
+
+  return;
 }
 
 void GraphExecutor::BulkTrainingOpSegs(size_t total_num_nodes) {
diff --git a/src/profiler/profiler.h b/src/profiler/profiler.h
index b8d0e8ef340..768a0bc7d71 100644
--- a/src/profiler/profiler.h
+++ b/src/profiler/profiler.h
@@ -391,14 +391,6 @@ class Profiler {
     return aggregate_stats_.get() != nullptr;
   }
 
-  /*!
-   * \brief Whether aggregate stats are currently being recorded
-   * \return true if aggregate stats are currently being recorded
-   */
-  inline bool AggregateRunning() const {
-    return GetState() == kRunning && AggregateEnabled();
-  }
-
  public:
   /*!
    * \brief Constructor


 

----------------------------------------------------------------
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