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
4272fff1
Commit
4272fff1
authored
May 24, 2022
by
Paul
Browse files
Handle symetrical padding
parent
e872b1b7
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
4 deletions
+17
-4
src/targets/gpu/mlir.cpp
src/targets/gpu/mlir.cpp
+16
-1
test/gpu/mlir.cpp
test/gpu/mlir.cpp
+1
-3
No files found.
src/targets/gpu/mlir.cpp
View file @
4272fff1
...
@@ -421,6 +421,21 @@ struct mlir_program
...
@@ -421,6 +421,21 @@ struct mlir_program
return
"migraphx."
+
ins
->
name
();
return
"migraphx."
+
ins
->
name
();
}
}
static
value
get_operator_value
(
const
operation
&
op
)
{
auto
v
=
op
.
to_value
();
if
(
op
.
name
()
==
"convolution"
)
{
// Adjust symetrical padding
if
(
v
.
at
(
"padding"
).
size
()
==
v
.
at
(
"stride"
).
size
())
{
auto
padding
=
v
.
at
(
"padding"
);
std
::
copy
(
padding
.
begin
(),
padding
.
end
(),
std
::
back_inserter
(
v
.
at
(
"padding"
)));
}
}
return
v
;
}
static
shape
get_shape
(
instruction_ref
ins
)
static
shape
get_shape
(
instruction_ref
ins
)
{
{
if
(
ins
->
name
()
==
"@return"
)
if
(
ins
->
name
()
==
"@return"
)
...
@@ -442,7 +457,7 @@ struct mlir_program
...
@@ -442,7 +457,7 @@ struct mlir_program
continue
;
continue
;
auto
name
=
get_name
(
ins
);
auto
name
=
get_name
(
ins
);
auto
ops
=
create_operation_state
(
name
);
auto
ops
=
create_operation_state
(
name
);
ops
.
add_attribute_value
(
ins
->
get_operator
()
.
to_value
(
));
ops
.
add_attribute_value
(
get_operator_value
(
ins
->
get_operator
()));
if
(
ins
->
name
()
!=
"@return"
)
if
(
ins
->
name
()
!=
"@return"
)
ops
.
add_results
({
get_shape
(
ins
)});
ops
.
add_results
({
get_shape
(
ins
)});
...
...
test/gpu/mlir.cpp
View file @
4272fff1
...
@@ -111,9 +111,7 @@ module {
...
@@ -111,9 +111,7 @@ module {
migraphx
::
module
m
;
migraphx
::
module
m
;
auto
x
=
m
.
add_parameter
(
"x"
,
{
migraphx
::
shape
::
float_type
,
{
1
,
8
,
4
,
4
}});
auto
x
=
m
.
add_parameter
(
"x"
,
{
migraphx
::
shape
::
float_type
,
{
1
,
8
,
4
,
4
}});
auto
w
=
m
.
add_parameter
(
"w"
,
{
migraphx
::
shape
::
float_type
,
{
2
,
8
,
3
,
3
}});
auto
w
=
m
.
add_parameter
(
"w"
,
{
migraphx
::
shape
::
float_type
,
{
2
,
8
,
3
,
3
}});
auto
conv
=
auto
conv
=
m
.
add_instruction
(
migraphx
::
make_op
(
"convolution"
),
x
,
w
);
m
.
add_instruction
(
migraphx
::
make_op
(
"convolution"
,
{{
"padding"
,
{
0
,
0
,
0
,
0
}}}),
x
,
w
);
// auto conv = m.add_instruction(migraphx::make_op("convolution"), x, w);
m
.
add_return
({
conv
});
m
.
add_return
({
conv
});
auto
s
=
migraphx
::
gpu
::
dump_mlir
(
m
);
auto
s
=
migraphx
::
gpu
::
dump_mlir
(
m
);
// Skip test if MLIR is not enabled
// Skip test if MLIR is not enabled
...
...
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