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
247ce1d2
Commit
247ce1d2
authored
May 26, 2023
by
Paul
Browse files
Format
parent
17ee5428
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
24 deletions
+36
-24
src/targets/gpu/compiler.cpp
src/targets/gpu/compiler.cpp
+14
-10
src/targets/gpu/include/migraphx/gpu/compiler.hpp
src/targets/gpu/include/migraphx/gpu/compiler.hpp
+22
-14
No files found.
src/targets/gpu/compiler.cpp
View file @
247ce1d2
...
@@ -29,13 +29,13 @@ inline namespace MIGRAPHX_INLINE_NS {
...
@@ -29,13 +29,13 @@ inline namespace MIGRAPHX_INLINE_NS {
namespace
gpu
{
namespace
gpu
{
namespace
{
namespace
{
struct
compiler_handle
struct
compiler_handle
{
{
compiler_compile
compile
;
compiler_compile
compile
;
compiler_compile_op
compile_op
;
compiler_compile_op
compile_op
;
compiler_tuning_config
get_tuning_config
;
compiler_tuning_config
get_tuning_config
;
};
};
}
}
// namespace
auto
&
compiler_map
()
auto
&
compiler_map
()
{
{
...
@@ -43,13 +43,17 @@ auto& compiler_map()
...
@@ -43,13 +43,17 @@ auto& compiler_map()
return
m
;
return
m
;
}
}
void
register_compiler
(
const
std
::
string
&
name
,
compiler_compile
c
,
compiler_compile_op
cop
,
compiler_tuning_config
ctg
)
void
register_compiler
(
const
std
::
string
&
name
,
compiler_compile
c
,
compiler_compile_op
cop
,
compiler_tuning_config
ctg
)
{
{
compiler_map
()[
name
]
=
{
std
::
move
(
c
),
std
::
move
(
cop
),
std
::
move
(
ctg
)};
compiler_map
()[
name
]
=
{
std
::
move
(
c
),
std
::
move
(
cop
),
std
::
move
(
ctg
)};
}
}
bool
has_compiler_for
(
const
std
::
string
&
name
)
{
return
compiler_map
().
count
(
name
)
>
0
;
}
bool
has_compiler_for
(
const
std
::
string
&
name
)
{
return
compiler_map
().
count
(
name
)
>
0
;
}
compiler_replace
compile
(
context
&
ctx
,
instruction_ref
ins
,
const
operation
&
op
,
const
value
&
solution
)
compiler_replace
compile
(
context
&
ctx
,
instruction_ref
ins
,
const
operation
&
op
,
const
value
&
solution
)
{
{
return
compiler_map
().
at
(
op
.
name
()).
compile
(
ctx
,
ins
,
op
,
solution
);
return
compiler_map
().
at
(
op
.
name
()).
compile
(
ctx
,
ins
,
op
,
solution
);
}
}
...
...
src/targets/gpu/include/migraphx/gpu/compiler.hpp
View file @
247ce1d2
...
@@ -74,20 +74,25 @@ struct tuning_config
...
@@ -74,20 +74,25 @@ struct tuning_config
std
::
vector
<
value
>
solutions
;
std
::
vector
<
value
>
solutions
;
};
};
using
compiler_compile
=
std
::
function
<
compiler_replace
(
context
&
,
instruction_ref
,
operation
,
const
value
&
)
>
;
using
compiler_compile
=
std
::
function
<
compiler_replace
(
context
&
,
instruction_ref
,
operation
,
const
value
&
)
>
;
using
compiler_compile_op
=
using
compiler_compile_op
=
std
::
function
<
operation
(
context
&
,
const
std
::
vector
<
shape
>&
inputs
,
const
value
&
)
>
;
std
::
function
<
operation
(
context
&
,
const
std
::
vector
<
shape
>&
inputs
,
const
value
&
)
>
;
using
compiler_tuning_config
=
std
::
function
<
optional
<
tuning_config
>
(
context
&
,
instruction_ref
,
const
operation
&
)
>
;
using
compiler_tuning_config
=
std
::
function
<
optional
<
tuning_config
>
(
context
&
,
instruction_ref
,
const
operation
&
)
>
;
void
register_compiler
(
const
std
::
string
&
name
,
compiler_compile
c
,
compiler_compile_op
cop
,
compiler_tuning_config
ctg
);
void
register_compiler
(
const
std
::
string
&
name
,
compiler_compile
c
,
compiler_compile_op
cop
,
compiler_tuning_config
ctg
);
bool
has_compiler_for
(
const
std
::
string
&
name
);
bool
has_compiler_for
(
const
std
::
string
&
name
);
compiler_replace
compile
(
context
&
ctx
,
instruction_ref
ins
,
const
operation
&
op
,
const
value
&
solution
);
compiler_replace
compile
(
context
&
ctx
,
instruction_ref
ins
,
const
operation
&
op
,
const
value
&
solution
);
operation
operation
compile_op
(
const
std
::
string
&
name
,
context
&
ctx
,
const
std
::
vector
<
shape
>&
inputs
,
const
value
&
v
);
compile_op
(
const
std
::
string
&
name
,
context
&
ctx
,
const
std
::
vector
<
shape
>&
inputs
,
const
value
&
v
);
optional
<
tuning_config
>
get_tuning_config
(
context
&
ctx
,
instruction_ref
ins
,
const
operation
&
op
);
optional
<
tuning_config
>
get_tuning_config
(
context
&
ctx
,
instruction_ref
ins
,
const
operation
&
op
);
template
<
class
T
>
template
<
class
T
>
void
register_compiler
()
void
register_compiler
()
{
{
...
@@ -96,7 +101,9 @@ void register_compiler()
...
@@ -96,7 +101,9 @@ void register_compiler()
{
{
register_compiler
(
register_compiler
(
name
,
name
,
[
=
](
auto
&&
...
xs
)
{
return
c
.
invoke_compile
(
rank
<
1
>
{},
std
::
forward
<
decltype
(
xs
)
>
(
xs
)...);
},
[
=
](
auto
&&
...
xs
)
{
return
c
.
invoke_compile
(
rank
<
1
>
{},
std
::
forward
<
decltype
(
xs
)
>
(
xs
)...);
},
[
=
](
auto
&&
...
xs
)
{
return
c
.
compile_op
(
std
::
forward
<
decltype
(
xs
)
>
(
xs
)...);
},
[
=
](
auto
&&
...
xs
)
{
return
c
.
compile_op
(
std
::
forward
<
decltype
(
xs
)
>
(
xs
)...);
},
[
=
](
auto
&&
...
xs
)
{
return
c
.
get_tuning_config
(
std
::
forward
<
decltype
(
xs
)
>
(
xs
)...);
});
[
=
](
auto
&&
...
xs
)
{
return
c
.
get_tuning_config
(
std
::
forward
<
decltype
(
xs
)
>
(
xs
)...);
});
}
}
...
@@ -117,24 +124,25 @@ using auto_register_compiler = auto_register<register_compiler_action, T>;
...
@@ -117,24 +124,25 @@ using auto_register_compiler = auto_register<register_compiler_action, T>;
template
<
class
Derived
>
template
<
class
Derived
>
struct
compiler
:
auto_register_compiler
<
Derived
>
struct
compiler
:
auto_register_compiler
<
Derived
>
{
{
const
Derived
&
derived
()
const
const
Derived
&
derived
()
const
{
return
static_cast
<
const
Derived
&>
(
*
this
);
}
{
return
static_cast
<
const
Derived
&>
(
*
this
);
}
optional
<
tuning_config
>
get_tuning_config
(
context
&
,
instruction_ref
,
const
operation
&
)
const
optional
<
tuning_config
>
get_tuning_config
(
context
&
,
instruction_ref
,
const
operation
&
)
const
{
{
return
nullopt
;
return
nullopt
;
}
}
operation
compile_op
(
context
&
,
const
std
::
vector
<
shape
>&
,
const
value
&
)
const
{
return
{};
}
operation
compile_op
(
context
&
,
const
std
::
vector
<
shape
>&
,
const
value
&
)
const
{
return
{};
}
template
<
class
D
=
Derived
>
template
<
class
D
=
Derived
>
auto
invoke_compile
(
rank
<
1
>
,
context
&
ctx
,
instruction_ref
ins
,
operation
op
,
const
value
&
solution
)
const
->
decltype
(
std
::
declval
<
D
>
().
compile
(
ctx
,
ins
,
std
::
move
(
op
),
solution
))
auto
invoke_compile
(
rank
<
1
>
,
context
&
ctx
,
instruction_ref
ins
,
operation
op
,
const
value
&
solution
)
const
->
decltype
(
std
::
declval
<
D
>
().
compile
(
ctx
,
ins
,
std
::
move
(
op
),
solution
))
{
{
return
derived
().
compile
(
ctx
,
ins
,
std
::
move
(
op
),
solution
);
return
derived
().
compile
(
ctx
,
ins
,
std
::
move
(
op
),
solution
);
}
}
template
<
class
D
=
Derived
>
template
<
class
D
=
Derived
>
auto
invoke_compile
(
rank
<
0
>
,
context
&
ctx
,
instruction_ref
ins
,
operation
op
,
const
value
&
solution
)
const
->
decltype
(
std
::
declval
<
D
>
().
compile
(
ctx
,
ins
,
std
::
move
(
op
)))
auto
invoke_compile
(
rank
<
0
>
,
context
&
ctx
,
instruction_ref
ins
,
operation
op
,
const
value
&
solution
)
const
->
decltype
(
std
::
declval
<
D
>
().
compile
(
ctx
,
ins
,
std
::
move
(
op
)))
{
{
assert
(
solution
.
empty
());
assert
(
solution
.
empty
());
(
void
)
solution
;
(
void
)
solution
;
...
...
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