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
c87f5621
Commit
c87f5621
authored
Jul 01, 2019
by
Paul
Browse files
Formatting
parent
fa485ae6
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
28 additions
and
37 deletions
+28
-37
src/driver/main.cpp
src/driver/main.cpp
+14
-13
src/include/migraphx/functional.hpp
src/include/migraphx/functional.hpp
+1
-1
src/include/migraphx/matcher.hpp
src/include/migraphx/matcher.hpp
+8
-14
src/simplify_reshapes.cpp
src/simplify_reshapes.cpp
+1
-5
src/targets/gpu/fuse_ops.cpp
src/targets/gpu/fuse_ops.cpp
+4
-4
No files found.
src/driver/main.cpp
View file @
c87f5621
...
@@ -58,19 +58,20 @@ struct loader
...
@@ -58,19 +58,20 @@ struct loader
auto
last
=
std
::
prev
(
p
.
end
(),
trim
);
auto
last
=
std
::
prev
(
p
.
end
(),
trim
);
p
.
remove_instructions
(
last
,
p
.
end
());
p
.
remove_instructions
(
last
,
p
.
end
());
}
}
if
(
optimize
)
if
(
optimize
)
migraphx
::
run_passes
(
p
,
{
migraphx
::
run_passes
(
p
,
migraphx
::
eliminate_identity
{},
{
migraphx
::
dead_code_elimination
{},
migraphx
::
eliminate_identity
{},
migraphx
::
simplify_algebra
{},
migraphx
::
dead_code_elimination
{},
migraphx
::
dead_code_elimination
{},
migraphx
::
simplify_algebra
{},
migraphx
::
simplify_reshapes
{},
migraphx
::
dead_code_elimination
{},
migraphx
::
dead_code_elimination
{},
migraphx
::
simplify_reshapes
{},
migraphx
::
propagate_constant
{},
migraphx
::
dead_code_elimination
{},
migraphx
::
dead_code_elimination
{},
migraphx
::
propagate_constant
{},
migraphx
::
eliminate_pad
{},
migraphx
::
dead_code_elimination
{},
migraphx
::
dead_code_elimination
{},
migraphx
::
eliminate_pad
{},
});
migraphx
::
dead_code_elimination
{},
});
return
p
;
return
p
;
}
}
};
};
...
...
src/include/migraphx/functional.hpp
View file @
c87f5621
...
@@ -190,7 +190,7 @@ auto pop_back_args(Ts&&... xs)
...
@@ -190,7 +190,7 @@ auto pop_back_args(Ts&&... xs)
};
};
}
}
template
<
class
T
>
template
<
class
T
>
auto
always
(
T
x
)
auto
always
(
T
x
)
{
{
return
[
=
](
auto
&&
...)
{
return
x
;
};
return
[
=
](
auto
&&
...)
{
return
x
;
};
...
...
src/include/migraphx/matcher.hpp
View file @
c87f5621
...
@@ -242,7 +242,7 @@ void find_matches(program& p, Ms&&... ms)
...
@@ -242,7 +242,7 @@ void find_matches(program& p, Ms&&... ms)
struct
lazy_and
struct
lazy_and
{
{
template
<
class
F
,
class
G
>
template
<
class
F
,
class
G
>
bool
operator
()(
F
f
,
G
g
)
const
bool
operator
()(
F
f
,
G
g
)
const
{
{
return
f
()
and
g
();
return
f
()
and
g
();
...
@@ -251,7 +251,7 @@ struct lazy_and
...
@@ -251,7 +251,7 @@ struct lazy_and
struct
lazy_or
struct
lazy_or
{
{
template
<
class
F
,
class
G
>
template
<
class
F
,
class
G
>
bool
operator
()(
F
f
,
G
g
)
const
bool
operator
()(
F
f
,
G
g
)
const
{
{
return
f
()
or
g
();
return
f
()
or
g
();
...
@@ -266,12 +266,9 @@ struct folder
...
@@ -266,12 +266,9 @@ struct folder
{
{
return
make_bf_matcher
([
=
](
matcher_context
&
ctx
,
instruction_ref
ins
)
{
return
make_bf_matcher
([
=
](
matcher_context
&
ctx
,
instruction_ref
ins
)
{
Op
op
;
Op
op
;
auto
matched
=
[
&
](
auto
m
)
{
auto
matched
=
[
&
](
auto
m
)
{
return
[
&
]
{
return
ctx
.
matched
(
m
,
ins
);
};
};
return
[
&
]{
return
ctx
.
matched
(
m
,
ins
);
};
bool
matches
=
};
fold
([
&
](
auto
x
,
auto
y
)
{
return
op
(
always
(
x
),
matched
(
y
));
})(
Start
,
ms
...);
bool
matches
=
fold
([
&
](
auto
x
,
auto
y
)
{
return
op
(
always
(
x
),
matched
(
y
));
})(
Start
,
ms
...);
if
(
matches
==
Matches
)
if
(
matches
==
Matches
)
return
ins
;
return
ins
;
return
ctx
.
not_found
();
return
ctx
.
not_found
();
...
@@ -286,13 +283,10 @@ struct folder
...
@@ -286,13 +283,10 @@ struct folder
Op
op
;
Op
op
;
bool
matches
=
Start
;
bool
matches
=
Start
;
select
(
start
,
[
&
](
auto
ins
)
{
select
(
start
,
[
&
](
auto
ins
)
{
auto
matched
=
[
&
](
auto
m
)
{
auto
matched
=
[
&
](
auto
m
)
{
return
[
&
]
{
return
ctx
.
matched
(
m
,
ins
);
};
};
return
[
&
]{
return
ctx
.
matched
(
m
,
ins
);
};
};
auto
fold_match
=
[
&
]
{
auto
fold_match
=
[
&
]
{
return
fold
([
&
](
auto
x
,
auto
y
)
{
return
fold
([
&
](
auto
x
,
auto
y
)
{
return
op
(
always
(
x
),
matched
(
y
));
})(
return
op
(
always
(
x
),
matched
(
y
));
Start
,
ms
...);
})(
Start
,
ms
...);
};
};
matches
=
op
(
always
(
matches
),
fold_match
);
matches
=
op
(
always
(
matches
),
fold_match
);
});
});
...
...
src/simplify_reshapes.cpp
View file @
c87f5621
...
@@ -214,11 +214,7 @@ void simplify_reshapes::apply(program& p) const
...
@@ -214,11 +214,7 @@ void simplify_reshapes::apply(program& p) const
// Skip possible dead instructions
// Skip possible dead instructions
if
(
ins
->
outputs
().
empty
()
and
ins
!=
end
)
if
(
ins
->
outputs
().
empty
()
and
ins
!=
end
)
continue
;
continue
;
match
::
find_matches
(
p
,
match
::
find_matches
(
p
,
ins
,
find_nop_reshapes
{},
find_reshaper
{},
find_transpose
{}
ins
,
find_nop_reshapes
{},
find_reshaper
{},
find_transpose
{}
// find_concat_transpose{}
// find_concat_transpose{}
);
);
}
}
...
...
src/targets/gpu/fuse_ops.cpp
View file @
c87f5621
...
@@ -232,10 +232,10 @@ struct find_triadd
...
@@ -232,10 +232,10 @@ struct find_triadd
void
apply
(
program
&
p
,
match
::
matcher_result
r
)
const
void
apply
(
program
&
p
,
match
::
matcher_result
r
)
const
{
{
auto
add_ins
=
r
.
instructions
[
"add"
];
auto
add_ins
=
r
.
instructions
[
"add"
];
auto
input_ins
=
r
.
instructions
[
"input"
];
auto
input_ins
=
r
.
instructions
[
"input"
];
auto
ins
=
r
.
result
;
auto
ins
=
r
.
result
;
auto
args
=
add_ins
->
inputs
();
auto
args
=
add_ins
->
inputs
();
assert
(
add_ins
!=
input_ins
);
assert
(
add_ins
!=
input_ins
);
auto
is_broadcasted
=
[](
auto
arg
)
{
return
arg
->
get_shape
().
broadcasted
();
};
auto
is_broadcasted
=
[](
auto
arg
)
{
return
arg
->
get_shape
().
broadcasted
();
};
...
...
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