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 issue in utils.py (by P3) #10

Open
DLPerf opened this issue Aug 27, 2021 · 1 comment
Open

Performance issue in utils.py (by P3) #10

DLPerf opened this issue Aug 27, 2021 · 1 comment

Comments

@DLPerf
Copy link

DLPerf commented Aug 27, 2021

Hello! I've found a performance issue in utils.py: .batch(MODEL_PARAMS['batch_size'] )(line 72) should be called before .map( parse_example_helper_csv, num_parallel_calls=8 )(line 46), which could make your program more efficient.

Here is the tensorflow document to support it.

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

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

@DSXiangLi
Copy link
Owner

@DLPerf Thanks for point this out! Honestly I haven't pay much attention to performance before >< I just took a look at that performance doc, and found there are actually multiple ways to speed up the tf.data ^O^ !

  1. speed up data transformation
  • sequential mapping -> parall mapping, by using the num_parallel_calls that I already used in the code
  • scalar mapping -> vectorized mapping, by using batch before map as you proposed
  1. speed up data extraction: sequential extraction -> parallel extraction, by using interleave. But in order to use this, I think we need to chunk train sample into multiple tf records in advance ?
  2. parallelize above ops with training, by using prefetch.

Maybe we can add the other 2 also? Currenly I am indeed not available to manage this repo, could you please help me fix this? Much appreciated!

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

2 participants