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

Replace _compile_fn with compile_fn #107

Merged
merged 1 commit into from
Aug 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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