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
8dffc0d5
Commit
8dffc0d5
authored
Feb 15, 2022
by
Shucai Xiao
Browse files
refine the implementation
parent
3541b5af
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
6 deletions
+28
-6
src/auto_contiguous.cpp
src/auto_contiguous.cpp
+18
-0
src/eliminate_contiguous.cpp
src/eliminate_contiguous.cpp
+0
-6
src/simplify_reshapes.cpp
src/simplify_reshapes.cpp
+10
-0
No files found.
src/auto_contiguous.cpp
View file @
8dffc0d5
...
...
@@ -46,6 +46,24 @@ void auto_contiguous::apply(module& p) const
p
.
replace_instruction
(
ins
,
c
);
}
}
// if ops used as output param are alias 0, add a contiguous for the output
// so return outputs with standard shape
if
(
last
->
name
()
==
"@return"
)
{
auto
inputs
=
last
->
inputs
();
for
(
auto
ins
:
inputs
)
{
if
(
ins
->
name
()
==
"contiguous"
)
continue
;
auto
ins_alias
=
ins
->
get_operator
().
output_alias
({});
if
(
ins_alias
==
0
)
{
auto
cont_ins
=
p
.
insert_instruction
(
last
,
make_op
(
"contiguous"
),
ins
);
p
.
replace_instruction
(
ins
,
cont_ins
);
}
}
}
}
}
// namespace MIGRAPHX_INLINE_NS
...
...
src/eliminate_contiguous.cpp
View file @
8dffc0d5
...
...
@@ -39,12 +39,6 @@ static bool try_compute_shape(instruction_ref ins,
return
false
;
}
if
(
std
::
any_of
(
outputs
.
begin
(),
outputs
.
end
(),
[](
auto
o
)
{
return
o
->
name
()
==
"@return"
;
}))
{
return
false
;
}
for
(
auto
output
:
outputs
)
{
auto
args
=
output
->
inputs
();
...
...
src/simplify_reshapes.cpp
View file @
8dffc0d5
...
...
@@ -120,6 +120,16 @@ struct find_nop_reshapes
void
apply
(
module
&
p
,
const
match
::
matcher_result
&
mr
)
const
{
auto
ins
=
mr
.
result
;
if
(
ins
->
name
()
==
"contiguous"
)
{
auto
&
outputs
=
ins
->
outputs
();
if
(
std
::
any_of
(
outputs
.
begin
(),
outputs
.
end
(),
[
&
](
auto
o
)
{
return
o
->
name
()
==
"@return"
;
}))
{
return
;
}
}
p
.
replace_instruction
(
ins
,
ins
->
inputs
().
front
());
}
};
...
...
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