示例#1
0
def run_simple_replication(**kwargs):
    """Helper function to run replication tensorflow python script with
       command line arguments"""
    cwd = os.path.dirname(os.path.abspath(inspect.stack()[0][1]))
    out = test_util.run_python_script_helper(cwd, "simple_replication.py",
                                             **kwargs)
    return out
示例#2
0
def run_ipu_estimator_cnn(**kwargs):
    """Helper function to run ipu_estimator_cnn tensorflow python script with
       command line arguments"""
    out = run_python_script_helper(
        os.path.dirname(__file__), "ipu_estimator_cnn.py", **kwargs
    )
    return out
示例#3
0
def run_simple_replication(**kwargs):
    """Helper function to run replication tensorflow python script with
       command line arguments"""
    out = run_python_script_helper(
        os.path.dirname(__file__), "simple_replication.py", **kwargs
    )
    return out
示例#4
0
def run_tensorflow_nmt(**kwargs):
    """Helper function to run nmt tensorflow python script with
       command line arguments"""
    out = run_python_script_helper(os.path.dirname(__file__),
                                   "nmt-tf.py",
                                   **kwargs)
    return out
示例#5
0
def generate_data(path_to_generation_script):
    """Runs the data generation scripts assumes path"""

    files_to_generate = ["training.csv", "validation.csv"]

    if test_util.check_data_exists(path_to_generation_script,
                                   files_to_generate):
        print("Data already generated, skipping...")
        return

    cwd = os.path.dirname(os.path.abspath(inspect.stack()[0][1]))
    test_util.run_python_script_helper(cwd, "data_gen/generate.py")

    if not test_util.check_data_exists(path_to_generation_script,
                                       files_to_generate):
        raise Exception("Dataset generation failed")

    print("Successfully generated datasets")
def run_connection_type(connection_type):
    """Helper to run connect_type.py with specific connection type,
       capture the output, and parse the result."""
    kwargs = {"--connection_type": connection_type}
    out = run_python_script_helper(os.path.dirname(__file__),
                                   "connection_type.py",
                                   want_std_err=True,
                                   **kwargs)
    result = parse_output(out)
    print("result {}".format(result))
    return result
示例#7
0
def generate_data(path_to_generation_script):
    """Runs the data generation scripts assumes path"""

    files_to_generate = ["training.csv", "validation.csv"]

    if check_data_exists(
        path_to_generation_script,
        files_to_generate
    ):
        print("Data already generated, skipping...")
        return

    run_python_script_helper(os.path.dirname(__file__), "data_gen/generate.py")

    if not check_data_exists(
        path_to_generation_script,
        files_to_generate
    ):
        raise Exception("Dataset generation failed")

    print("Successfully generated datasets")
示例#8
0
 def test_tf_code(self):
     """Run the python script and check the result"""
     # Run the script and capture the output
     out = run_python_script_helper(self.path, "tf_code.py")
     # Get the first and the second line of output
     ipu_res, target_res = out.split("\n")[:-1]
     # Convert these lines to arrays, in turn
     list_regex = r"\[.*\]$"
     match = re.search(list_regex, ipu_res)
     string_vals = match.group()[1:-1].split()
     ipu_arr = np.array([float(val) for val in string_vals],
                        dtype=np.float32)
     match = re.search(list_regex, target_res)
     string_vals = match.group()[1:-1].split()
     target_arr = np.array([float(val) for val in string_vals],
                           dtype=np.float32)
     # Finally, check that the results are reasonably close
     assert np.allclose(ipu_arr,
                        target_arr), ("Output value {} does not "
                                      "equal expected value {}".format(
                                          ipu_arr, target_arr))
     # Clean up
     subprocess.run(["make", "clean"], cwd=self.path)
示例#9
0
def run_pytorch_mnist(**kwargs):
    cwd = os.path.dirname(os.path.abspath(inspect.stack()[0][1]))
    return test_util.run_python_script_helper(cwd, "pytorch_popart_mnist.py",
                                              **kwargs)
示例#10
0
def run_pytorch_mnist(**kwargs):
    return run_python_script_helper(os.path.dirname(__file__),
                                    "pytorch_popart_mnist.py", **kwargs)
示例#11
0
def run_popart_mnist_training(**kwargs):
    out = test_util.run_python_script_helper(os.path.dirname(__file__),
                                             "popart_mnist_conv.py", **kwargs)
    return out
def run_report_generation(**kwargs):
    """Helper function to run report generation python script"""
    out = run_python_script_helper(os.path.dirname(__file__),
                                   "report_generation_example.py", **kwargs)
    return out
示例#13
0
def run_pytorch_Torchvision(**kwargs):
    return run_python_script_helper(os.path.dirname(__file__),
                                    "torchvision_examples.py", **kwargs)
示例#14
0
def run_popart_mnist_training(**kwargs):
    """Helper function to run popart mnist linear model python script with
       command line arguments"""
    out = run_python_script_helper(os.path.dirname(__file__),
                                   "popart_mnist.py", **kwargs)
    return out
示例#15
0
def run_report_generation():
    """Helper function to run report generation python script"""
    cwd = os.path.dirname(os.path.abspath(inspect.stack()[0][1]))
    out = test_util.run_python_script_helper(cwd,
                                             "report_generation_example.py")
    return out