Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
gaoqiong
MIGraphX
Commits
7b2516e0
Commit
7b2516e0
authored
Jan 17, 2023
by
charlie
Browse files
Fix argument parsing for map
parent
c6e4c1c6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
10 deletions
+29
-10
tools/dyn_test_runner.py
tools/dyn_test_runner.py
+29
-10
No files found.
tools/dyn_test_runner.py
View file @
7b2516e0
...
...
@@ -70,22 +70,41 @@ def parse_dyn_dim_str(dim_str):
def
parse_dyn_dims_str
(
dds_str
):
# expecting string like "{{1, 4, 2}, {4, 4}, {4, 4}}"
dyn_dims
=
dds_str
[
1
,
-
2
].
split
(
', '
)
# expecting string like "[{1, 4, 2}, {4, 4}, {4, 4}]"
dyn_dims
=
[]
start_ind
=
0
dds_str
=
dds_str
.
strip
(
'[]'
)
for
i
,
v
in
enumerate
(
dds_str
):
if
v
==
'{'
:
start_ind
=
i
elif
v
==
'}'
:
dyn_dims
.
append
(
dds_str
[
start_ind
:
i
+
1
])
return
[
parse_dyn_dim_str
(
dd
)
for
dd
in
dyn_dims
]
def
parse_map_dyn_input_str
(
dict_str
):
# return {input_name: list<dynamic_dimension>}
# expecting string like: {"A": {{1, 4, 2}, {4, 4}, {4, 4}}, "B": {{2, 4}, {2, 4}}}
dict_str
=
dict_str
[
1
,
-
2
]
pairs
=
dict_str
.
split
(
', '
)
# expecting string like: `{"A": [{1, 4, 2}, {4, 4}, {4, 4}], "B": [{2, 4}, {2, 4}]}`
start_ind
=
0
in_quotes
=
False
keys
=
[]
dyn_dim_strs
=
[]
for
i
,
v
in
enumerate
(
dict_str
):
if
v
==
'"'
:
if
not
in_quotes
:
start_ind
=
i
in_quotes
=
True
else
:
keys
.
append
(
dict_str
[
start_ind
:
i
+
1
])
in_quotes
=
False
elif
v
==
'['
and
not
in_quotes
:
start_ind
=
i
elif
v
==
']'
and
not
in_quotes
:
dyn_dim_strs
.
append
(
dict_str
[
start_ind
:
i
+
1
])
dd_dict
=
{}
for
p
in
pairs
:
key
,
dyn_dims_str
=
p
.
split
(
': '
)
dds
=
parse_dyn_dims_str
(
dyn_dims_str
)
# key[1:-2] to remove quotation marks
dd_dict
[
key
[
1
:
-
2
]]
=
dds
for
key
,
dds
in
zip
(
keys
,
dyn_dim_strs
):
x
=
parse_dyn_dims_str
(
dds
)
dd_dict
[
key
.
strip
(
'"'
)]
=
x
return
dd_dict
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment