Example #1
0
def check_output(*args, **kwargs):
    try:
        out = subprocess.check_output(*args,
                                      cwd=bert_root_dir(),
                                      stderr=subprocess.PIPE,
                                      **kwargs)
    except subprocess.CalledProcessError as e:
        print(f"TEST FAILED")
        print(f"stdout={e.stdout.decode('utf-8',errors='ignore')}")
        print(f"stderr={e.stderr.decode('utf-8',errors='ignore')}")
        raise
    return out
Example #2
0
def test_average_distributed_deques():
    try:
        subprocess.check_output(
            f"mpirun --allow-run-as-root -x "
            f"PYTHONPATH={bert_root_dir()}:$PYTHONPATH -np 2 "
            f"python3 {os.path.abspath(__file__)}",
            shell=True,
            cwd=bert_root_dir(),
            stderr=subprocess.PIPE)
    except subprocess.CalledProcessError as e:
        print(f"TEST FAILED")
        print(f"stdout={e.stdout.decode('utf-8',errors='ignore')}")
        print(f"stderr={e.stderr.decode('utf-8',errors='ignore')}")
        raise
Example #3
0
def test_host_embedding(custom_ops):
    args_string = [
        "--config",
        os.path.join(bert_root_dir(),
                     'configs/mk1/squad_base_128_inference.json'),
        '--host-embedding=ALL', '--device-connection-type=ondemand',
        '--generated-data=true'
    ]
    args = utils.parse_bert_args(args_string)
    args.shuffle = False
    args.host_embedding = "ALL"
    host_embedding_outputs = np.array(run_embedding_layer(args), dtype=float)
    args.host_embedding = "NONE"
    ipu_embedding_outputs = np.array(run_embedding_layer(args), dtype=float)

    if np.allclose(host_embedding_outputs, ipu_embedding_outputs, rtol=0.3):
        logger.info("Passed")
    else:
        logger.info("Failed")
        raise TestFailureError("outputs do not match")
Example #4
0
def generated_sample_input_file():
    with tempfile.TemporaryDirectory() as tmpdirname:
        input_file = generate_sample_input_files(
            os.path.join(bert_root_dir(), "bert_data/sample_text.txt"),
            tmpdirname)
        yield input_file
Example #5
0
def custom_ops():
    so_path = os.path.join(bert_root_dir(), "custom_ops.so")
    ctypes.cdll.LoadLibrary(so_path)
    return so_path
Example #6
0
def pytest_sessionstart(session):
    subprocess.run(['make'], shell=True, cwd=bert_root_dir())