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
d7ba7f44
Commit
d7ba7f44
authored
Apr 29, 2019
by
Shucai Xiao
Browse files
add more test for the refinement.
parent
f8511fad
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
22 additions
and
2 deletions
+22
-2
src/eliminate_contiguous.cpp
src/eliminate_contiguous.cpp
+6
-0
src/include/migraphx/op/binary.hpp
src/include/migraphx/op/binary.hpp
+1
-1
src/include/migraphx/op/unary.hpp
src/include/migraphx/op/unary.hpp
+1
-1
test/eliminate_contiguous_test.cpp
test/eliminate_contiguous_test.cpp
+14
-0
No files found.
src/eliminate_contiguous.cpp
View file @
d7ba7f44
...
@@ -20,6 +20,12 @@ static bool try_compute_shape(instruction_ref ins, const std::vector<shape>& inp
...
@@ -20,6 +20,12 @@ static bool try_compute_shape(instruction_ref ins, const std::vector<shape>& inp
return
true
;
return
true
;
}
}
// if no changes for the shape, the contiguous can also be removed
if
(
new_shape
==
ins
->
get_shape
())
{
return
true
;
}
auto
outputs
=
ins
->
outputs
();
auto
outputs
=
ins
->
outputs
();
// If the current instruction has no output, it means it is the last
// If the current instruction has no output, it means it is the last
// instruction and generates a non-standard output. But for unary
// instruction and generates a non-standard output. But for unary
...
...
src/include/migraphx/op/binary.hpp
View file @
d7ba7f44
...
@@ -21,7 +21,7 @@ struct binary
...
@@ -21,7 +21,7 @@ struct binary
shape
compute_shape
(
std
::
vector
<
shape
>
inputs
)
const
shape
compute_shape
(
std
::
vector
<
shape
>
inputs
)
const
{
{
check_shapes
{
inputs
}.
has
(
2
).
same_type
().
same_dims
();
check_shapes
{
inputs
}.
has
(
2
).
same_type
().
same_dims
();
return
{
inputs
.
at
(
0
)
.
type
(),
inputs
.
at
(
0
).
lens
()}
;
return
inputs
.
at
(
0
);
}
}
};
};
...
...
src/include/migraphx/op/unary.hpp
View file @
d7ba7f44
...
@@ -21,7 +21,7 @@ struct unary
...
@@ -21,7 +21,7 @@ struct unary
shape
compute_shape
(
std
::
vector
<
shape
>
inputs
)
const
shape
compute_shape
(
std
::
vector
<
shape
>
inputs
)
const
{
{
check_shapes
{
inputs
}.
has
(
1
);
check_shapes
{
inputs
}.
has
(
1
);
return
{
inputs
.
at
(
0
)
.
type
(),
inputs
.
at
(
0
).
lens
()}
;
return
inputs
.
at
(
0
);
}
}
};
};
...
...
test/eliminate_contiguous_test.cpp
View file @
d7ba7f44
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
#include <migraphx/dead_code_elimination.hpp>
#include <migraphx/dead_code_elimination.hpp>
#include <migraphx/op/identity.hpp>
#include <migraphx/op/identity.hpp>
#include <migraphx/op/dot.hpp>
#include <migraphx/op/dot.hpp>
#include <migraphx/op/add.hpp>
#include <migraphx/op/transpose.hpp>
#include <migraphx/op/transpose.hpp>
#include <migraphx/op/contiguous.hpp>
#include <migraphx/op/contiguous.hpp>
#include <basic_ops.hpp>
#include <basic_ops.hpp>
...
@@ -54,4 +55,17 @@ TEST_CASE(transpose_gemm)
...
@@ -54,4 +55,17 @@ TEST_CASE(transpose_gemm)
EXPECT
(
std
::
distance
(
p
.
begin
(),
p
.
end
())
==
(
count
-
1
));
EXPECT
(
std
::
distance
(
p
.
begin
(),
p
.
end
())
==
(
count
-
1
));
}
}
TEST_CASE
(
transpose_standard_op
)
{
migraphx
::
program
p
;
auto
l
=
p
.
add_literal
(
get_2x2
());
auto
t
=
p
.
add_instruction
(
migraphx
::
op
::
transpose
{{
1
,
0
}},
l
);
auto
c
=
p
.
add_instruction
(
migraphx
::
op
::
contiguous
{},
t
);
auto
sum
=
p
.
add_instruction
(
migraphx
::
op
::
add
{},
c
,
c
);
p
.
add_instruction
(
pass_standard_op
{},
sum
);
auto
count
=
std
::
distance
(
p
.
begin
(),
p
.
end
());
p
.
compile
(
eliminate_contiguous_target
{});
EXPECT
(
std
::
distance
(
p
.
begin
(),
p
.
end
())
==
count
);
}
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