INNER CODE UNIT · Python

N_PHYSICAL_CORES

OpenNMT/CTranslate2 · tools/tune_inter_intra.py:14

N_PHYSICAL_CORES = multiprocessing.cpu_count() // 2
eprint("Optimizing for up to:", N_PHYSICAL_CORES, "cores")

# try best first, ie: closest to the number of cores
configurations = sorted([(i, j) for (i, j) in itertools.product(range(1, N_PHYSICAL_CORES+1), repeat=2) if i*j <= N_PHYSICAL_CORES], key=lambda x: x[0]*x[1], reverse=True)
eprint("Values to explore:", list(configurations))

# do not wait standard input if a src file to translate is given
input_to_translate = bytes() if "--src" in sys.argv else sys.stdin.read().encode()

translate_bin_path = sys.argv[1]

if not os.access(translate_bin_path, os.X_OK):
    eprint("No executable file at:", translate_bin_path)
    exit(1)

def popen_with(inter_threads, intra_threads):
    user_args = [arg for arg in sys.argv[2:] if arg != "--log_profiling"]

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…