INNER CODE UNIT · Python

performance_with_parameters

OpenNMT/CTranslate2 · tools/tune_inter_intra.py:35

def performance_with_parameters(inter_threads, intra_threads):
    translate = popen_with(inter_threads, intra_threads)
    translate.stdin.write(input_to_translate)
    translate.stdin.close()
    # any error in the execution of the program will show in stderr and will prevent us to parse tokens/s
    try:
        err = str(translate.stderr.read().decode("utf-8"))
        tokens_per_seconds = float(err)
    except KeyboardInterrupt:
        raise KeyboardInterrupt()
    except:
        eprint(err)
        exit(1)
    memory_used = 0
    # try to get maximum memory used if supported
    try:
        memory_used = os.wait4(translate.pid, 0)[2].ru_maxrss # in MB
    except:

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…