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
23546ab5
Commit
23546ab5
authored
Jul 20, 2021
by
Khalique
Browse files
add contiguous to flatten
parent
eacf042e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
2 deletions
+15
-2
src/include/migraphx/op/flatten.hpp
src/include/migraphx/op/flatten.hpp
+1
-1
src/onnx/parse_generic_op.cpp
src/onnx/parse_generic_op.cpp
+1
-1
test/eliminate_contiguous_test.cpp
test/eliminate_contiguous_test.cpp
+13
-0
No files found.
src/include/migraphx/op/flatten.hpp
View file @
23546ab5
...
@@ -39,7 +39,7 @@ struct flatten
...
@@ -39,7 +39,7 @@ struct flatten
std
::
string
name
()
const
{
return
"flatten"
;
}
std
::
string
name
()
const
{
return
"flatten"
;
}
shape
normalize_compute_shape
(
std
::
vector
<
shape
>
inputs
)
const
shape
normalize_compute_shape
(
std
::
vector
<
shape
>
inputs
)
const
{
{
check_shapes
{
inputs
,
*
this
}.
has
(
1
);
check_shapes
{
inputs
,
*
this
}.
has
(
1
)
.
standard
()
;
auto
&&
lens
=
inputs
.
front
().
lens
();
auto
&&
lens
=
inputs
.
front
().
lens
();
auto
x
=
auto
x
=
std
::
accumulate
(
lens
.
begin
(),
lens
.
begin
()
+
axis
,
std
::
size_t
{
1
},
std
::
multiplies
<>
{});
std
::
accumulate
(
lens
.
begin
(),
lens
.
begin
()
+
axis
,
std
::
size_t
{
1
},
std
::
multiplies
<>
{});
...
...
src/onnx/parse_generic_op.cpp
View file @
23546ab5
...
@@ -47,7 +47,7 @@ struct parse_generic_op : op_parser<parse_generic_op>
...
@@ -47,7 +47,7 @@ struct parse_generic_op : op_parser<parse_generic_op>
bool
needs_contiguous
(
const
std
::
string
&
op_name
)
const
bool
needs_contiguous
(
const
std
::
string
&
op_name
)
const
{
{
return
contains
({
"gather"
},
op_name
);
return
contains
({
"flatten"
,
"gather"
},
op_name
);
}
}
instruction_ref
parse
(
const
op_desc
&
opd
,
instruction_ref
parse
(
const
op_desc
&
opd
,
...
...
test/eliminate_contiguous_test.cpp
View file @
23546ab5
...
@@ -131,4 +131,17 @@ TEST_CASE(non_standard_return_input)
...
@@ -131,4 +131,17 @@ TEST_CASE(non_standard_return_input)
EXPECT
(
std
::
distance
(
m
.
begin
(),
m
.
end
())
==
count
);
EXPECT
(
std
::
distance
(
m
.
begin
(),
m
.
end
())
==
count
);
}
}
TEST_CASE
(
non_standard_flatten_op
)
{
migraphx
::
module
m
;
auto
l
=
m
.
add_parameter
(
"x"
,
{
migraphx
::
shape
::
float_type
,
{
2
,
6
,
6
,
6
}});
auto
t
=
m
.
add_instruction
(
migraphx
::
make_op
(
"slice"
,
{{
"axes"
,
{
2
,
3
}},
{
"starts"
,
{
1
,
1
}},
{
"ends"
,
{
6
,
6
}}}),
l
);
auto
c
=
m
.
add_instruction
(
migraphx
::
make_op
(
"contiguous"
),
t
);
m
.
add_instruction
(
migraphx
::
make_op
(
"flatten"
),
c
);
auto
count
=
std
::
distance
(
m
.
begin
(),
m
.
end
());
run_pass
(
m
);
EXPECT
(
std
::
distance
(
m
.
begin
(),
m
.
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