Skip to content

Commit

Permalink
Replace _compile_fn with compile_fn
Browse files Browse the repository at this point in the history
Will be used directly by google#96
  • Loading branch information
Northbadge committed Aug 16, 2022
1 parent 220c0f5 commit 72b8af4
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions compiler_opt/rl/compilation_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ def collect_data(
ValueError if example under default policy and ml policy does not match.
"""
if reward_stat is None:
default_result = self._compile_fn(
default_result = self.compile_fn(
module_spec,
tf_policy_path='',
reward_only=bool(tf_policy_path),
Expand All @@ -308,7 +308,7 @@ def collect_data(
}

if tf_policy_path:
policy_result = self._compile_fn(
policy_result = self.compile_fn(
module_spec,
tf_policy_path,
reward_only=False,
Expand Down Expand Up @@ -346,7 +346,7 @@ def collect_data(
rewards=rewards,
keys=keys)

def _compile_fn(
def compile_fn(
self, module_spec: corpus.ModuleSpec, tf_policy_path: str,
reward_only: bool,
cancellation_manager: Optional[WorkerCancellationManager]
Expand Down
8 changes: 4 additions & 4 deletions compiler_opt/rl/compilation_runner_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def assertListProtoEqual(self, a, b):
self.assertProtoEquals(x, y)

@mock.patch(constant.BASE_MODULE_DIR +
'.compilation_runner.CompilationRunner._compile_fn')
'.compilation_runner.CompilationRunner.compile_fn')
def test_policy(self, mock_compile_fn):
mock_compile_fn.side_effect = _mock_compile_fn
runner = compilation_runner.CompilationRunner(
Expand Down Expand Up @@ -132,7 +132,7 @@ def test_policy(self, mock_compile_fn):
self.assertAllClose([0.1998002], data.rewards)

@mock.patch(constant.BASE_MODULE_DIR +
'.compilation_runner.CompilationRunner._compile_fn')
'.compilation_runner.CompilationRunner.compile_fn')
def test_default(self, mock_compile_fn):
mock_compile_fn.side_effect = _mock_compile_fn
runner = compilation_runner.CompilationRunner(
Expand Down Expand Up @@ -163,7 +163,7 @@ def test_default(self, mock_compile_fn):
self.assertAllClose([0], data.rewards)

@mock.patch(constant.BASE_MODULE_DIR +
'.compilation_runner.CompilationRunner._compile_fn')
'.compilation_runner.CompilationRunner.compile_fn')
def test_given_default_size(self, mock_compile_fn):
mock_compile_fn.side_effect = _mock_compile_fn
runner = compilation_runner.CompilationRunner(
Expand Down Expand Up @@ -198,7 +198,7 @@ def test_given_default_size(self, mock_compile_fn):
self.assertAllClose([0.199800], data.rewards)

@mock.patch(constant.BASE_MODULE_DIR +
'.compilation_runner.CompilationRunner._compile_fn')
'.compilation_runner.CompilationRunner.compile_fn')
def test_exception_handling(self, mock_compile_fn):
mock_compile_fn.side_effect = subprocess.CalledProcessError(
returncode=1, cmd='error')
Expand Down
2 changes: 1 addition & 1 deletion compiler_opt/rl/inlining/inlining_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def __init__(self, llvm_size_path: str, *args, **kwargs):
super().__init__(*args, **kwargs)
self._llvm_size_path = llvm_size_path

def _compile_fn(
def compile_fn(
self, module_spec: corpus.ModuleSpec, tf_policy_path: str,
reward_only: bool, cancellation_manager: Optional[
compilation_runner.WorkerCancellationManager]
Expand Down
2 changes: 1 addition & 1 deletion compiler_opt/rl/regalloc/regalloc_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class RegAllocRunner(compilation_runner.CompilationRunner):

# TODO: refactor file_paths parameter to ensure correctness during
# construction
def _compile_fn(
def compile_fn(
self, module_spec: corpus.ModuleSpec, tf_policy_path: str,
reward_only: bool, cancellation_manager: Optional[
compilation_runner.WorkerCancellationManager]
Expand Down

0 comments on commit 72b8af4

Please sign in to comment.