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
90967138
Commit
90967138
authored
Oct 11, 2023
by
Khalique Ahmed
Browse files
update to remove extra contiguous by requires_std_shape, update tests
parent
e7e73c8c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
7 deletions
+12
-7
src/auto_contiguous.cpp
src/auto_contiguous.cpp
+9
-3
test/auto_contiguous_test.cpp
test/auto_contiguous_test.cpp
+3
-4
No files found.
src/auto_contiguous.cpp
View file @
90967138
...
...
@@ -61,9 +61,15 @@ void auto_contiguous::apply(module& m) const
{
if
(
contains
({
"layout"
,
"contiguous"
,
"@return"
,
"@param"
,
"@outline"
},
ins
->
name
()))
continue
;
auto
outputs
=
ins
->
outputs
();
// for last instruction that is NOT a return
if
(
ins
->
outputs
()
.
empty
()
and
ins
!=
last
)
if
(
outputs
.
empty
()
and
ins
!=
last
)
continue
;
if
(
not
outputs
.
empty
())
// if contiguous was already inserted, skip
if
(
std
::
all_of
(
outputs
.
begin
(),
outputs
.
end
(),
[](
auto
output
)
{
return
output
->
name
()
==
"contiguous"
;}))
continue
;
shape
s
=
ins
->
get_shape
();
if
(
s
.
dynamic
())
continue
;
...
...
@@ -72,9 +78,9 @@ void auto_contiguous::apply(module& m) const
if
(
s
.
standard
()
and
ins
->
name
()
==
"@literal"
)
continue
;
if
(
s
.
scalar
()
and
not
contains
(
ins
->
name
(),
"broadcast"
))
{
continue
;
}
auto
c
=
m
.
insert_instruction
(
std
::
next
(
ins
),
make_op
(
"contiguous"
),
ins
);
m
.
replace_instruction
(
ins
,
c
);
}
...
...
test/auto_contiguous_test.cpp
View file @
90967138
...
...
@@ -179,7 +179,8 @@ TEST_CASE(standard_reshape_lazy)
auto
ca
=
m2
.
add_instruction
(
migraphx
::
make_op
(
"contiguous"
),
add
);
auto
r
=
m2
.
add_instruction
(
migraphx
::
make_op
(
"reshape_lazy"
,
{{
"dims"
,
{
2
,
1
,
12
,
5
}}}),
ca
);
m2
.
add_return
({
r
});
auto
cr
=
m2
.
add_instruction
(
migraphx
::
make_op
(
"contiguous"
),
r
);
m2
.
add_return
({
cr
});
}
EXPECT
(
m1
==
m2
);
...
...
@@ -201,9 +202,7 @@ TEST_CASE(standard_reshape)
auto
data
=
m2
.
add_parameter
(
"2x2"
,
{
migraphx
::
shape
::
float_type
,
{
2
,
3
,
4
,
5
}});
auto
add
=
m2
.
add_instruction
(
migraphx
::
make_op
(
"add"
),
data
,
data
);
auto
ca
=
m2
.
add_instruction
(
migraphx
::
make_op
(
"contiguous"
),
add
);
// extra contiguous coming from reshape logic which has "requires_std_shape" attribute
auto
cb
=
m2
.
add_instruction
(
migraphx
::
make_op
(
"contiguous"
),
ca
);
auto
r
=
m2
.
add_instruction
(
migraphx
::
make_op
(
"reshape"
,
{{
"dims"
,
{
2
,
1
,
12
,
5
}}}),
cb
);
auto
r
=
m2
.
add_instruction
(
migraphx
::
make_op
(
"reshape"
,
{{
"dims"
,
{
2
,
1
,
12
,
5
}}}),
ca
);
auto
cr
=
m2
.
add_instruction
(
migraphx
::
make_op
(
"contiguous"
),
r
);
m2
.
add_return
({
cr
});
}
...
...
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