Skip to content

Commit 6379f41

Browse files
Fix run_extraction after earlier patch
My refactoring earlier in 32064da ended up breaking the extract_ir.py script as local objects can't be pickled. This patch changes everything back to using a functools.partial() but maintains the spirit of the original refactoring by still eliminating the global helper function. I would like to add in a test case for this but it would have to be an integration style test to get the setup correct and we don't have the infrastructure to do that currently.
1 parent 32064da commit 6379f41

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

compiler_opt/tools/extract_ir_lib.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import shutil
2121
import subprocess
2222
import multiprocessing
23+
import functools
2324
import json
2425

2526
from typing import Dict, List, Optional
@@ -314,10 +315,13 @@ def run_extraction(objs: List[TrainingIRExtractor], num_workers: int,
314315
bitcode_section_name: The name of the bitcode section created by the
315316
bitcode embedding.
316317
"""
317-
318-
def extract_artifacts(obj: TrainingIRExtractor) -> Optional[str]:
319-
return obj.extract(llvm_objcopy_path, cmd_filter, thinlto_build,
320-
cmd_section_name, bitcode_section_name)
318+
extract_artifacts = functools.partial(
319+
TrainingIRExtractor.extract,
320+
llvm_objcopy_path=llvm_objcopy_path,
321+
cmd_filter=cmd_filter,
322+
thinlto_build=thinlto_build,
323+
cmd_section_name=cmd_section_name,
324+
bitcode_section_name=bitcode_section_name)
321325

322326
with multiprocessing.Pool(num_workers) as pool:
323327
relative_output_paths = pool.map(extract_artifacts, objs)

0 commit comments

Comments
 (0)