Exemple #1
0
def test_mapping_registered_args_no_match_for_name():
    parser = argparse.ArgumentParser()
    generate_registry_args(parser, Executor)
    parsed, _ = parser.parse_known_args(["--executor=woof"])

    with pytest.raises(TVMCException, match='Executor "woof" is not defined'):
        reconstruct_registry_entity(parsed, Executor)
Exemple #2
0
def test_mapping_registered_args_mismatch_for_arg():
    parser = argparse.ArgumentParser()
    generate_registry_args(parser, Executor)
    parsed, _ = parser.parse_known_args(
        ["--executor=aot", "--executor-graph-link-params=1"])

    with pytest.raises(
            TVMCException,
            match=
            "Passed --executor-graph-link-params but did not specify graph executor",
    ):
        reconstruct_registry_entity(parsed, Executor)
Exemple #3
0
def drive_compile(args):
    """Invoke tvmc.compiler module with command line arguments

    Parameters
    ----------
    args: argparse.Namespace
        Arguments from command line parser.

    Returns
    -------
    int
        Zero if successfully completed

    """
    if not os.path.isfile(args.FILE):
        raise TVMCException(
            f"Input file '{args.FILE}' doesn't exist, is a broken symbolic link, or a directory."
        )

    tvmc_model = frontends.load_model(args.FILE, args.model_format,
                                      args.input_shapes)

    dump_code = [x.strip() for x in args.dump_code.split(",")
                 ] if args.dump_code else None

    compile_model(
        tvmc_model,
        args.target,
        opt_level=args.opt_level,
        executor=reconstruct_registry_entity(args, Executor),
        runtime=reconstruct_registry_entity(args, Runtime),
        tuning_records=args.tuning_records,
        package_path=args.output,
        cross=args.cross_compiler,
        cross_options=args.cross_compiler_options,
        output_format=args.output_format,
        dump_code=dump_code,
        target_host=None,
        desired_layout=args.desired_layout,
        disabled_pass=args.disabled_pass,
        pass_context_configs=args.pass_config,
        additional_target_options=reconstruct_target_args(args),
        mod_name=args.module_name,
    )

    return 0
Exemple #4
0
def test_mapping_registered_args():
    parser = argparse.ArgumentParser()
    generate_registry_args(parser, Executor)
    parsed, _ = parser.parse_known_args(
        ["--executor=aot", "--executor-aot-interface-api=c"])
    entity = reconstruct_registry_entity(parsed, Executor)

    assert isinstance(entity, Executor)
    assert "interface-api" in entity
    assert entity["interface-api"] == "c"
Exemple #5
0
def test_mapping_registered_args_no_arg():
    parser = argparse.ArgumentParser()
    generate_registry_args(parser, Executor)
    parsed, _ = parser.parse_known_args([])

    assert reconstruct_registry_entity(parsed, Executor) == None