Skip to content

Commit

Permalink
Remove the --ls_benchmark and --dataset flags.
Browse files Browse the repository at this point in the history
With the new dataset API, enumerating the benchmarks is not
advised (the list may be infinite), and there is now no need to
install datasets ahead of time.

Issue facebookresearch#45.
  • Loading branch information
ChrisCummins authored and bwasti committed Aug 3, 2021
1 parent 3d5f541 commit cdeba3f
Show file tree
Hide file tree
Showing 8 changed files with 7 additions and 56 deletions.
3 changes: 0 additions & 3 deletions compiler_gym/bin/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ py_binary(
"//compiler_gym/util",
"//compiler_gym/util/flags:benchmark_from_flags",
"//compiler_gym/util/flags:env_from_flags",
"//compiler_gym/util/flags:ls_benchmark",
],
)

Expand All @@ -60,7 +59,6 @@ py_binary(
"//compiler_gym:random_search",
"//compiler_gym/util/flags:benchmark_from_flags",
"//compiler_gym/util/flags:env_from_flags",
"//compiler_gym/util/flags:ls_benchmark",
"//compiler_gym/util/flags:nproc",
"//compiler_gym/util/flags:output_dir",
],
Expand Down Expand Up @@ -97,7 +95,6 @@ py_binary(
deps = [
"//compiler_gym:validate",
"//compiler_gym/util",
"//compiler_gym/util/flags:dataset",
"//compiler_gym/util/flags:env_from_flags",
"//compiler_gym/util/flags:nproc",
],
Expand Down
8 changes: 0 additions & 8 deletions compiler_gym/bin/manual_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,6 @@

from absl import app, flags

import compiler_gym.util.flags.ls_benchmark # noqa Flag definition.
from compiler_gym.envs import CompilerEnv
from compiler_gym.util.flags.benchmark_from_flags import benchmark_from_flags
from compiler_gym.util.flags.env_from_flags import env_from_flags
Expand Down Expand Up @@ -895,13 +894,6 @@ def main(argv):
if len(argv) != 1:
raise app.UsageError(f"Unknown command line arguments: {argv[1:]}")

if FLAGS.ls_benchmark:
benchmark = benchmark_from_flags()
env = env_from_flags(benchmark)
print("\n".join(sorted(env.benchmarks)))
env.close()
return

with Timer("Initialized environment"):
# FIXME Chris, I don't seem to actually get a benchmark
benchmark = benchmark_from_flags()
Expand Down
6 changes: 0 additions & 6 deletions compiler_gym/bin/random_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@

from absl import app, flags

import compiler_gym.util.flags.ls_benchmark # noqa Flag definition.
import compiler_gym.util.flags.nproc # noqa Flag definition.
import compiler_gym.util.flags.output_dir # noqa Flag definition.
from compiler_gym.random_search import random_search
Expand Down Expand Up @@ -93,11 +92,6 @@ def main(argv):
if len(argv) != 1:
raise app.UsageError(f"Unknown command line arguments: {argv[1:]}")

if FLAGS.ls_benchmark:
env = env_from_flags()
print("\n".join(sorted(env.benchmarks)))
env.close()
return
if FLAGS.ls_reward:
env = env_from_flags()
print("\n".join(sorted(env.reward.indices.keys())))
Expand Down
2 changes: 0 additions & 2 deletions compiler_gym/bin/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@
import numpy as np
from absl import app, flags

import compiler_gym.util.flags.dataset # noqa Flag definition.
import compiler_gym.util.flags.nproc # noqa Flag definition.
from compiler_gym.envs.compiler_env import CompilerEnvState
from compiler_gym.util.flags.env_from_flags import env_from_flags
Expand Down Expand Up @@ -165,7 +164,6 @@ def main(argv):
validation_results = validate_states(
env_from_flags,
states,
datasets=FLAGS.dataset,
nproc=FLAGS.nproc,
inorder=FLAGS.inorder,
)
Expand Down
12 changes: 0 additions & 12 deletions compiler_gym/util/flags/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,6 @@ py_library(
],
)

py_library(
name = "dataset",
srcs = ["dataset.py"],
visibility = ["//visibility:public"],
)

