INNER CODE UNIT · Python
eprint
OpenNMT/CTranslate2 · tools/tune_inter_intra.py:8
def eprint(*args, **kwargs):
print(*args, file=sys.stderr, **kwargs)
def csv_print(*args):
print(*args, sep=',')
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]