Skip to content

Commit b800c2b

Browse files
committed
uv tool run yapf -irp .
1 parent ce983d6 commit b800c2b

File tree

12 files changed

+60
-42
lines changed

12 files changed

+60
-42
lines changed

compiler_opt/benchmark/benchmark_chromium.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,9 @@ def main(_):
206206
with open(test_description, encoding='UTF-8') as test_description_file:
207207
print(test_description)
208208
test_descriptions.append(json.load(test_description_file))
209-
test_executables = [test_description['executable'] for test_description in test_descriptions]
209+
test_executables = [
210+
test_description['executable'] for test_description in test_descriptions
211+
]
210212

211213
if FLAGS.compile_llvm:
212214
benchmarking_utils.build_llvm(FLAGS.model_path, FLAGS.llvm_use_incremental,

compiler_opt/benchmark/benchmark_report_test.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,7 @@ def test_loading(self):
8282
}
8383
})
8484
self.assertSetEqual(report.names(), {'BM_A', 'BM_B'})
85-
self.assertSetEqual(report.counters(),
86-
{'PerfCounter_0', 'PerfCounter_1'})
85+
self.assertSetEqual(report.counters(), {'PerfCounter_0', 'PerfCounter_1'})
8786
self.assertEqual(
8887
report.counter_means('BM_A', 'PerfCounter_0'),
8988
(10.488088481701517, 0.7071067811865476))

compiler_opt/es/blackbox_learner.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,9 @@ def _get_perturbations(self) -> List[npt.NDArray[np.float32]]:
170170
"""Get perturbations for the model weights."""
171171
rng = np.random.default_rng(seed=self._seed)
172172
return [
173-
rng.normal(size=len(self._model_weights)) * self._config.precision_parameter
174-
for _ in range(self._config.total_num_perturbations)
173+
rng.normal(size=len(self._model_weights)) *
174+
self._config.precision_parameter
175+
for _ in range(self._config.total_num_perturbations)
175176
]
176177

177178
def _update_model(self, perturbations: List[npt.NDArray[np.float32]],
@@ -274,8 +275,10 @@ def run_step(self, pool: FixedWorkerPool) -> None:
274275
p for p in initial_perturbations for p in (p, -p)
275276
]
276277

277-
perturbations_as_policies = [self._get_policy_from_perturbation(perturbation)
278-
for perturbation in initial_perturbations]
278+
perturbations_as_policies = [
279+
self._get_policy_from_perturbation(perturbation)
280+
for perturbation in initial_perturbations
281+
]
279282

280283
results = self._evaluator.get_results(pool, perturbations_as_policies)
281284
rewards = self._evaluator.get_rewards(results)

compiler_opt/es/regalloc_trace/regalloc_trace_worker.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,9 @@ def _build_corpus(self, modules: Collection[corpus.ModuleSpec],
113113
with concurrent.futures.ThreadPoolExecutor(
114114
max_workers=self._thread_count) as thread_pool:
115115
compile_futures = [
116-
thread_pool.submit(self._compile_module, module, output_directory,
117-
tflite_policy_dir) for module in modules
118-
]
116+
thread_pool.submit(self._compile_module, module, output_directory,
117+
tflite_policy_dir) for module in modules
118+
]
119119

120120
for future in compile_futures:
121121
if future.exception() is not None:

