Skip to content

Commit

Permalink
[Frontend][ArgParse] Compile with default target(LLVM) when built USE…
Browse files Browse the repository at this point in the history
…_MRVL=ON(apache#17454)

This is a use-case of invoking TVMC with default target though it is built with MRVL_ON.
In command line processing, validate_target_args checks if there are add-on options
derived from the default arguments of codegen/BYOC and it expects that particular codegen
to be given explicitly in command line. However, certain codegen's can have default target alone,
in that case codegen optios are not extracted there by relaxing the validation

Signed-off-by: M N Ganesan <[email protected]>
  • Loading branch information
M N Ganesan committed Oct 23, 2024
1 parent eef2340 commit fd36853
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
8 changes: 8 additions & 0 deletions python/tvm/driver/tvmc/composite_target.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,41 +52,49 @@
"compute-library": {
"config_key": None,
"pass_default": False,
"default_target": None,
"pass_pipeline": partition_for_arm_compute_lib,
},
"cmsis-nn": {
"config_key": "relay.ext.cmsisnn.options",
"pass_default": False,
"default_target": None,
"pass_pipeline": partition_for_cmsisnn,
},
"ethos-n": {
"config_key": "relay.ext.ethos-n.options",
"pass_default": False,
"default_target": None,
"pass_pipeline": partition_for_ethosn,
},
"ethos-u": {
"config_key": "relay.ext.ethos-u.options",
"pass_default": False,
"default_target": None,
"pass_pipeline": partition_for_ethosu,
},
"bnns": {
"config_key": None,
"pass_default": False,
"default_target": None,
"pass_pipeline": partition_for_bnns,
},
"vitis-ai": {
"config_key": "relay.ext.vitis_ai.options",
"pass_default": False,
"default_target": None,
"pass_pipeline": partition_for_vitis_ai,
},
"clml": {
"config_key": None,
"pass_default": False,
"default_target": None,
"pass_pipeline": partition_for_clml,
},
"mrvl": {
"config_key": "relay.ext.mrvl.options",
"pass_default": True,
"default_target": "llvm",
"pass_pipeline": partition_for_mrvl,
},
}
Expand Down
4 changes: 4 additions & 0 deletions python/tvm/driver/tvmc/target.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,11 @@ def _reconstruct_codegen_args(args, codegen_name):
codegen = get_codegen_by_target(codegen_name)
pass_configs = PassContext.list_configs()
codegen_options = {}
default_tgt = codegen["default_target"]

# Do not fetch codegen options, if the default target alone is choosen by user
if codegen_name not in args.target and default_tgt is not None and default_tgt in args.target:
return codegen_options
if codegen["config_key"] is not None and codegen["config_key"] in pass_configs:
attrs = make_node(pass_configs[codegen["config_key"]]["type"])
fields = attrs_api.AttrsListFieldInfo(attrs)
Expand Down
13 changes: 13 additions & 0 deletions tests/python/driver/tvmc/test_target_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,19 @@ def test_default_arg_for_mrvl_hybrid():
assert parsed.target_mrvl_num_tiles == 8


@tvm.testing.requires_mrvl
# Test for default(LLVM) target, when built with USE_MRVL=ON
def test_mrvl_build_with_llvm_only_target():
parser = argparse.ArgumentParser()
generate_target_args(parser)
parsed, _ = parser.parse_known_args(
[
"--target=llvm",
]
)
assert parsed.target == "llvm"


@tvm.testing.requires_cmsisnn
def test_mapping_target_args():
parser = argparse.ArgumentParser()
Expand Down

0 comments on commit fd36853

Please sign in to comment.