You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by jx...@apache.org on 2018/03/22 05:51:38 UTC
[incubator-mxnet] branch master updated: [MXNET-124] Upgrade
examples to use newer profiler API (#10190)
This is an automated email from the ASF dual-hosted git repository.
jxie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-mxnet.git
The following commit(s) were added to refs/heads/master by this push:
new b51cfbe [MXNET-124] Upgrade examples to use newer profiler API (#10190)
b51cfbe is described below
commit b51cfbef95918f0a49d4cc9f9655d2698eaa929d
Author: Chris Olivier <cj...@gmail.com>
AuthorDate: Wed Mar 21 22:51:34 2018 -0700
[MXNET-124] Upgrade examples to use newer profiler API (#10190)
* Upgrade examples to use newer profiler API
* Trigger rebuild
---
benchmark/python/sparse/sparse_end2end.py | 6 +++---
example/profiler/profiler_executor.py | 6 +++---
example/profiler/profiler_imageiter.py | 6 +++---
example/profiler/profiler_matmul.py | 6 +++---
example/profiler/profiler_ndarray.py | 6 +++---
tests/python/unittest/test_profiler.py | 2 +-
6 files changed, 16 insertions(+), 16 deletions(-)
diff --git a/benchmark/python/sparse/sparse_end2end.py b/benchmark/python/sparse/sparse_end2end.py
index ecd9057..d032f9d 100644
--- a/benchmark/python/sparse/sparse_end2end.py
+++ b/benchmark/python/sparse/sparse_end2end.py
@@ -239,8 +239,8 @@ if __name__ == '__main__':
device = 'gpu' + str(args.num_gpu)
name = 'profile_' + args.dataset + '_' + device + '_nworker' + str(num_worker)\
+ '_batchsize' + str(args.batch_size) + '_outdim' + str(args.output_dim) + '.json'
- mx.profiler.profiler_set_config(mode='all', filename=name)
- mx.profiler.profiler_set_state('run')
+ mx.profiler.set_config(profile_all=True, filename=name)
+ mx.profiler.set_state('run')
logging.debug('start training ...')
start = time.time()
@@ -301,7 +301,7 @@ if __name__ == '__main__':
logging.info('|cpu/{} cores| {} | {} | {} |'.format(str(num_cores), str(num_worker), str(average_cost_epoch), rank))
data_iter.reset()
if profiler:
- mx.profiler.profiler_set_state('stop')
+ mx.profiler.set_state('stop')
end = time.time()
time_cost = end - start
logging.info('num_worker = {}, rank = {}, time cost = {}'.format(str(num_worker), str(rank), str(time_cost)))
diff --git a/example/profiler/profiler_executor.py b/example/profiler/profiler_executor.py
index 117a8df..8ab417a 100644
--- a/example/profiler/profiler_executor.py
+++ b/example/profiler/profiler_executor.py
@@ -128,7 +128,7 @@ def benchmark(mod, dry_run=10, iterations=10):
t0 = time.clock()
- profiler.profiler_set_state('run')
+ profiler.set_state('run')
# real run
for i in range(iterations):
mod.forward(batch, is_train=True)
@@ -136,7 +136,7 @@ def benchmark(mod, dry_run=10, iterations=10):
mod.update()
for output in mod.get_outputs(merge_multi_context=False)[0]:
output.wait_to_read()
- profiler.profiler_set_state('stop')
+ profiler.set_state('stop')
t1 = time.clock()
return (t1 - t0)*1000.0 / iterations
@@ -152,7 +152,7 @@ def executor(num_iteration):
args = parse_args()
if __name__ == '__main__':
- mx.profiler.profiler_set_config(mode='symbolic', filename=args.profile_filename)
+ mx.profiler.set_config(profile_symbolic=True, filename=args.profile_filename)
print('profile file save to {0}'.format(args.profile_filename))
print('executor num_iteration: {0}'.format(args.iter_num))
executor_time = executor(args.iter_num)
diff --git a/example/profiler/profiler_imageiter.py b/example/profiler/profiler_imageiter.py
index 77ca412..c8e7478 100644
--- a/example/profiler/profiler_imageiter.py
+++ b/example/profiler/profiler_imageiter.py
@@ -40,7 +40,7 @@ def run_imageiter(path_rec, n, batch_size=32):
if __name__ == '__main__':
- mx.profiler.profiler_set_config(mode='all', filename='profile_imageiter.json')
- mx.profiler.profiler_set_state('run')
+ mx.profiler.set_config(profile_all=True, filename='profile_imageiter.json')
+ mx.profiler.set_state('run')
run_imageiter('test.rec', 20) # See http://mxnet.io/tutorials/python/image_io.html for how to create .rec files.
- mx.profiler.profiler_set_state('stop')
+ mx.profiler.set_state('stop')
diff --git a/example/profiler/profiler_matmul.py b/example/profiler/profiler_matmul.py
index a23545c..6b92bcc 100644
--- a/example/profiler/profiler_matmul.py
+++ b/example/profiler/profiler_matmul.py
@@ -33,7 +33,7 @@ def parse_args():
args = parse_args()
if __name__ == '__main__':
- mx.profiler.profiler_set_config(mode='symbolic', filename=args.profile_filename)
+ mx.profiler.set_config(profile_symbolic=True, filename=args.profile_filename)
print('profile file save to {0}'.format(args.profile_filename))
A = mx.sym.Variable('A')
@@ -53,10 +53,10 @@ if __name__ == '__main__':
for i in range(args.iter_num):
if i == args.begin_profiling_iter:
t0 = time.clock()
- mx.profiler.profiler_set_state('run')
+ mx.profiler.set_state('run')
if i == args.end_profiling_iter:
t1 = time.clock()
- mx.profiler.profiler_set_state('stop')
+ mx.profiler.set_state('stop')
executor.forward()
c = executor.outputs[0]
c.wait_to_read()
diff --git a/example/profiler/profiler_ndarray.py b/example/profiler/profiler_ndarray.py
index 5c233c6..e34b536 100644
--- a/example/profiler/profiler_ndarray.py
+++ b/example/profiler/profiler_ndarray.py
@@ -316,8 +316,8 @@ def test_broadcast():
if __name__ == '__main__':
- mx.profiler.profiler_set_config(mode='all', filename='profile_ndarray.json')
- mx.profiler.profiler_set_state('run')
+ mx.profiler.set_config(profile_all=True, filename='profile_ndarray.json')
+ mx.profiler.set_state('run')
test_ndarray_slice_along_axis()
test_broadcast()
test_ndarray_elementwise()
@@ -333,4 +333,4 @@ if __name__ == '__main__':
test_ndarray_onehot()
test_ndarray_fill()
test_reduce()
- mx.profiler.profiler_set_state('stop')
+ mx.profiler.set_state('stop')
diff --git a/tests/python/unittest/test_profiler.py b/tests/python/unittest/test_profiler.py
index 7654cd2..cdc1be4 100644
--- a/tests/python/unittest/test_profiler.py
+++ b/tests/python/unittest/test_profiler.py
@@ -83,7 +83,7 @@ def test_profile_create_domain():
def test_profile_create_domain_dept():
- profiler.profiler_set_config(mode='symbolic', filename='test_profile_create_domain_dept.json')
+ profiler.set_config(profile_symbolic=True, filename='test_profile_create_domain_dept.json')
profiler.set_state('run')
domain = profiler.Domain(name='PythonDomain')
print("Domain created: {}".format(str(domain)))
--
To stop receiving notification emails like this one, please contact
jxie@apache.org.