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
0ac5a5d5
Commit
0ac5a5d5
authored
Aug 04, 2023
by
Khalique Ahmed
Browse files
changed auto contiguous to no longer check shape, move after optimize_module
parent
e46a6a52
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
27 deletions
+42
-27
src/auto_contiguous.cpp
src/auto_contiguous.cpp
+40
-26
src/targets/gpu/target.cpp
src/targets/gpu/target.cpp
+2
-1
No files found.
src/auto_contiguous.cpp
View file @
0ac5a5d5
...
...
@@ -33,43 +33,57 @@ inline namespace MIGRAPHX_INLINE_NS {
void
auto_contiguous
::
apply
(
module
&
m
)
const
{
std
::
string
key
=
"require_std_shape"
;
for
(
auto
ins
:
reverse_iterator_for
(
m
))
{
auto
&&
attr
=
ins
->
get_operator
().
attributes
();
if
((
attr
.
get
(
key
,
false
)))
{
auto
args
=
ins
->
inputs
();
auto
new_args
=
args
;
std
::
transform
(
args
.
begin
(),
args
.
end
(),
new_args
.
begin
(),
[
&
](
auto
in
)
{
if
(
in
->
name
()
==
"contiguous"
)
{
return
in
;
}
return
m
.
insert_instruction
(
ins
,
make_op
(
"contiguous"
),
in
);
});
//
std::string key = "require_std_shape";
//
for(auto ins : reverse_iterator_for(m))
//
{
//
auto&& attr = ins->get_operator().attributes();
//
if((attr.get(key, false)))
//
{
//
auto args = ins->inputs();
//
auto new_args = args;
//
std::transform(args.begin(), args.end(), new_args.begin(), [&](auto in) {
//
if(in->name() == "contiguous")
//
{
//
return in;
//
}
//
return m.insert_instruction(ins, make_op("contiguous"), in);
//
});
if
(
new_args
!=
args
)
{
m
.
replace_instruction
(
ins
,
ins
->
get_operator
(),
new_args
);
}
}
}
//
if(new_args != args)
//
{
//
m.replace_instruction(ins, ins->get_operator(), new_args);
//
}
//
}
//
}
auto
last
=
std
::
prev
(
m
.
end
());
for
(
auto
ins
:
iterator_for
(
m
))
{
if
(
ins
->
name
()
==
"layout"
)
if
(
ins
->
name
()
==
"layout"
or
ins
->
name
()
==
"contiguous"
)
continue
;
// for last instruction that is NOT a return
if
(
ins
->
outputs
().
empty
()
and
ins
!=
last
)
continue
;
shape
s
=
ins
->
get_shape
();
if
(
not
s
.
dynamic
()
and
not
s
.
standard
()
and
s
.
elements
()
!=
0
)
auto
args
=
ins
->
inputs
();
auto
new_args
=
args
;
std
::
transform
(
args
.
begin
(),
args
.
end
(),
new_args
.
begin
(),
[
&
](
auto
in
)
{
if
(
in
->
name
()
==
"contiguous"
or
in
->
name
()
==
"layout"
)
{
return
in
;
}
return
m
.
insert_instruction
(
ins
,
make_op
(
"contiguous"
),
in
);
});
if
(
new_args
!=
args
)
{
auto
c
=
m
.
insert_instruction
(
std
::
next
(
ins
),
make_op
(
"contiguous"
),
ins
);
m
.
replace_instruction
(
ins
,
c
);
m
.
replace_instruction
(
ins
,
ins
->
get_operator
(),
new_args
);
}
// shape s = ins->get_shape();
// if(not s.dynamic() and not s.standard() and s.elements() != 0)
// {
// auto c = m.insert_instruction(std::next(ins), make_op("contiguous"), ins);
// m.replace_instruction(ins, c);
// }
}
}
...
...
src/targets/gpu/target.cpp
View file @
0ac5a5d5
...
...
@@ -132,8 +132,9 @@ std::vector<pass> target::get_passes(migraphx::context& gctx, const compile_opti
dead_code_elimination
{},
prefuse_ops
{},
dead_code_elimination
{},
auto_contiguous
{},
//
auto_contiguous{},
optimize_module
{},
auto_contiguous
{},
fuse_pointwise
{},
dead_code_elimination
{},
enable_pass
(
not
enabled
(
MIGRAPHX_DISABLE_REDUCE_FUSION
{}),
fuse_reduce
{}),
...
...
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