From 99e1ec02e89f59cef2bb2106deeb897423d58db3 Mon Sep 17 00:00:00 2001 From: MNGanesan Date: Tue, 17 Jan 2023 12:54:26 +0000 Subject: [PATCH 1/2] Enhance the --help message of composite target Presently --help for vitis displays the target and option string, it has no description. Eg: target vitis-ai dpu This can be made more meaningful by fetching the description from the config node of the target. Eg: Vitis AI DPU identifier Here, adding test cases to verify the fix Signed-off-by: MNGanesan --- python/tvm/driver/tvmc/target.py | 2 +- .../python/driver/tvmc/test_target_options.py | 22 +++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/python/tvm/driver/tvmc/target.py b/python/tvm/driver/tvmc/target.py index a3602b4eb8e1..ec8215184ee3 100644 --- a/python/tvm/driver/tvmc/target.py +++ b/python/tvm/driver/tvmc/target.py @@ -72,7 +72,7 @@ def _generate_codegen_args(parser, codegen_name): target_group.add_argument( f"--target-{codegen_name}-{target_option}", type=python_type, - help=f"target {codegen_name} {target_option}{python_type}", + help=field.description, ) diff --git a/tests/python/driver/tvmc/test_target_options.py b/tests/python/driver/tvmc/test_target_options.py index 891df86f0c1f..d8922d9410c3 100644 --- a/tests/python/driver/tvmc/test_target_options.py +++ b/tests/python/driver/tvmc/test_target_options.py @@ -60,6 +60,28 @@ def test_mapping_target_args(): assert reconstruct_target_args(parsed) == {"llvm": {"mcpu": "cortex-m3"}} +def test_composite_target_cmd_line_help(): + parser = argparse.ArgumentParser() + generate_target_args(parser) + assert parser._option_string_actions["--target-vitis-ai-dpu"].help == "Vitis AI DPU identifier" + assert ( + parser._option_string_actions["--target-vitis-ai-build_dir"].help + == "Build directory to be used (optional, debug)" + ) + assert ( + parser._option_string_actions["--target-vitis-ai-work_dir"].help + == "Work directory to be used (optional, debug)" + ) + assert ( + parser._option_string_actions["--target-vitis-ai-export_runtime_module"].help + == "Export the Vitis AI runtime module to this file" + ) + assert ( + parser._option_string_actions["--target-vitis-ai-load_runtime_module"].help + == "Load the Vitis AI runtime module to this file" + ) + + @tvm.testing.requires_cmsisnn def test_include_known_codegen(): parser = argparse.ArgumentParser() From d080aacedbfb0fdce0ad0de2e537c47895c4ca79 Mon Sep 17 00:00:00 2001 From: MNGanesan Date: Wed, 25 Jan 2023 10:19:11 +0000 Subject: [PATCH 2/2] Added decorator for the test case, which check command line help Signed-off-by: MNGanesan --- tests/python/driver/tvmc/test_target_options.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/python/driver/tvmc/test_target_options.py b/tests/python/driver/tvmc/test_target_options.py index d8922d9410c3..8d11e448009d 100644 --- a/tests/python/driver/tvmc/test_target_options.py +++ b/tests/python/driver/tvmc/test_target_options.py @@ -60,6 +60,7 @@ def test_mapping_target_args(): assert reconstruct_target_args(parsed) == {"llvm": {"mcpu": "cortex-m3"}} +@tvm.testing.requires_vitis_ai def test_composite_target_cmd_line_help(): parser = argparse.ArgumentParser() generate_target_args(parser)