Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Performance issues in examples/ #1139

Open
DLPerf opened this issue Aug 20, 2021 · 3 comments
Open

Performance issues in examples/ #1139

DLPerf opened this issue Aug 20, 2021 · 3 comments

Comments

@DLPerf
Copy link

DLPerf commented Aug 20, 2021

Hello! I've found a performance issue in tensorlayer/examples: batch() should be called before map(), which could make your program more efficient. Here is the tensorflow document to support it.

Detailed description is listed below:

  • examples/quantized_net/tutorial_binarynet_cifar10_tfrecord.py: train_ds = train_ds.batch(batch_size)(here) should be called before train_ds = train_ds.map(_map_fn_train, num_parallel_calls=multiprocessing.cpu_count())(here).
  • examples/quantized_net/tutorial_binarynet_cifar10_tfrecord.py: test_ds = test_ds.batch(batch_size)(here) shoule be called before test_ds = test_ds.map(_map_fn_test, num_parallel_calls=multiprocessing.cpu_count())(here).
  • examples/quantized_net/tutorial_dorefanet_cifar10_tfrecord.py: train_ds = train_ds.batch(batch_size)(here) should be called before train_ds = train_ds.map(_map_fn_train, num_parallel_calls=multiprocessing.cpu_count())(here).
  • examples/quantized_net/tutorial_dorefanet_cifar10_tfrecord.py: test_ds = test_ds.batch(batch_size)(here) should be called before test_ds = test_ds.map(_map_fn_test, num_parallel_calls=multiprocessing.cpu_count())(here).
  • examples/quantized_net/tutorial_quanconv_cifar10.py: train_ds = train_ds.batch(batch_size)(here) should be called before train_ds = train_ds.map(_map_fn_train, num_parallel_calls=multiprocessing.cpu_count())(here).
  • examples/quantized_net/tutorial_quanconv_cifar10.py: test_ds = test_ds.batch(batch_size)(here) should be called before test_ds = test_ds.map(_map_fn_test, num_parallel_calls=multiprocessing.cpu_count())(here).
  • examples/quantized_net/tutorial_ternaryweight_cifar10_tfrecord.py: train_ds = train_ds.batch(batch_size)(here) should be called before train_ds = train_ds.map(_map_fn_train, num_parallel_calls=multiprocessing.cpu_count())(here).
  • examples/quantized_net/tutorial_ternaryweight_cifar10_tfrecord.py: test_ds = test_ds.batch(batch_size)(here) should be called before test_ds = test_ds.map(_map_fn_test, num_parallel_calls=multiprocessing.cpu_count())(here).
  • examples/data_process/tutorial_fast_affine_transform.py: dataset = dataset.batch(batch_size)(here) should be called before dataset = dataset.map(_map_fn, num_parallel_calls=multiprocessing.cpu_count())(here).
  • examples/data_process/tutorial_tf_dataset_voc.py: ds = ds.batch(batch_size)(here) should be called before ds = ds.map(_map_fn, num_parallel_calls=multiprocessing.cpu_count())(here).
  • examples/basic_tutorials/tutorial_cifar10_cnn_static.py: train_ds = train_ds.batch(batch_size)(here) should be called before train_ds = train_ds.map(_map_fn_train, num_parallel_calls=multiprocessing.cpu_count())(here).
  • examples/basic_tutorials/tutorial_cifar10_cnn_static.py: test_ds = test_ds.batch(batch_size)(here) should be called before test_ds = test_ds.map(_map_fn_test, num_parallel_calls=multiprocessing.cpu_count())(here).
  • examples/deprecated_tutorials/tutorial_imagenet_inceptionV3_distributed.py: dataset = dataset.batch(batch_size)(here) should be called before dataset = dataset.map(_map_fn, num_parallel_calls=max_cpus)(here).

Besides, you need to check the function called in map()(e.g., _map_fn called in dataset.map()) whether to be affected or not to make the changed code work properly. For example, if _map_fn needs data with shape (x, y, z) as its input before fix, it would require data with shape (batch_size, x, y, z).

Looking forward to your reply. Btw, I am very glad to create a PR to fix it if you are too busy.

@zsdonghao
Copy link
Member

thanks, we will have a check asap

@DLPerf
Copy link
Author

DLPerf commented Aug 31, 2021

Hello,
How long do you need to confirm this problem? @zsdonghao
Thank you~

@hanjr92
Copy link
Member

hanjr92 commented Sep 8, 2021

Sorry! It is too late to reply you. I will modify them and update. @DLPerf

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants