Skip to content

Commit

Permalink
Removed unused flags for gin bindings and gin configs.
Browse files Browse the repository at this point in the history
  • Loading branch information
tvmarino committed Dec 20, 2024
1 parent 97eb067 commit 2f3f86c
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 36 deletions.
12 changes: 6 additions & 6 deletions compiler_opt/rl/imitation_learning/generate_bc_trajectories.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,19 @@
import gin

from compiler_opt.rl.imitation_learning import generate_bc_trajectories_lib
from compiler_opt.tools import generate_test_model # pylint:disable=unused-import

from tf_agents.system import system_multiprocessing as multiprocessing

flags.FLAGS['gin_files'].allow_override = True
flags.FLAGS['gin_bindings'].allow_override = True

FLAGS = flags.FLAGS
_GIN_FILES = flags.DEFINE_multi_string(
'gin_files', [], 'List of paths to gin configuration files.')
_GIN_BINDINGS = flags.DEFINE_multi_string(
'gin_bindings', [],
'Gin bindings to override the values set in the config files.')


def main(_):
gin.parse_config_files_and_bindings(
FLAGS.gin_files, bindings=FLAGS.gin_bindings, skip_unknown=True)
_GIN_FILES.value, bindings=_GIN_BINDINGS.value, skip_unknown=True)
logging.info(gin.config_str())

generate_bc_trajectories_lib.gen_trajectories()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from typing import Any, Callable, Dict, List, Optional, Tuple, Type, Generator, Union
import json

from absl import flags
# from absl import flags
from absl import logging
import bisect
import dataclasses
Expand All @@ -46,13 +46,6 @@
from compiler_opt.distributed import buffered_scheduler
from compiler_opt.distributed.local import local_worker_manager

from compiler_opt.tools import generate_test_model # pylint:disable=unused-import

flags.FLAGS['gin_files'].allow_override = True
flags.FLAGS['gin_bindings'].allow_override = True

FLAGS = flags.FLAGS

ProfilingDictValueType = Dict[str, Union[str, float, int]]


Expand Down
27 changes: 13 additions & 14 deletions compiler_opt/rl/imitation_learning/generate_bc_trajectories_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

import functools
from absl import app
from absl import flags
import gin
import json
from typing import List
Expand All @@ -36,8 +35,8 @@
from compiler_opt.rl import env
from compiler_opt.rl import env_test

flags.FLAGS['gin_files'].allow_override = True
flags.FLAGS['gin_bindings'].allow_override = True
# flags.FLAGS['gin_files'].allow_override = True
# flags.FLAGS['gin_bindings'].allow_override = True

_eps = 1e-5

Expand Down Expand Up @@ -648,17 +647,17 @@ def select_best_exploration(self, mock_popen, loaded_module_spec):
class GenTrajectoriesTest(tf.test.TestCase):

def setUp(self):
with gin.unlock_config():
gin.parse_config_files_and_bindings(
config_files=['compiler_opt/rl/inlining/gin_configs/common.gin'],
bindings=[
('generate_bc_trajectories_test.'
'MockModuleWorker.clang_path="/test/clang/path"'),
('generate_bc_trajectories_test.'
'MockModuleWorker.exploration_frac=1.0'),
('generate_bc_trajectories_test.'
'MockModuleWorker.reward_key="default"'),
])
with gin.config_scope('gen_trajectories_test'):
with gin.unlock_config():
gin.bind_parameter(
'generate_bc_trajectories_test.MockModuleWorker.clang_path',
'/test/clang/path')
gin.bind_parameter(
'generate_bc_trajectories_test.MockModuleWorker.exploration_frac',
1.0)
gin.bind_parameter(
'generate_bc_trajectories_test.MockModuleWorker.reward_key',
'default')
return super().setUp()

def test_gen_trajectories(self):
Expand Down
7 changes: 5 additions & 2 deletions compiler_opt/rl/inlining/gin_configs/imitation_learning.gin
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,14 @@ env.InliningForSizeTask.llvm_size_path=''

generate_bc_trajectories_lib.ModuleWorker.clang_path=''
generate_bc_trajectories_lib.ModuleWorker.mlgo_task_type=@env.InliningForSizeTask
generate_bc_trajectories_lib.ModuleWorker.policy_paths=[]
generate_bc_trajectories_lib.ModuleWorker.policy_paths=['']
generate_bc_trajectories_lib.ModuleWorker.exploration_policy_paths=[]
generate_bc_trajectories_lib.ModuleWorker.explore_on_features=None
generate_bc_trajectories_lib.ModuleWorker.base_path=''
generate_bc_trajectories_lib.ModuleWorker.partitions=[0.,]
generate_bc_trajectories_lib.ModuleWorker.partitions=[
285.0, 376.0, 452.0, 512.0, 571.0, 627.5, 720.0, 809.5, 1304.0, 1832.0,
2467.0, 3344.0, 4545.0, 6459.0, 9845.0, 17953.0, 29430.5, 85533.5,
124361.0]
generate_bc_trajectories_lib.ModuleWorker.reward_key='default'
# generate_bc_trajectories_lib.ModuleWorker.gin_config_str=None

Expand Down
12 changes: 6 additions & 6 deletions compiler_opt/rl/inlining/imitation_learning_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,19 @@

from compiler_opt.rl.imitation_learning import generate_bc_trajectories_lib
from compiler_opt.rl.inlining import imitation_learning_config
from compiler_opt.tools import generate_test_model # pylint:disable=unused-import

from tf_agents.system import system_multiprocessing as multiprocessing

flags.FLAGS['gin_files'].allow_override = True
flags.FLAGS['gin_bindings'].allow_override = True

FLAGS = flags.FLAGS
_GIN_FILES = flags.DEFINE_multi_string(
'gin_files', [], 'List of paths to gin configuration files.')
_GIN_BINDINGS = flags.DEFINE_multi_string(
'gin_bindings', [],
'Gin bindings to override the values set in the config files.')


def main(_):
gin.parse_config_files_and_bindings(
FLAGS.gin_files, bindings=FLAGS.gin_bindings, skip_unknown=True)
_GIN_FILES.value, bindings=_GIN_BINDINGS.value, skip_unknown=True)
logging.info(gin.config_str())

generate_bc_trajectories_lib.gen_trajectories(
Expand Down

0 comments on commit 2f3f86c

Please sign in to comment.