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
8607853b
Commit
8607853b
authored
Apr 15, 2019
by
Paul
Browse files
Add more tests
parent
f43528ed
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
4 deletions
+37
-4
test/propagate_constant_test.cpp
test/propagate_constant_test.cpp
+37
-4
No files found.
test/propagate_constant_test.cpp
View file @
8607853b
#include <migraphx/propagate_constant.hpp>
#include <migraphx/propagate_constant.hpp>
#include <migraphx/dead_code_elimination.hpp>
#include <migraphx/dead_code_elimination.hpp>
#include <migraphx/op/add.hpp>
#include <migraphx/op/add.hpp>
#include <migraphx/op/scalar.hpp>
#include <migraphx/op/mul.hpp>
#include <migraphx/op/mul.hpp>
#include <basic_ops.hpp>
#include <basic_ops.hpp>
#include <test.hpp>
#include <test.hpp>
...
@@ -15,7 +16,7 @@ struct const_prop_target
...
@@ -15,7 +16,7 @@ struct const_prop_target
migraphx
::
context
get_context
()
const
{
return
{};
}
migraphx
::
context
get_context
()
const
{
return
{};
}
};
};
TEST_CASE
(
const_add
1
)
TEST_CASE
(
const_add
)
{
{
migraphx
::
program
p1
;
migraphx
::
program
p1
;
auto
one
=
p1
.
add_literal
(
1
);
auto
one
=
p1
.
add_literal
(
1
);
...
@@ -30,7 +31,7 @@ TEST_CASE(const_add1)
...
@@ -30,7 +31,7 @@ TEST_CASE(const_add1)
EXPECT
(
p1
==
p2
);
EXPECT
(
p1
==
p2
);
}
}
TEST_CASE
(
const_add
2
)
TEST_CASE
(
const_add
_parameter
)
{
{
migraphx
::
program
p1
;
migraphx
::
program
p1
;
auto
one
=
p1
.
add_parameter
(
"one"
,
{
migraphx
::
shape
::
int32_type
,
{
1
}});
auto
one
=
p1
.
add_parameter
(
"one"
,
{
migraphx
::
shape
::
int32_type
,
{
1
}});
...
@@ -45,7 +46,7 @@ TEST_CASE(const_add2)
...
@@ -45,7 +46,7 @@ TEST_CASE(const_add2)
EXPECT
(
p1
!=
p2
);
EXPECT
(
p1
!=
p2
);
}
}
TEST_CASE
(
const_add
3
)
TEST_CASE
(
const_
multi
add
)
{
{
migraphx
::
program
p1
;
migraphx
::
program
p1
;
auto
one
=
p1
.
add_literal
(
1
);
auto
one
=
p1
.
add_literal
(
1
);
...
@@ -61,7 +62,7 @@ TEST_CASE(const_add3)
...
@@ -61,7 +62,7 @@ TEST_CASE(const_add3)
EXPECT
(
p1
==
p2
);
EXPECT
(
p1
==
p2
);
}
}
TEST_CASE
(
const_add
4
)
TEST_CASE
(
const_add
_mul
)
{
{
migraphx
::
program
p1
;
migraphx
::
program
p1
;
auto
one
=
p1
.
add_literal
(
1
);
auto
one
=
p1
.
add_literal
(
1
);
...
@@ -78,4 +79,36 @@ TEST_CASE(const_add4)
...
@@ -78,4 +79,36 @@ TEST_CASE(const_add4)
EXPECT
(
p1
==
p2
);
EXPECT
(
p1
==
p2
);
}
}
TEST_CASE
(
const_add_scalar
)
{
migraphx
::
program
p1
;
auto
one
=
p1
.
add_instruction
(
migraphx
::
op
::
scalar
{{
migraphx
::
shape
::
int32_type
,
{
2
,
2
}}},
p1
.
add_literal
(
1
));
auto
two
=
p1
.
add_instruction
(
migraphx
::
op
::
scalar
{{
migraphx
::
shape
::
int32_type
,
{
2
,
2
}}},
p1
.
add_literal
(
2
));
auto
sum
=
p1
.
add_instruction
(
migraphx
::
op
::
add
{},
one
,
two
);
p1
.
add_instruction
(
pass_op
{},
sum
);
p1
.
compile
(
const_prop_target
{});
migraphx
::
program
p2
;
auto
total
=
p2
.
add_literal
(
migraphx
::
literal
{{
migraphx
::
shape
::
int32_type
,
{
2
,
2
}},
{
3
,
3
,
3
,
3
}});
p2
.
add_instruction
(
pass_op
{},
total
);
EXPECT
(
p1
==
p2
);
}
TEST_CASE
(
const_scalar
)
{
migraphx
::
program
p1
;
{
auto
one
=
p1
.
add_instruction
(
migraphx
::
op
::
scalar
{{
migraphx
::
shape
::
int32_type
,
{
2
,
2
}}},
p1
.
add_literal
(
1
));
p1
.
add_instruction
(
pass_op
{},
one
);
}
p1
.
compile
(
const_prop_target
{});
migraphx
::
program
p2
;
{
auto
one
=
p2
.
add_instruction
(
migraphx
::
op
::
scalar
{{
migraphx
::
shape
::
int32_type
,
{
2
,
2
}}},
p2
.
add_literal
(
1
));
p2
.
add_instruction
(
pass_op
{},
one
);
}
EXPECT
(
p1
==
p2
);
}
int
main
(
int
argc
,
const
char
*
argv
[])
{
test
::
run
(
argc
,
argv
);
}
int
main
(
int
argc
,
const
char
*
argv
[])
{
test
::
run
(
argc
,
argv
);
}
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