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
8291137e
"examples/vscode:/vscode.git/clone" did not exist on "a92ae3688afad51245d135a3f361fb7e20364d6d"
Unverified
Commit
8291137e
authored
Aug 22, 2023
by
Paul Fultz II
Committed by
GitHub
Aug 22, 2023
Browse files
Fix bug in eliminate_contiguous for operators that have module inputs (#2071)
parent
e3877a81
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
3 deletions
+35
-3
src/eliminate_contiguous.cpp
src/eliminate_contiguous.cpp
+1
-1
test/eliminate_contiguous_test.cpp
test/eliminate_contiguous_test.cpp
+34
-2
No files found.
src/eliminate_contiguous.cpp
View file @
8291137e
...
...
@@ -80,7 +80,7 @@ static bool try_compute_shape(instruction_ref ins,
return
(
arg
==
ins
)
?
new_shape
:
arg
->
get_shape
();
});
if
(
not
try_compute_shape
(
output
,
input_shapes
,
mods
))
if
(
not
try_compute_shape
(
output
,
input_shapes
,
output
->
module_inputs
()
))
{
return
false
;
}
...
...
test/eliminate_contiguous_test.cpp
View file @
8291137e
...
...
@@ -196,15 +196,47 @@ TEST_CASE(contiguous_pointwise)
migraphx
::
make_op
(
"broadcast"
,
{{
"axis"
,
1
},
{
"out_lens"
,
{
2
,
3
,
8
,
8
}}}),
y
);
auto
yc
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"contiguous"
),
yb
);
auto
add
=
add_pointwise
(
p
,
"main:pointwise0"
,
{
x
,
yc
},
single_pointwise
(
"add"
));
mm
->
add_instruction
(
pass_op
{},
add
);
auto
cadd
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"contiguous"
),
add
);
mm
->
add_instruction
(
pass_op
{},
cadd
);
}
auto
count
=
std
::
distance
(
mm
->
begin
(),
mm
->
end
());
run_pass
(
*
mm
);
EXPECT
(
std
::
distance
(
mm
->
begin
(),
mm
->
end
())
==
(
count
-
1
));
EXPECT
(
std
::
distance
(
mm
->
begin
(),
mm
->
end
())
==
(
count
-
2
));
EXPECT
(
std
::
none_of
(
mm
->
begin
(),
mm
->
end
(),
[](
auto
&&
ins
)
{
return
ins
.
name
()
==
"contiguous"
;
}));
}
TEST_CASE
(
contiguous_nhwc_pointwise
)
{
auto
s
=
migraphx
::
shape
::
from_permutation
(
migraphx
::
shape
::
float_type
,
{
2
,
3
,
8
,
8
},
{
0
,
2
,
3
,
1
});
migraphx
::
program
p1
;
{
auto
*
mm
=
p1
.
get_main_module
();
auto
x
=
mm
->
add_parameter
(
"x"
,
s
);
auto
y
=
mm
->
add_parameter
(
"y"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
3
}});
auto
yb
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"broadcast"
,
{{
"axis"
,
1
},
{
"out_lens"
,
{
2
,
3
,
8
,
8
}}}),
y
);
auto
yc
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"contiguous"
),
yb
);
auto
add
=
add_pointwise
(
p1
,
"main:pointwise0"
,
{
x
,
yc
},
single_pointwise
(
"add"
));
auto
cadd
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"contiguous"
),
add
);
mm
->
add_instruction
(
pass_op
{},
cadd
);
}
run_pass
(
*
p1
.
get_main_module
());
migraphx
::
program
p2
;
{
auto
*
mm
=
p2
.
get_main_module
();
auto
x
=
mm
->
add_parameter
(
"x"
,
s
);
auto
y
=
mm
->
add_parameter
(
"y"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
3
}});
auto
yb
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"broadcast"
,
{{
"axis"
,
1
},
{
"out_lens"
,
{
2
,
3
,
8
,
8
}}}),
y
);
auto
add
=
add_pointwise
(
p2
,
"main:pointwise0"
,
{
x
,
yb
},
single_pointwise
(
"add"
));
auto
cadd
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"contiguous"
),
add
);
mm
->
add_instruction
(
pass_op
{},
cadd
);
}
EXPECT
(
p1
==
p2
);
}
TEST_CASE
(
slice_contiguous
)
{
migraphx
::
module
m
;
...
...
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