Skip to content

Commit addecb5

Browse files
committed
Update the config files with some new flags and ensure that the
```reward_key``` is the same for ```ModuleWorker``` and ```InliningForSizeTask```
1 parent d04ae3b commit addecb5

File tree

4 files changed

+12
-5
lines changed

4 files changed

+12
-5
lines changed

compiler_opt/rl/inlining/env.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,10 @@
2828
class InliningForSizeTask(env.MLGOTask):
2929
"""Implementation of the inlining-for-size MLGOTask."""
3030

31-
def __init__(self, llvm_size_path: str):
31+
def __init__(self, llvm_size_path: str, default_reward_key: str = 'default'):
3232
super().__init__()
3333
self._llvm_size_path = llvm_size_path
34+
self._default_reward_key = default_reward_key
3435

3536
def get_cmdline(self, clang_path: str, base_args: list[str],
3637
interactive_base_path: str | None,
@@ -62,7 +63,7 @@ def get_module_scores(self, working_dir: str) -> dict[str, float]:
6263
raise RuntimeError(f'Wrong llvm-size output {output}')
6364
tmp = tmp[1].split('\t')
6465
native_size = int(tmp[0])
65-
return {'default': native_size}
66+
return {self._default_reward_key: native_size}
6667

6768

6869
@gin.configurable

compiler_opt/rl/inlining/gin_configs/common.gin

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ env.InliningForSizeTask.llvm_size_path=%llvm_size_path
1515
env.get_inlining_env.clang_path=%clang_path
1616

1717
problem_config.flags_to_add.add_flags=()
18-
problem_config.flags_to_delete.delete_flags=('-split-dwarf-file','-split-dwarf-output',)
18+
problem_config.flags_to_delete.delete_flags=('-split-dwarf-file','-split-dwarf-output','--crel','-fskip-odr-check-in-gmf','--warning-suppression-mappings')
1919
# For AFDO profile reinjection set:
2020
# problem_config.flags_to_replace.replace_flags={'-fprofile-sample-use':'/path/to/gwp.afdo','-fprofile-remapping-file':'/path/to/prof_remap.txt'}
2121
problem_config.flags_to_replace.replace_flags={}

compiler_opt/rl/inlining/gin_configs/imitation_learning.gin

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ generate_bc_trajectories_lib.ModuleWorker.partitions=[
1414
285.0, 376.0, 452.0, 512.0, 571.0, 627.5, 720.0, 809.5, 1304.0, 1832.0,
1515
2467.0, 3344.0, 4545.0, 6459.0, 9845.0, 17953.0, 29430.5, 85533.5,
1616
124361.0]
17-
generate_bc_trajectories_lib.ModuleWorker.reward_key='default'
17+
18+
reward_key='default'
19+
generate_bc_trajectories_lib.ModuleWorker.reward_key=%reward_key
20+
env.InliningForSizeTask.reward_key=%reward_key
1821

1922
generate_bc_trajectories_lib.gen_trajectories.data_path=''
2023
generate_bc_trajectories_lib.gen_trajectories.delete_flags=('-split-dwarf-file', '-split-dwarf-output')

compiler_opt/rl/inlining/imitation_learning_config.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# coding=utf-8
12
# Copyright 2020 Google LLC
23
#
34
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -14,6 +15,7 @@
1415
"""Module for collect data of inlining-for-size."""
1516

1617
import gin
18+
from typing import Type
1719

1820
import numpy as np
1921
import tensorflow as tf
@@ -66,6 +68,7 @@ def get_input_signature():
6668
key: tf.TensorSpec(dtype=tf.int64, shape=(), name=key) for key in (
6769
'is_callee_avail_external',
6870
'is_caller_avail_external',
71+
'inlining_default'
6972
)
7073
})
7174

@@ -76,7 +79,7 @@ def get_input_signature():
7679

7780

7881
@gin.register
79-
def get_task_type() -> type[env.InliningForSizeTask]:
82+
def get_task_type() -> Type[env.InliningForSizeTask]:
8083
"""Returns the task type for the trajectory collection."""
8184
return env.InliningForSizeTask
8285

0 commit comments

Comments
 (0)