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
[tf.data] Support eager mode benchmarking #46320
[tf.data] Support eager mode benchmarking #46320
Conversation
cc: @aaudiber for review. |
I don't think eager benchmarks are worth maintaining, since the backend dataset implementation works the same in both eager and graph mode. WDYT @jsimsa? |
I think there is value in being able to run benchmarks in eager mode but this support should certainly not result in duplicating benchmark code. Instead, the benchmark base should be modified to make it possible to run a benchmark both in graph mode or eagerly. Which mode to use could be a based on which parameter is passed to |
I see that not all the benchmarks located in As per @jsimsa 's suggestion, I can modify the I can do the same for benchmarks which do not inherit the What do you think? @jsimsa @aaudiber? UPDATE: The benchmarks do not take the |
Thanks @kvignesh1420. You plan for modifying |
@jsimsa thanks for the go-ahead. I will update the PR with the required changes and try to refactor things. |
tf.data.Dataset
s
tf.data.Dataset
s
I have modified the cc: @jsimsa @aaudiber let me know how it looks. I can take up the benchmarks in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you. As per one of my comments, we want to test that the new implementation works as expected before merging the PR (and I provided you with instructions on how to do so).
@jsimsa I have modified the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great. Thank you for the changes. Left one minor comment. Other than that it looks good.
This PR adds support for eager execution based benchmarks based on the benchmarking context. This is achieved by checking for the
eager_execution()
value within the benchmarking context and iterating over the dataset eagerly in theDatasetBenchmarkBase
class.Additionally, the
ListFilesBenchmark
inpython/data/benchmarks/list_files_benchmark.py
has been refactored to use theDatasetBenchmarkBase
class.A sample comparison w.r.t
RangeBenchmark
is as follows:GRAPH MODE:
EAGER MODE:
w.r.t
ListFilesBenchmark
NOTE: Description has been updated as per review comments.