py_library(
name = "env_from_flags",
srcs = ["env_from_flags.py"],
Expand All @@ -30,12 +24,6 @@ py_library(
],
)

py_library(
name = "ls_benchmark",
srcs = ["ls_benchmark.py"],
visibility = ["//visibility:public"],
)

py_library(
name = "nproc",
srcs = ["nproc.py"],
Expand Down
11 changes: 0 additions & 11 deletions compiler_gym/util/flags/dataset.py

This file was deleted.

7 changes: 0 additions & 7 deletions compiler_gym/util/flags/ls_benchmark.py

This file was deleted.

14 changes: 7 additions & 7 deletions tests/bin/validate_bin_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def test_okay_llvm_result(monkeypatch):
benchmark://cBench-v1/crc32,0,opt input.bc -o output.bc,0.3
""".strip()
flags.FLAGS.unparse_flags()
flags.FLAGS(["argv0", "--env=llvm-ic-v0", "--dataset=cBench-v1"])
flags.FLAGS(["argv0", "--env=llvm-ic-v0"])
monkeypatch.setattr("sys.stdin", StringIO(stdin))

with capture_output() as out:
Expand All @@ -43,7 +43,7 @@ def test_okay_llvm_result_file_input():
""".strip()
)
flags.FLAGS.unparse_flags()
flags.FLAGS(["argv0", "--env=llvm-ic-v0", "--dataset=cBench-v1"])
flags.FLAGS(["argv0", "--env=llvm-ic-v0"])

with capture_output() as out:
main(["argv0", str(path)])
Expand All @@ -54,7 +54,7 @@ def test_okay_llvm_result_file_input():

def test_no_input(monkeypatch):
flags.FLAGS.unparse_flags()
flags.FLAGS(["argv0", "--env=llvm-ic-v0", "--dataset=cBench-v1"])
flags.FLAGS(["argv0", "--env=llvm-ic-v0"])
monkeypatch.setattr("sys.stdin", StringIO(""))

with capture_output() as out:
Expand All @@ -70,7 +70,7 @@ def test_invalid_reward_llvm_result(monkeypatch):
benchmark://cBench-v1/crc32,0.5,opt input.bc -o output.bc,0.3
""".strip()
flags.FLAGS.unparse_flags()
flags.FLAGS(["argv0", "--env=llvm-ic-v0", "--dataset=cBench-v1"])
flags.FLAGS(["argv0", "--env=llvm-ic-v0"])
monkeypatch.setattr("sys.stdin", StringIO(stdin))
with capture_output() as out:
with pytest.raises(SystemExit):
Expand All @@ -86,7 +86,7 @@ def test_invalid_reward_llvm_result(monkeypatch):
def test_invalid_csv_format(monkeypatch):
stdin = "invalid\ncsv\nformat"
flags.FLAGS.unparse_flags()
flags.FLAGS(["argv0", "--env=llvm-ic-v0", "--dataset=cBench-v1"])
flags.FLAGS(["argv0", "--env=llvm-ic-v0"])
monkeypatch.setattr("sys.stdin", StringIO(stdin))

with capture_output() as out:
Expand All @@ -105,7 +105,7 @@ def test_multiple_valid_inputs(monkeypatch):
benchmark://cBench-v1/crc32,,0,opt input.bc -o output.bc
""".strip()
flags.FLAGS.unparse_flags()
flags.FLAGS(["argv0", "--env=llvm-v0", "--dataset=cBench-v1"])
flags.FLAGS(["argv0", "--env=llvm-v0"])
monkeypatch.setattr("sys.stdin", StringIO(stdin))

with capture_output() as out:
Expand Down Expand Up @@ -144,7 +144,7 @@ def test_validate_cBench_null_options(monkeypatch):
benchmark://cBench-v1/susan,,0,opt input.bc -o output.bc
""".strip()
flags.FLAGS.unparse_flags()
flags.FLAGS(["argv0", "--env=llvm-v0", "--dataset=cBench-v1"])
flags.FLAGS(["argv0", "--env=llvm-v0"])
monkeypatch.setattr("sys.stdin", StringIO(stdin))

with capture_output() as out:
Expand Down

0 comments on commit cdeba3f

Please sign in to comment.