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
40bab788
Commit
40bab788
authored
Apr 30, 2021
by
Paul
Browse files
Formatting
parent
a851f699
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
27 deletions
+27
-27
src/include/migraphx/algorithm.hpp
src/include/migraphx/algorithm.hpp
+9
-9
src/program.cpp
src/program.cpp
+18
-18
No files found.
src/include/migraphx/algorithm.hpp
100755 → 100644
View file @
40bab788
...
@@ -10,15 +10,15 @@ inline namespace MIGRAPHX_INLINE_NS {
...
@@ -10,15 +10,15 @@ inline namespace MIGRAPHX_INLINE_NS {
template
<
class
Iterator
,
class
Output
,
class
Predicate
,
class
F
>
template
<
class
Iterator
,
class
Output
,
class
Predicate
,
class
F
>
void
transform_if
(
Iterator
start
,
Iterator
last
,
Output
out
,
Predicate
pred
,
F
f
)
void
transform_if
(
Iterator
start
,
Iterator
last
,
Output
out
,
Predicate
pred
,
F
f
)
{
{
while
(
start
!=
last
)
while
(
start
!=
last
)
{
{
if
(
pred
(
*
start
))
if
(
pred
(
*
start
))
{
{
*
out
=
f
(
*
start
);
*
out
=
f
(
*
start
);
++
out
;
++
out
;
}
}
++
start
;
++
start
;
}
}
}
}
template
<
class
Iterator
,
class
Output
,
class
Predicate
>
template
<
class
Iterator
,
class
Output
,
class
Predicate
>
...
...
src/program.cpp
100755 → 100644
View file @
40bab788
...
@@ -65,10 +65,11 @@ void program::assign(const program& p)
...
@@ -65,10 +65,11 @@ void program::assign(const program& p)
// build a map from old ins to new ins
// build a map from old ins to new ins
// Build a map from old module to new module
// Build a map from old module to new module
std
::
unordered_map
<
module_ref
,
module_ref
>
mod_map
;
std
::
unordered_map
<
module_ref
,
module_ref
>
mod_map
;
std
::
transform
(
impl
->
modules
.
begin
(),
std
::
transform
(
impl
->
modules
.
end
(),
impl
->
modules
.
begin
(),
std
::
inserter
(
mod_map
,
mod_map
.
begin
()),
impl
->
modules
.
end
(),
[
&
](
auto
&&
xp
)
{
return
std
::
make_pair
(
&
p
.
impl
->
modules
.
at
(
xp
.
first
),
&
xp
.
second
);
});
std
::
inserter
(
mod_map
,
mod_map
.
begin
()),
[
&
](
auto
&&
xp
)
{
return
std
::
make_pair
(
&
p
.
impl
->
modules
.
at
(
xp
.
first
),
&
xp
.
second
);
});
std
::
unordered_map
<
instruction_ref
,
instruction_ref
>
ins_map
;
std
::
unordered_map
<
instruction_ref
,
instruction_ref
>
ins_map
;
for
(
auto
&&
pp
:
mod_map
)
for
(
auto
&&
pp
:
mod_map
)
...
@@ -457,9 +458,10 @@ void program::from_value(const value& v)
...
@@ -457,9 +458,10 @@ void program::from_value(const value& v)
impl
->
modules
.
emplace
(
name
,
name
);
impl
->
modules
.
emplace
(
name
,
name
);
}
}
std
::
unordered_map
<
std
::
string
,
module_ref
>
map_mods
;
std
::
unordered_map
<
std
::
string
,
module_ref
>
map_mods
;
std
::
transform
(
impl
->
modules
.
begin
(),
impl
->
modules
.
end
(),
std
::
inserter
(
map_mods
,
map_mods
.
end
()),
[
&
](
auto
&&
pp
)
{
std
::
transform
(
impl
->
modules
.
begin
(),
return
std
::
make_pair
(
pp
.
first
,
&
pp
.
second
);
impl
->
modules
.
end
(),
});
std
::
inserter
(
map_mods
,
map_mods
.
end
()),
[
&
](
auto
&&
pp
)
{
return
std
::
make_pair
(
pp
.
first
,
&
pp
.
second
);
});
std
::
unordered_map
<
std
::
string
,
instruction_ref
>
map_insts
;
std
::
unordered_map
<
std
::
string
,
instruction_ref
>
map_insts
;
auto
*
mm
=
get_main_module
();
auto
*
mm
=
get_main_module
();
...
@@ -650,10 +652,7 @@ void program::annotate(std::ostream& os, const std::function<void(instruction_re
...
@@ -650,10 +652,7 @@ void program::annotate(std::ostream& os, const std::function<void(instruction_re
}
}
}
}
const
module
*
program
::
get_module
(
const
std
::
string
&
name
)
const
const
module
*
program
::
get_module
(
const
std
::
string
&
name
)
const
{
return
&
impl
->
modules
.
at
(
name
);
}
{
return
&
impl
->
modules
.
at
(
name
);
}
module
*
program
::
create_module
(
const
std
::
string
&
name
)
module
*
program
::
create_module
(
const
std
::
string
&
name
)
{
{
...
@@ -661,16 +660,13 @@ module* program::create_module(const std::string& name)
...
@@ -661,16 +660,13 @@ module* program::create_module(const std::string& name)
return
&
(
r
.
first
->
second
);
return
&
(
r
.
first
->
second
);
}
}
module
*
program
::
get_module
(
const
std
::
string
&
name
)
module
*
program
::
get_module
(
const
std
::
string
&
name
)
{
return
&
impl
->
modules
.
at
(
name
);
}
{
return
&
impl
->
modules
.
at
(
name
);
}
module
*
program
::
get_main_module
()
{
return
get_module
(
"main"
);
}
module
*
program
::
get_main_module
()
{
return
get_module
(
"main"
);
}
const
module
*
program
::
get_main_module
()
const
{
return
get_module
(
"main"
);
}
const
module
*
program
::
get_main_module
()
const
{
return
get_module
(
"main"
);
}
template
<
class
T
>
template
<
class
T
>
std
::
vector
<
T
*>
generic_get_modules
(
T
*
mm
)
std
::
vector
<
T
*>
generic_get_modules
(
T
*
mm
)
{
{
std
::
vector
<
T
*>
vec_modules
;
std
::
vector
<
T
*>
vec_modules
;
...
@@ -680,14 +676,18 @@ std::vector<T*> generic_get_modules(T* mm)
...
@@ -680,14 +676,18 @@ std::vector<T*> generic_get_modules(T* mm)
return
vec_modules
;
return
vec_modules
;
}
}
template
<
class
Map
,
class
T
,
class
OutputIterator
>
template
<
class
Map
,
class
T
,
class
OutputIterator
>
void
generic_get_unused_modules
(
Map
&
m
,
const
std
::
vector
<
T
*>&
mods
,
OutputIterator
out
)
void
generic_get_unused_modules
(
Map
&
m
,
const
std
::
vector
<
T
*>&
mods
,
OutputIterator
out
)
{
{
std
::
unordered_set
<
std
::
string
>
used
;
std
::
unordered_set
<
std
::
string
>
used
;
std
::
transform
(
mods
.
begin
(),
mods
.
end
(),
std
::
inserter
(
used
,
used
.
end
()),
[](
auto
&&
mod
)
{
std
::
transform
(
mods
.
begin
(),
mods
.
end
(),
std
::
inserter
(
used
,
used
.
end
()),
[](
auto
&&
mod
)
{
return
mod
->
name
();
return
mod
->
name
();
});
});
transform_if
(
m
.
begin
(),
m
.
end
(),
out
,
[
&
](
auto
&&
pp
){
return
not
contains
(
used
,
pp
.
first
);
},
[](
auto
&&
pp
)
{
return
&
pp
.
second
;
});
transform_if
(
m
.
begin
(),
m
.
end
(),
out
,
[
&
](
auto
&&
pp
)
{
return
not
contains
(
used
,
pp
.
first
);
},
[](
auto
&&
pp
)
{
return
&
pp
.
second
;
});
}
}
std
::
vector
<
const
module
*>
program
::
get_modules
()
const
std
::
vector
<
const
module
*>
program
::
get_modules
()
const
...
...
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