Skip to content

Commit 72302df

Browse files
update tests
1 parent 0108b13 commit 72302df

2 files changed

Lines changed: 77 additions & 4 deletions

File tree

tests/python/contrib/test_ethosu/test_attr_passing.py

Lines changed: 63 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,23 +25,82 @@
2525
def test_compiler_attr():
2626
config = {
2727
"accelerator_config": "ethos-u55-32",
28+
"enable_cascader": True,
29+
"enable_striping": True,
30+
"disable_copying_constants": True,
31+
"dev_force_block_config": "2x4x16",
32+
"dev_max_open_plans": "256",
33+
"dev_max_closed_plans": "128",
34+
"dev_select_proposal_idx": "1",
35+
"dev_disable_pareto_plans": True,
36+
"dev_disable_pareto_proposals": True,
37+
"dev_disable_block_culling": True,
38+
"dev_cascader_logging": True,
2839
}
2940
with tvm.transform.PassContext(opt_level=3, config={"relay.ext.ethos-u.options": config}):
3041
with tvm.target.Target("c"):
3142
compiler_attrs = tvm.get_global_func("relay.ext.ethos-u.get_compiler_attrs")()
32-
accel_config_str = compiler_attrs.accelerator_config
33-
assert accel_config_str == config["accelerator_config"]
43+
assert compiler_attrs.accelerator_config == config["accelerator_config"]
44+
assert compiler_attrs.enable_cascader == config["enable_cascader"]
45+
assert compiler_attrs.enable_striping == config["enable_striping"]
46+
assert compiler_attrs.disable_copying_constants == config["disable_copying_constants"]
47+
assert compiler_attrs.dev_force_block_config == config["dev_force_block_config"]
48+
assert compiler_attrs.dev_max_open_plans == config["dev_max_open_plans"]
49+
assert compiler_attrs.dev_max_closed_plans == config["dev_max_closed_plans"]
50+
assert compiler_attrs.dev_select_proposal_idx == config["dev_select_proposal_idx"]
51+
assert compiler_attrs.dev_disable_pareto_plans == config["dev_disable_pareto_plans"]
52+
assert (
53+
compiler_attrs.dev_disable_pareto_proposals
54+
== config["dev_disable_pareto_proposals"]
55+
)
56+
assert compiler_attrs.dev_disable_block_culling == config["dev_disable_block_culling"]
57+
assert compiler_attrs.dev_cascader_logging == config["dev_cascader_logging"]
3458

3559

3660
def test_compiler_attr_default():
3761
default_config = {
3862
"accelerator_config": "ethos-u55-256",
63+
"enable_cascader": False,
64+
"enable_striping": False,
65+
"disable_copying_constants": False,
66+
"dev_force_block_config": "",
67+
"dev_max_open_plans": "8",
68+
"dev_max_closed_plans": "32",
69+
"dev_select_proposal_idx": "-1",
70+
"dev_disable_pareto_plans": False,
71+
"dev_disable_pareto_proposals": False,
72+
"dev_disable_block_culling": False,
73+
"dev_cascader_logging": False,
3974
}
4075
with tvm.transform.PassContext(opt_level=3):
4176
with tvm.target.Target("c"):
4277
compiler_attrs = tvm.get_global_func("relay.ext.ethos-u.get_compiler_attrs")()
43-
accel_config_str = compiler_attrs.accelerator_config
44-
assert accel_config_str == default_config["accelerator_config"]
78+
assert compiler_attrs.accelerator_config == default_config["accelerator_config"]
79+
assert compiler_attrs.enable_cascader == default_config["enable_cascader"]
80+
assert compiler_attrs.enable_striping == default_config["enable_striping"]
81+
assert (
82+
compiler_attrs.disable_copying_constants
83+
== default_config["disable_copying_constants"]
84+
)
85+
assert compiler_attrs.dev_force_block_config == default_config["dev_force_block_config"]
86+
assert compiler_attrs.dev_max_open_plans == default_config["dev_max_open_plans"]
87+
assert compiler_attrs.dev_max_closed_plans == default_config["dev_max_closed_plans"]
88+
assert (
89+
compiler_attrs.dev_select_proposal_idx == default_config["dev_select_proposal_idx"]
90+
)
91+
assert (
92+
compiler_attrs.dev_disable_pareto_plans
93+
== default_config["dev_disable_pareto_plans"]
94+
)
95+
assert (
96+
compiler_attrs.dev_disable_pareto_proposals
97+
== default_config["dev_disable_pareto_proposals"]
98+
)
99+
assert (
100+
compiler_attrs.dev_disable_block_culling
101+
== default_config["dev_disable_block_culling"]
102+
)
103+
assert compiler_attrs.dev_cascader_logging == default_config["dev_cascader_logging"]
45104

46105

47106
if __name__ == "__main__":

tests/python/driver/tvmc/test_target_options.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,20 @@ def test_include_known_codegen():
9696
}
9797

9898

99+
@tvm.testing.requires_ethosu
100+
def test_ethosu_compiler_attrs():
101+
# It is checked that the represented string and boolean types in the
102+
# EthosUCompilerConfigNode structure can be passed via the command line
103+
parser = argparse.ArgumentParser()
104+
generate_target_args(parser)
105+
parsed, _ = parser.parse_known_args(
106+
["--target-ethos-u-accelerator_config=ethos-u55-32", "--target-ethos-u-enable_cascader=1"]
107+
)
108+
assert reconstruct_target_args(parsed) == {
109+
"ethos-u": {"accelerator_config": "ethos-u55-32", "enable_cascader": 1},
110+
}
111+
112+
99113
def test_skip_target_from_codegen():
100114
parser = argparse.ArgumentParser()
101115
generate_target_args(parser)

0 commit comments

Comments
 (0)