Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Aleksei-grovety committed Jun 28, 2023
1 parent 0108b13 commit 72302df
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 4 deletions.
67 changes: 63 additions & 4 deletions tests/python/contrib/test_ethosu/test_attr_passing.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,82 @@
def test_compiler_attr():
config = {
"accelerator_config": "ethos-u55-32",
"enable_cascader": True,
"enable_striping": True,
"disable_copying_constants": True,
"dev_force_block_config": "2x4x16",
"dev_max_open_plans": "256",
"dev_max_closed_plans": "128",
"dev_select_proposal_idx": "1",
"dev_disable_pareto_plans": True,
"dev_disable_pareto_proposals": True,
"dev_disable_block_culling": True,
"dev_cascader_logging": True,
}
with tvm.transform.PassContext(opt_level=3, config={"relay.ext.ethos-u.options": config}):
with tvm.target.Target("c"):
compiler_attrs = tvm.get_global_func("relay.ext.ethos-u.get_compiler_attrs")()
accel_config_str = compiler_attrs.accelerator_config
assert accel_config_str == config["accelerator_config"]
assert compiler_attrs.accelerator_config == config["accelerator_config"]
assert compiler_attrs.enable_cascader == config["enable_cascader"]
assert compiler_attrs.enable_striping == config["enable_striping"]
assert compiler_attrs.disable_copying_constants == config["disable_copying_constants"]
assert compiler_attrs.dev_force_block_config == config["dev_force_block_config"]
assert compiler_attrs.dev_max_open_plans == config["dev_max_open_plans"]
assert compiler_attrs.dev_max_closed_plans == config["dev_max_closed_plans"]
assert compiler_attrs.dev_select_proposal_idx == config["dev_select_proposal_idx"]
assert compiler_attrs.dev_disable_pareto_plans == config["dev_disable_pareto_plans"]
assert (
compiler_attrs.dev_disable_pareto_proposals
== config["dev_disable_pareto_proposals"]
)
assert compiler_attrs.dev_disable_block_culling == config["dev_disable_block_culling"]
assert compiler_attrs.dev_cascader_logging == config["dev_cascader_logging"]


def test_compiler_attr_default():
default_config = {
"accelerator_config": "ethos-u55-256",
"enable_cascader": False,
"enable_striping": False,
"disable_copying_constants": False,
"dev_force_block_config": "",
"dev_max_open_plans": "8",
"dev_max_closed_plans": "32",
"dev_select_proposal_idx": "-1",
"dev_disable_pareto_plans": False,
"dev_disable_pareto_proposals": False,
"dev_disable_block_culling": False,
"dev_cascader_logging": False,
}
with tvm.transform.PassContext(opt_level=3):
with tvm.target.Target("c"):
compiler_attrs = tvm.get_global_func("relay.ext.ethos-u.get_compiler_attrs")()
accel_config_str = compiler_attrs.accelerator_config
assert accel_config_str == default_config["accelerator_config"]
assert compiler_attrs.accelerator_config == default_config["accelerator_config"]
assert compiler_attrs.enable_cascader == default_config["enable_cascader"]
assert compiler_attrs.enable_striping == default_config["enable_striping"]
assert (
compiler_attrs.disable_copying_constants
== default_config["disable_copying_constants"]
)
assert compiler_attrs.dev_force_block_config == default_config["dev_force_block_config"]
assert compiler_attrs.dev_max_open_plans == default_config["dev_max_open_plans"]
assert compiler_attrs.dev_max_closed_plans == default_config["dev_max_closed_plans"]
assert (
compiler_attrs.dev_select_proposal_idx == default_config["dev_select_proposal_idx"]
)
assert (
compiler_attrs.dev_disable_pareto_plans
== default_config["dev_disable_pareto_plans"]
)
assert (
compiler_attrs.dev_disable_pareto_proposals
== default_config["dev_disable_pareto_proposals"]
)
assert (
compiler_attrs.dev_disable_block_culling
== default_config["dev_disable_block_culling"]
)
assert compiler_attrs.dev_cascader_logging == default_config["dev_cascader_logging"]


if __name__ == "__main__":
Expand Down
14 changes: 14 additions & 0 deletions tests/python/driver/tvmc/test_target_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,20 @@ def test_include_known_codegen():
}


@tvm.testing.requires_ethosu
def test_ethosu_compiler_attrs():
# It is checked that the represented string and boolean types in the
# EthosUCompilerConfigNode structure can be passed via the command line
parser = argparse.ArgumentParser()
generate_target_args(parser)
parsed, _ = parser.parse_known_args(
["--target-ethos-u-accelerator_config=ethos-u55-32", "--target-ethos-u-enable_cascader=1"]
)
assert reconstruct_target_args(parsed) == {
"ethos-u": {"accelerator_config": "ethos-u55-32", "enable_cascader": 1},
}


def test_skip_target_from_codegen():
parser = argparse.ArgumentParser()
generate_target_args(parser)
Expand Down

0 comments on commit 72302df

Please sign in to comment.