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
79ffac9f
Commit
79ffac9f
authored
May 24, 2022
by
Paul
Browse files
Format
parent
b7f31df5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
12 deletions
+14
-12
src/targets/gpu/mlir.cpp
src/targets/gpu/mlir.cpp
+8
-7
test/gpu/mlir.cpp
test/gpu/mlir.cpp
+6
-5
No files found.
src/targets/gpu/mlir.cpp
View file @
79ffac9f
...
@@ -486,11 +486,12 @@ struct mlir_program
...
@@ -486,11 +486,12 @@ struct mlir_program
// 2nd pipeline to call
// 2nd pipeline to call
std
::
string
tname
=
get_device_name
();
std
::
string
tname
=
get_device_name
();
// HACK: Since MLIR can't handle the full target name
// HACK: Since MLIR can't handle the full target name
auto
hacked_tname
=
tname
.
substr
(
0
,
tname
.
find
(
":"
));
auto
hacked_tname
=
tname
.
substr
(
0
,
tname
.
find
(
":"
));
if
(
tname
.
size
()
!=
hacked_tname
.
size
())
if
(
tname
.
size
()
!=
hacked_tname
.
size
())
std
::
cout
<<
"*************** WARNING: MLIR may not compile the correct target features for: "
<<
tname
<<
std
::
endl
;
std
::
cout
mlirMIGraphXAddBackendPipeline
(
<<
"*************** WARNING: MLIR may not compile the correct target features for: "
pm
.
get
(),
hacked_tname
.
c_str
(),
"amdgcn-amd-amdhsa"
,
""
);
<<
tname
<<
std
::
endl
;
mlirMIGraphXAddBackendPipeline
(
pm
.
get
(),
hacked_tname
.
c_str
(),
"amdgcn-amd-amdhsa"
,
""
);
mlirPassManagerRun
(
pm
.
get
(),
mmodule
.
get
());
mlirPassManagerRun
(
pm
.
get
(),
mmodule
.
get
());
code_object_op
op
;
code_object_op
op
;
...
@@ -537,12 +538,12 @@ std::string dump_mlir(const module& m)
...
@@ -537,12 +538,12 @@ std::string dump_mlir(const module& m)
code_object_op
compile_mlir
(
const
module
&
m
)
code_object_op
compile_mlir
(
const
module
&
m
)
{
{
const
bool
trace
=
enabled
(
MIGRAPHX_TRACE_MLIR
{});
const
bool
trace
=
enabled
(
MIGRAPHX_TRACE_MLIR
{});
if
(
trace
)
if
(
trace
)
std
::
cout
<<
m
<<
std
::
endl
;
std
::
cout
<<
m
<<
std
::
endl
;
mlir_program
mp
;
mlir_program
mp
;
mp
.
parse
(
m
);
mp
.
parse
(
m
);
auto
mod_op
=
mlirModuleGetOperation
(
mp
.
mmodule
.
get
());
auto
mod_op
=
mlirModuleGetOperation
(
mp
.
mmodule
.
get
());
if
(
trace
)
if
(
trace
)
std
::
cout
<<
mlir_print
(
&
mlirOperationPrint
,
mod_op
)
<<
std
::
endl
;
std
::
cout
<<
mlir_print
(
&
mlirOperationPrint
,
mod_op
)
<<
std
::
endl
;
return
mp
.
compile
();
return
mp
.
compile
();
}
}
...
...
test/gpu/mlir.cpp
View file @
79ffac9f
...
@@ -21,12 +21,11 @@ using migraphx::trim;
...
@@ -21,12 +21,11 @@ using migraphx::trim;
struct
mlir_gpu_target
:
migraphx
::
gpu
::
target
struct
mlir_gpu_target
:
migraphx
::
gpu
::
target
{
{
std
::
string
name
()
const
{
return
"mlir"
;
}
std
::
string
name
()
const
{
return
"mlir"
;
}
std
::
vector
<
migraphx
::
pass
>
get_passes
(
migraphx
::
context
&
gctx
,
const
migraphx
::
compile_options
&
)
const
std
::
vector
<
migraphx
::
pass
>
get_passes
(
migraphx
::
context
&
gctx
,
const
migraphx
::
compile_options
&
)
const
{
{
auto
&
ctx
=
migraphx
::
any_cast
<
migraphx
::
gpu
::
context
>
(
gctx
);
auto
&
ctx
=
migraphx
::
any_cast
<
migraphx
::
gpu
::
context
>
(
gctx
);
return
{
return
{
migraphx
::
gpu
::
write_literals
{
&
ctx
}};
migraphx
::
gpu
::
write_literals
{
&
ctx
}
};
}
}
};
};
...
@@ -60,7 +59,9 @@ migraphx::program create_program_from_mlir(const migraphx::module& mmlir)
...
@@ -60,7 +59,9 @@ migraphx::program create_program_from_mlir(const migraphx::module& mmlir)
std
::
transform
(
names
.
begin
(),
names
.
end
(),
std
::
back_inserter
(
inputs
),
[
&
](
const
auto
&
name
)
{
std
::
transform
(
names
.
begin
(),
names
.
end
(),
std
::
back_inserter
(
inputs
),
[
&
](
const
auto
&
name
)
{
return
mm
->
add_parameter
(
name
,
mmlir
.
get_parameter_shape
(
name
));
return
mm
->
add_parameter
(
name
,
mmlir
.
get_parameter_shape
(
name
));
});
});
std
::
sort
(
inputs
.
begin
(),
inputs
.
end
(),
migraphx
::
by
(
std
::
less
<>
{},
[](
auto
ins
)
{
return
to_string
(
ins
->
get_operator
());
}));
std
::
sort
(
inputs
.
begin
(),
inputs
.
end
(),
migraphx
::
by
(
std
::
less
<>
{},
[](
auto
ins
)
{
return
to_string
(
ins
->
get_operator
());
}));
inputs
.
push_back
(
mm
->
add_parameter
(
"output"
,
mmlir
.
get_output_shapes
().
front
()));
inputs
.
push_back
(
mm
->
add_parameter
(
"output"
,
mmlir
.
get_output_shapes
().
front
()));
migraphx
::
gpu
::
insert_mlir
(
*
mm
,
mm
->
end
(),
mmlir
,
inputs
);
migraphx
::
gpu
::
insert_mlir
(
*
mm
,
mm
->
end
(),
mmlir
,
inputs
);
...
...
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