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

Add a module of wrappers for CompilerEnv environments. #272

Merged
merged 1 commit into from
May 18, 2021

Conversation

ChrisCummins
Copy link
Contributor

This adds a series of helper wrappers under a new
compiler_gym.warppers module that makes it easier to modify the
behavior of CompilerEnv environments without having to change the
underlying implementation.

New classes are:

  • CompilerEnvWrapper an extension to gym.Wrapper to support the
    custom compiler_gym API calls.
  • ActionWrapper compatibility with gym.ActionWrapper.
  • CommandlineWithTerminalAction adds an "end of episode" action to a
    commandline space.
  • ConstrainedCommandline allows a subset of commandline flags to be
    selected for use.
  • CycleOverBenchmarks loop over a list of benchamrks on reset().
  • IterateOverBenchmarks same as above but the iterator is
    exhaustible.
  • RandomOrderBenchmarks same as above but the order is random and
    non-terminating.

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label May 16, 2021
@ChrisCummins ChrisCummins requested a review from JD-ETH May 16, 2021 21:42
Copy link
Contributor

@JD-ETH JD-ETH left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Super useful, exactly what I have been mimicing :D This gives a modular way to experiment with different action/env configurations.

Can we add the time limit wrapper as well? Fixed horizon is a very standard setup.

@ChrisCummins ChrisCummins force-pushed the wrappers branch 2 times, most recently from dd74530 to 21d75a1 Compare May 17, 2021 19:22
@codecov-commenter
Copy link

codecov-commenter commented May 17, 2021

Codecov Report

Merging #272 (c6a4dec) into development (9231dff) will decrease coverage by 1.53%.
The diff coverage is 91.34%.

Impacted file tree graph

@@               Coverage Diff               @@
##           development     #272      +/-   ##
===============================================
- Coverage        83.52%   81.99%   -1.54%     
===============================================
  Files               78       86       +8     
  Lines             4426     4677     +251     
===============================================
+ Hits              3697     3835     +138     
- Misses             729      842     +113     
Impacted Files Coverage Δ
compiler_gym/wrappers/core.py 85.00% <85.00%> (ø)
compiler_gym/wrappers/commandline.py 89.79% <89.79%> (ø)
compiler_gym/wrappers/datasets.py 95.83% <95.83%> (ø)
compiler_gym/datasets/benchmark.py 98.94% <100.00%> (+0.02%) ⬆️
compiler_gym/wrappers/__init__.py 100.00% <100.00%> (ø)
compiler_gym/wrappers/time_limit.py 100.00% <100.00%> (ø)
compiler_gym/service/connection.py 73.99% <0.00%> (-1.29%) ⬇️
compiler_gym/envs/llvm/llvm_env.py 86.86% <0.00%> (-0.14%) ⬇️
... and 7 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9231dff...c6a4dec. Read the comment docs.

This adds a series of helper wrappers under a new
`compiler_gym.warppers` module that makes it easier to modify the
behavior of CompilerEnv environments without having to change the
underlying implementation.

New classes are:

* `CompilerEnvWrapper` an extension to `gym.Wrapper` to support the
  custom compiler_gym API calls.

* `ActionWrapper` compatibility with `gym.ActionWrapper`.

* `CommandlineWithTerminalAction` adds an "end of episode" action to a
  commandline space.

* `ConstrainedCommandline` allows a subset of commandline flags to be
  selected for use.

* `CycleOverBenchmarks` loop over a list of benchamrks on `reset()`.

* `IterateOverBenchmarks` same as above but the iterator is
  exhaustible.

* `RandomOrderBenchmarks` same as above but the order is random and
  non-terminating.
@ChrisCummins
Copy link
Contributor Author

Can we add the time limit wrapper as well? Fixed horizon is a very standard setup.

Good idea, done.

@ChrisCummins ChrisCummins merged commit bdf6fb3 into facebookresearch:development May 18, 2021
@ChrisCummins ChrisCummins deleted the wrappers branch May 18, 2021 00:48
This was referenced Jun 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants