Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
gaoqiong
MIGraphX
Commits
cb8d9359
Commit
cb8d9359
authored
Nov 29, 2018
by
Khalique
Browse files
added tests for variadic inputs
parent
8ba7c0a0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
67 additions
and
4 deletions
+67
-4
test/cpu_ops_test.cpp
test/cpu_ops_test.cpp
+34
-0
test/onnx/onnx_test.cpp
test/onnx/onnx_test.cpp
+33
-4
No files found.
test/cpu_ops_test.cpp
View file @
cb8d9359
...
...
@@ -1166,4 +1166,38 @@ TEST_CASE(elu_test)
EXPECT
(
migraphx
::
verify_range
(
results_vector
,
gold
));
}
TEST_CASE
(
max_test
)
{
migraphx
::
program
p
;
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
3
}};
auto
l0
=
p
.
add_literal
(
migraphx
::
literal
{
s
,
{
1
,
4
,
3
}});
auto
l1
=
p
.
add_literal
(
migraphx
::
literal
{
s
,
{
2
,
8
,
6
}});
auto
l2
=
p
.
add_literal
(
migraphx
::
literal
{
s
,
{
7
,
5
,
9
}});
auto
curr_max
=
p
.
add_instruction
(
migraphx
::
op
::
max
{},
l0
,
l1
);
p
.
add_instruction
(
migraphx
::
op
::
max
{},
curr_max
,
l2
);
p
.
compile
(
migraphx
::
cpu
::
target
{});
auto
result
=
p
.
eval
({});
std
::
vector
<
float
>
results_vector
(
4
);
result
.
visit
([
&
](
auto
output
)
{
results_vector
.
assign
(
output
.
begin
(),
output
.
end
());
});
std
::
vector
<
float
>
gold
{
7
,
8
,
9
};
EXPECT
(
migraphx
::
verify_range
(
results_vector
,
gold
));
}
TEST_CASE
(
min_test
)
{
migraphx
::
program
p
;
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
3
}};
auto
l0
=
p
.
add_literal
(
migraphx
::
literal
{
s
,
{
1
,
4
,
3
}});
auto
l1
=
p
.
add_literal
(
migraphx
::
literal
{
s
,
{
2
,
8
,
6
}});
auto
l2
=
p
.
add_literal
(
migraphx
::
literal
{
s
,
{
7
,
5
,
9
}});
auto
curr_min
=
p
.
add_instruction
(
migraphx
::
op
::
min
{},
l0
,
l1
);
p
.
add_instruction
(
migraphx
::
op
::
min
{},
curr_min
,
l2
);
p
.
compile
(
migraphx
::
cpu
::
target
{});
auto
result
=
p
.
eval
({});
std
::
vector
<
float
>
results_vector
(
4
);
result
.
visit
([
&
](
auto
output
)
{
results_vector
.
assign
(
output
.
begin
(),
output
.
end
());
});
std
::
vector
<
float
>
gold
{
1
,
4
,
3
};
EXPECT
(
migraphx
::
verify_range
(
results_vector
,
gold
));
}
int
main
(
int
argc
,
const
char
*
argv
[])
{
test
::
run
(
argc
,
argv
);
}
test/onnx/onnx_test.cpp
View file @
cb8d9359
...
...
@@ -175,13 +175,40 @@ void sum_test()
auto
input0
=
p
.
add_parameter
(
"0"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
3
}});
auto
input1
=
p
.
add_parameter
(
"1"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
3
}});
auto
input2
=
p
.
add_parameter
(
"2"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
3
}});
auto
l0
=
p
.
add_instruction
(
migraphx
::
op
::
add
{},
input0
,
input1
);
p
.
add_instruction
(
migraphx
::
op
::
add
{},
l0
,
input2
);
auto
prog
=
migraphx
::
parse_onnx
(
"sum_test.onnx"
);
EXPECT
(
p
==
prog
);
}
void
max_test
()
{
migraphx
::
program
p
;
auto
input0
=
p
.
add_parameter
(
"0"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
3
}});
auto
input1
=
p
.
add_parameter
(
"1"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
3
}});
auto
input2
=
p
.
add_parameter
(
"2"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
3
}});
auto
l0
=
p
.
add_instruction
(
migraphx
::
op
::
max
{},
input0
,
input1
);
p
.
add_instruction
(
migraphx
::
op
::
max
{},
l0
,
input2
);
auto
prog
=
migraphx
::
parse_onnx
(
"max_test.onnx"
);
EXPECT
(
p
==
prog
);
}
auto
l0
=
p
.
add_instruction
(
migraphx
::
op
::
add
{},
input0
,
input1
);
p
.
add_instruction
(
migraphx
::
op
::
add
{},
l0
,
input2
);
auto
prog
=
migraph
::
parse_onnx
(
"sum_test.onnx"
);
void
min_test
()
{
migraphx
::
program
p
;
auto
input0
=
p
.
add_parameter
(
"0"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
3
}});
auto
input1
=
p
.
add_parameter
(
"1"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
3
}});
auto
input2
=
p
.
add_parameter
(
"2"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
3
}});
auto
l0
=
p
.
add_instruction
(
migraphx
::
op
::
min
{},
input0
,
input1
);
p
.
add_instruction
(
migraphx
::
op
::
min
{},
l0
,
input2
);
auto
prog
=
migraphx
::
parse_onnx
(
"min_test.onnx"
);
EXPECT
(
p
==
prog
);
EXPECT
(
p
==
prog
);
}
int
main
()
...
...
@@ -197,4 +224,6 @@ int main()
transpose_test
();
dropout_test
();
sum_test
();
max_test
();
min_test
();
}
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