This is an automated email from the ASF dual-hosted git repository. zhasheng 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 590d7b0 add profile option for frontend profiling to image script (#8171) 590d7b0 is described below commit 590d7b0fd96afdd1205fc0df15a0dc31db862f1f Author: Sheng Zha <s...@users.noreply.github.com> AuthorDate: Sat Oct 21 14:32:36 2017 -0700 add profile option for frontend profiling to image script (#8171) * add profile option for frontend profiling to image script * Update image_classification.py * Update image_classification.py --- example/gluon/image_classification.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/example/gluon/image_classification.py b/example/gluon/image_classification.py index 8481afb..a67da35 100644 --- a/example/gluon/image_classification.py +++ b/example/gluon/image_classification.py @@ -64,6 +64,9 @@ parser.add_argument('--use-pretrained', action='store_true', parser.add_argument('--kvstore', type=str, default='device', help='kvstore to use for trainer/module.') parser.add_argument('--log-interval', type=int, default=50, help='Number of batches to wait before logging.') +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.') opt = parser.parse_args() logging.info(opt) @@ -166,7 +169,7 @@ def train(epochs, ctx): net.save_params('image-classifier-%s-%d.params'%(opt.model, epochs)) -if __name__ == '__main__': +def main(): if opt.mode == 'symbolic': data = mx.sym.var('data') out = net(data) @@ -186,3 +189,16 @@ if __name__ == '__main__': if opt.mode == 'hybrid': net.hybridize() train(opt.epochs, context) + +if __name__ == '__main__': + if opt.profile: + import hotshot, hotshot.stats + prof = hotshot.Profile('image-classifier-%s-%s.prof'%(opt.model, opt.mode)) + prof.runcall(main) + prof.close() + stats = hotshot.stats.load('image-classifier-%s-%s.prof'%(opt.model, opt.mode)) + stats.strip_dirs() + stats.sort_stats('cumtime', 'calls') + stats.print_stats() + else: + main() -- To stop receiving notification emails like this one, please contact ['"comm...@mxnet.apache.org" <comm...@mxnet.apache.org>'].