compiler_opt/rl/data_reader.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,11 @@ def _parser_fn(serialized_proto):
4545
context_features = {}
4646
# pylint: disable=g-complex-comprehension
4747
sequence_features = {
48-
tensor_spec.name: tf.io.FixedLenSequenceFeature(
49-
shape=tensor_spec.shape, dtype=tensor_spec.dtype)
50-
for tensor_spec in agent_cfg.time_step_spec.observation.values()}
48+
tensor_spec.name:
49+
tf.io.FixedLenSequenceFeature(
50+
shape=tensor_spec.shape, dtype=tensor_spec.dtype)
51+
for tensor_spec in agent_cfg.time_step_spec.observation.values()
52+
}
5153
sequence_features[
5254
agent_cfg.action_spec.name] = tf.io.FixedLenSequenceFeature(
5355
shape=agent_cfg.action_spec.shape,

compiler_opt/rl/imitation_learning/weighted_bc_trainer_lib.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,9 +235,11 @@ def __init__(
235235

236236
observation_spec, action_spec = config.get_inlining_signature_spec()
237237
sequence_features = {
238-
tensor_spec.name: tf.io.FixedLenSequenceFeature(
239-
shape=tensor_spec.shape, dtype=tensor_spec.dtype)
240-
for tensor_spec in observation_spec[-1].values()}
238+
tensor_spec.name:
239+
tf.io.FixedLenSequenceFeature(
240+
shape=tensor_spec.shape, dtype=tensor_spec.dtype)
241+
for tensor_spec in observation_spec[-1].values()
242+
}
241243
sequence_features.update({
242244
action_spec.name:
243245
tf.io.FixedLenSequenceFeature(

compiler_opt/rl/inlining/config.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ def get_inlining_signature_spec():
6464
'is_multiple_blocks',
6565
'nested_inlines',
6666
'nested_inline_cost_estimate',
67-
'threshold')}
67+
'threshold')
68+
}
6869
reward_spec = tf.TensorSpec(dtype=tf.float32, shape=(), name='reward')
6970
time_step_spec = time_step.time_step_spec(observation_spec, reward_spec)
7071
action_spec = tensor_spec.BoundedTensorSpec(

compiler_opt/rl/inlining/imitation_learning_config.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,15 @@ def get_inlining_signature_spec():
3333
"""Returns (time_step_spec, action_spec) for collecting IL trajectories."""
3434
time_step_spec, _ = config.get_inlining_signature_spec()
3535
observation_spec = time_step_spec.observation
36-
observation_spec.update(
37-
{key: tf.TensorSpec(dtype=tf.int64, shape=(), name=key) for key in (
36+
observation_spec.update({
37+
key: tf.TensorSpec(dtype=tf.int64, shape=(), name=key) for key in (
3838
'is_callee_avail_external',
3939
'is_caller_avail_external',
4040
# following features are not used in training.
4141
'inlining_default',
4242
SequenceExampleFeatureNames.label_name,
43-
'policy_label')}) # testing only
43+
'policy_label')
44+
}) # testing only
4445

4546
observation_spec[SequenceExampleFeatureNames.module_name] = tf.TensorSpec(
4647
dtype=tf.string, shape=(), name=SequenceExampleFeatureNames.module_name)
@@ -63,11 +64,12 @@ def get_input_signature():
6364
"""Returns (time_step_spec, action_spec) wrapping a trained policy."""
6465
time_step_spec, action_spec = config.get_inlining_signature_spec()
6566
observation_spec = time_step_spec.observation
66-
observation_spec.update(
67-
{key: tf.TensorSpec(dtype=tf.int64, shape=(), name=key) for key in (
67+
observation_spec.update({
68+
key: tf.TensorSpec(dtype=tf.int64, shape=(), name=key) for key in (
6869
'is_callee_avail_external',
6970
'is_caller_avail_external',
70-
)})
71+
)
72+
})
7173

7274
time_step_spec = time_step.time_step_spec(observation_spec,
7375
time_step_spec.reward)

compiler_opt/rl/policy_saver.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,8 @@ def _write_output_signature(
181181

182182
# Map spec name to index in flattened outputs.
183183
sm_action_indices = {
184-
k.name.lower(): i for i, k in enumerate(sm_action_signature)}
184+
k.name.lower(): i for i, k in enumerate(sm_action_signature)
185+
}
185186

186187
# List mapping flattened structured outputs to tensors.
187188
sm_action_tensors = saved_model.signatures['action'].outputs

compiler_opt/rl/regalloc/config.py

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -33,22 +33,26 @@ def get_regalloc_signature_spec():
3333

3434
observation_spec = {
3535
key: tf.TensorSpec(dtype=tf.int64, shape=(num_registers), name=key)
36-
for key in ('mask', 'is_hint', 'is_local', 'is_free')}
37-
observation_spec.update(
38-
{key: tensor_spec.BoundedTensorSpec(
39-
dtype=tf.int64,
40-
shape=(num_registers),
41-
name=key,
42-
minimum=0,
43-
maximum=6) for key in ('max_stage', 'min_stage')})
44-
observation_spec.update(
45-
{key: tf.TensorSpec(dtype=tf.float32, shape=(num_registers), name=key)
46-
for key in ('weighed_reads_by_max', 'weighed_writes_by_max',
47-
'weighed_read_writes_by_max', 'weighed_indvars_by_max',
48-
'hint_weights_by_max', 'start_bb_freq_by_max',
49-
'end_bb_freq_by_max', 'hottest_bb_freq_by_max',
50-
'liverange_size', 'use_def_density', 'nr_defs_and_uses',
51-
'nr_broken_hints', 'nr_urgent', 'nr_rematerializable')})
36+
for key in ('mask', 'is_hint', 'is_local', 'is_free')
37+
}
38+
observation_spec.update({
39+
key:
40+
tensor_spec.BoundedTensorSpec(
41+
dtype=tf.int64,
42+
shape=(num_registers),
43+
name=key,
44+
minimum=0,
45+
maximum=6) for key in ('max_stage', 'min_stage')
46+
})
47+
observation_spec.update({
48+
key: tf.TensorSpec(dtype=tf.float32, shape=(num_registers), name=key)
49+
for key in ('weighed_reads_by_max', 'weighed_writes_by_max',
50+
'weighed_read_writes_by_max', 'weighed_indvars_by_max',
51+
'hint_weights_by_max', 'start_bb_freq_by_max',
52+
'end_bb_freq_by_max', 'hottest_bb_freq_by_max',
53+
'liverange_size', 'use_def_density', 'nr_defs_and_uses',
54+
'nr_broken_hints', 'nr_urgent', 'nr_rematerializable')
55+
})
5256
observation_spec['progress'] = tensor_spec.BoundedTensorSpec(
5357
dtype=tf.float32, shape=(), name='progress', minimum=0, maximum=1)
5458

0 commit comments

Comments
 (0)