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
84c745c6
Commit
84c745c6
authored
Sep 08, 2023
by
umang yadav
Browse files
Use param_prefix
parent
b888b61d
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
27 deletions
+29
-27
src/include/migraphx/op/if_op.hpp
src/include/migraphx/op/if_op.hpp
+3
-2
test/multi_target/multitarget_test.cpp
test/multi_target/multitarget_test.cpp
+26
-25
No files found.
src/include/migraphx/op/if_op.hpp
View file @
84c745c6
...
@@ -70,12 +70,13 @@ struct if_op
...
@@ -70,12 +70,13 @@ struct if_op
module_ref
mod
=
cond
?
mods
[
0
]
:
mods
[
1
];
module_ref
mod
=
cond
?
mods
[
0
]
:
mods
[
1
];
std
::
unordered_map
<
std
::
string
,
argument
>
params
;
std
::
unordered_map
<
std
::
string
,
argument
>
params
;
std
::
vector
<
std
::
string
>
pnames
;
std
::
set
<
std
::
string
>
pnames
;
for
(
const_module_ref
smod
:
mods
)
for
(
const_module_ref
smod
:
mods
)
{
{
auto
names
=
smod
->
get_parameter_names
();
auto
names
=
smod
->
get_parameter_names
();
pnames
.
insert
(
pnames
.
end
(),
names
.
begin
(),
names
.
end
());
pnames
.
insert
(
names
.
begin
(),
names
.
end
());
}
}
assert
(
pnames
.
size
()
<
args
.
size
());
assert
(
pnames
.
size
()
<
args
.
size
());
std
::
transform
(
pnames
.
begin
(),
std
::
transform
(
pnames
.
begin
(),
pnames
.
end
(),
pnames
.
end
(),
...
...
test/multi_target/multitarget_test.cpp
View file @
84c745c6
...
@@ -299,15 +299,16 @@ TEST_CASE(multitarget_compile_nested_if_then_else)
...
@@ -299,15 +299,16 @@ TEST_CASE(multitarget_compile_nested_if_then_else)
auto
x
=
mm
->
add_parameter
(
"x"
,
ds
);
auto
x
=
mm
->
add_parameter
(
"x"
,
ds
);
auto
y
=
mm
->
add_parameter
(
"y"
,
ds
);
auto
y
=
mm
->
add_parameter
(
"y"
,
ds
);
auto
z
=
mm
->
add_parameter
(
"z"
,
ds
);
auto
z
=
mm
->
add_parameter
(
"z"
,
ds
);
auto
create_test_module
=
[
&
](
migraphx
::
program
&
prog
,
std
::
size_t
tid
)
{
auto
create_test_module
=
[
&
](
migraphx
::
program
&
prog
,
std
::
size_t
tid
,
std
::
string
param_prefix
)
{
std
::
string
mod_name
=
std
::
string
mod_name
=
"target_"
+
std
::
to_string
(
tid
)
+
"_"
+
std
::
to_string
(
counter_map
[
tid
]
++
);
"target_"
+
std
::
to_string
(
tid
)
+
"_"
+
std
::
to_string
(
counter_map
[
tid
]
++
);
auto
*
test_mod
=
prog
.
create_module
(
mod_name
);
auto
*
test_mod
=
prog
.
create_module
(
mod_name
);
std
::
vector
<
float
>
data
(
ds
.
elements
(),
-
1
);
std
::
vector
<
float
>
data
(
ds
.
elements
(),
-
1
);
auto
l1
=
test_mod
->
add_literal
(
migraphx
::
literal
(
ds
,
data
));
auto
l1
=
test_mod
->
add_literal
(
migraphx
::
literal
(
ds
,
data
));
auto
test_mod_param_0
=
test_mod
->
add_parameter
(
mod_name
+
"_param_0"
,
ds
);
auto
test_mod_param_0
=
test_mod
->
add_parameter
(
param_prefix
+
"_param_0"
,
ds
);
auto
test_mod_param_1
=
test_mod
->
add_parameter
(
mod_name
+
"_param_1"
,
ds
);
auto
test_mod_param_1
=
test_mod
->
add_parameter
(
param_prefix
+
"_param_1"
,
ds
);
auto
test_mod_param_2
=
test_mod
->
add_parameter
(
mod_name
+
"_param_2"
,
ds
);
auto
test_mod_param_2
=
test_mod
->
add_parameter
(
param_prefix
+
"_param_2"
,
ds
);
auto
ins1
=
test_mod
->
add_instruction
(
migraphx
::
make_op
(
"add"
),
test_mod_param_0
,
l1
);
auto
ins1
=
test_mod
->
add_instruction
(
migraphx
::
make_op
(
"add"
),
test_mod_param_0
,
l1
);
auto
ins2
=
test_mod
->
add_instruction
(
migraphx
::
make_op
(
"mul"
),
ins1
,
test_mod_param_1
);
auto
ins2
=
test_mod
->
add_instruction
(
migraphx
::
make_op
(
"mul"
),
ins1
,
test_mod_param_1
);
auto
ins3
=
test_mod
->
add_instruction
(
migraphx
::
make_op
(
"sub"
),
ins2
,
test_mod_param_2
);
auto
ins3
=
test_mod
->
add_instruction
(
migraphx
::
make_op
(
"sub"
),
ins2
,
test_mod_param_2
);
...
@@ -335,7 +336,7 @@ TEST_CASE(multitarget_compile_nested_if_then_else)
...
@@ -335,7 +336,7 @@ TEST_CASE(multitarget_compile_nested_if_then_else)
then_mod_ref_ins
,
then_mod_ref_ins
,
then_mod_param_1
,
then_mod_param_1
,
then_mod_param_2
},
then_mod_param_2
},
{
create_test_module
(
p
,
1
),
create_test_module
(
p
,
0
)});
{
create_test_module
(
p
,
1
,
"1_"
),
create_test_module
(
p
,
0
,
"2_"
)});
auto
then_mod_if_0
=
auto
then_mod_if_0
=
then_mod
->
add_instruction
(
migraphx
::
make_op
(
"get_tuple_elem"
,
{{
"index"
,
0
}}),
then_mod_if
);
then_mod
->
add_instruction
(
migraphx
::
make_op
(
"get_tuple_elem"
,
{{
"index"
,
0
}}),
then_mod_if
);
then_mod
->
add_return
({
then_mod_if_0
});
then_mod
->
add_return
({
then_mod_if_0
});
...
@@ -360,7 +361,7 @@ TEST_CASE(multitarget_compile_nested_if_then_else)
...
@@ -360,7 +361,7 @@ TEST_CASE(multitarget_compile_nested_if_then_else)
else_mod_param_2
,
else_mod_param_2
,
else_mod_param_1
,
else_mod_param_1
,
else_mod_param_0
},
else_mod_param_0
},
{
create_test_module
(
p
,
0
),
create_test_module
(
p
,
1
)});
{
create_test_module
(
p
,
0
,
"1_"
),
create_test_module
(
p
,
1
,
"2_"
)});
auto
else_mod_if_0
=
auto
else_mod_if_0
=
else_mod
->
add_instruction
(
migraphx
::
make_op
(
"get_tuple_elem"
,
{{
"index"
,
0
}}),
else_mod_if
);
else_mod
->
add_instruction
(
migraphx
::
make_op
(
"get_tuple_elem"
,
{{
"index"
,
0
}}),
else_mod_if
);
else_mod
->
add_return
({
else_mod_if_0
});
else_mod
->
add_return
({
else_mod_if_0
});
...
...
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