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
b0cbf351
Commit
b0cbf351
authored
Oct 27, 2022
by
charlie
Browse files
Add broadcast_2in ref_ops tests
parent
49a12511
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
0 deletions
+46
-0
test/ref_ops_test.cpp
test/ref_ops_test.cpp
+46
-0
No files found.
test/ref_ops_test.cpp
View file @
b0cbf351
...
@@ -695,6 +695,52 @@ TEST_CASE(broadcast_test)
...
@@ -695,6 +695,52 @@ TEST_CASE(broadcast_test)
EXPECT
(
output
(
1
,
1
)
==
-
3
);
EXPECT
(
output
(
1
,
1
)
==
-
3
);
}
}
TEST_CASE
(
broadcast_2in_static_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
a_shape
{
migraphx
::
shape
::
int32_type
,
{
2
,
2
}};
std
::
vector
<
int32_t
>
a_data
{
0
,
0
,
0
,
0
};
migraphx
::
shape
b_shape
{
migraphx
::
shape
::
int32_type
,
{
2
}};
std
::
vector
<
int32_t
>
b_data
{
-
2
,
-
3
};
uint64_t
axis
=
0
;
auto
l1
=
mm
->
add_literal
(
migraphx
::
literal
{
a_shape
,
a_data
});
auto
l2
=
mm
->
add_literal
(
migraphx
::
literal
{
b_shape
,
b_data
});
mm
->
add_instruction
(
migraphx
::
make_op
(
"broadcast"
,
{{
"axis"
,
axis
}}),
l2
,
l1
);
p
.
compile
(
migraphx
::
ref
::
target
{});
auto
result
=
p
.
eval
({}).
back
();
auto
output
=
result
.
get
<
int32_t
>
();
EXPECT
(
output
(
0
,
0
)
==
-
2
);
EXPECT
(
output
(
0
,
1
)
==
-
2
);
EXPECT
(
output
(
1
,
0
)
==
-
3
);
EXPECT
(
output
(
1
,
1
)
==
-
3
);
}
TEST_CASE
(
broadcast_2in_dyn_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
a_shape
{
migraphx
::
shape
::
int32_type
,
{{
2
,
2
,
0
},
{
2
,
4
,
0
}}};
migraphx
::
shape
b_shape
{
migraphx
::
shape
::
int32_type
,
{
2
}};
std
::
vector
<
int32_t
>
b_data
{
-
2
,
-
3
};
uint64_t
axis
=
0
;
auto
pa
=
mm
->
add_parameter
(
"a"
,
a_shape
);
auto
lb
=
mm
->
add_literal
(
migraphx
::
literal
{
b_shape
,
b_data
});
mm
->
add_instruction
(
migraphx
::
make_op
(
"broadcast"
,
{{
"axis"
,
axis
}}),
lb
,
pa
);
p
.
compile
(
migraphx
::
ref
::
target
{});
std
::
vector
<
int32_t
>
a_data
{
0
,
0
,
0
,
0
};
migraphx
::
shape
input_fixed_shape0
{
migraphx
::
shape
::
int32_type
,
{
2
,
2
}};
migraphx
::
parameter_map
params0
;
params0
[
"a"
]
=
migraphx
::
argument
(
input_fixed_shape0
,
a_data
.
data
());
auto
result
=
p
.
eval
(
params0
).
back
();
auto
output
=
result
.
get
<
int32_t
>
();
EXPECT
(
output
(
0
,
0
)
==
-
2
);
EXPECT
(
output
(
0
,
1
)
==
-
2
);
EXPECT
(
output
(
1
,
0
)
==
-
3
);
EXPECT
(
output
(
1
,
1
)
==
-
3
);
}
TEST_CASE
(
ceil_test
)
TEST_CASE
(
ceil_test
)
{
{
migraphx
::
program
p
;
migraphx
::
program
p
;
...
...
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