Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
gaoqiong
MIGraphX
Commits
3cb4edfe
Commit
3cb4edfe
authored
Jul 02, 2019
by
Paul
Browse files
Try to fix ice on gcc 5
parent
8c8e5fb0
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
and
11 deletions
+39
-11
src/include/migraphx/functional.hpp
src/include/migraphx/functional.hpp
+12
-1
src/include/migraphx/matcher.hpp
src/include/migraphx/matcher.hpp
+13
-10
test/matcher.cpp
test/matcher.cpp
+14
-0
No files found.
src/include/migraphx/functional.hpp
View file @
3cb4edfe
...
@@ -190,10 +190,21 @@ auto pop_back_args(Ts&&... xs)
...
@@ -190,10 +190,21 @@ auto pop_back_args(Ts&&... xs)
};
};
}
}
template
<
class
T
>
struct
always_f
{
T
x
;
template
<
class
...
Ts
>
constexpr
T
operator
()(
Ts
&&
...)
const
{
return
x
;
}
};
template
<
class
T
>
template
<
class
T
>
auto
always
(
T
x
)
auto
always
(
T
x
)
{
{
return
[
=
](
auto
&&
...)
{
return
x
;
};
return
always_f
<
T
>
{
x
};
}
}
}
// namespace MIGRAPHX_INLINE_NS
}
// namespace MIGRAPHX_INLINE_NS
...
...
src/include/migraphx/matcher.hpp
View file @
3cb4edfe
...
@@ -261,14 +261,21 @@ struct lazy_or
...
@@ -261,14 +261,21 @@ struct lazy_or
template
<
class
Op
,
bool
Start
,
bool
Matches
>
template
<
class
Op
,
bool
Start
,
bool
Matches
>
struct
folder
struct
folder
{
{
template
<
class
...
Ms
>
static
bool
fold_match
(
matcher_context
&
ctx
,
instruction_ref
ins
,
Ms
...
ms
)
{
Op
op
;
auto
matched
=
[
&
](
auto
m
)
{
return
[
&
]
{
return
ctx
.
matched
(
m
,
ins
);
};
};
return
fold
([
&
](
auto
x
,
auto
y
)
{
return
op
(
always
(
x
),
matched
(
y
));
})(
Start
,
ms
...);
}
template
<
class
...
Ts
>
template
<
class
...
Ts
>
auto
operator
()(
Ts
...
ms
)
const
auto
operator
()(
Ts
...
ms
)
const
{
{
return
make_bf_matcher
([
=
](
matcher_context
&
ctx
,
instruction_ref
ins
)
{
return
make_bf_matcher
([
=
](
matcher_context
&
ctx
,
instruction_ref
ins
)
{
Op
op
;
bool
matches
=
folder
::
fold_match
(
ctx
,
ins
,
ms
...);
auto
matched
=
[
&
](
auto
m
)
{
return
[
&
]
{
return
ctx
.
matched
(
m
,
ins
);
};
};
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
();
...
@@ -283,12 +290,8 @@ struct folder
...
@@ -283,12 +290,8 @@ struct folder
Op
op
;
Op
op
;
bool
matches
=
Start
;
bool
matches
=
Start
;
select
(
start
,
[
&
](
auto
ins
)
{
select
(
start
,
[
&
](
auto
ins
)
{
auto
matched
=
[
&
](
auto
m
)
{
return
[
&
]
{
return
ctx
.
matched
(
m
,
ins
);
};
};
auto
fm
=
[
&
]
{
return
folder
::
fold_match
(
ctx
,
ins
,
ms
...);
};
auto
fold_match
=
[
&
]
{
matches
=
op
(
always
(
matches
),
fm
);
return
fold
([
&
](
auto
x
,
auto
y
)
{
return
op
(
always
(
x
),
matched
(
y
));
})(
Start
,
ms
...);
};
matches
=
op
(
always
(
matches
),
fold_match
);
});
});
if
(
matches
==
Matches
)
if
(
matches
==
Matches
)
return
start
;
return
start
;
...
...
test/matcher.cpp
View file @
3cb4edfe
...
@@ -148,6 +148,20 @@ TEST_CASE(match_arg7)
...
@@ -148,6 +148,20 @@ TEST_CASE(match_arg7)
EXPECT
(
bool
{
r
.
result
==
sum
});
EXPECT
(
bool
{
r
.
result
==
sum
});
}
}
TEST_CASE
(
match_arg8
)
{
migraphx
::
program
p
;
auto
one
=
p
.
add_literal
(
1
);
auto
two
=
p
.
add_literal
(
2
);
auto
sum
=
p
.
add_instruction
(
sum_op
{},
one
,
two
);
p
.
add_instruction
(
pass_op
{},
sum
);
auto
m
=
match
::
name
(
"sum"
)(
match
::
all_of
(
match
::
arg
(
0
)(
match
::
name
(
"@literal"
)),
match
::
arg
(
1
)(
match
::
name
(
"@literal"
))),
match
::
standard_shape
());
auto
r
=
find_match
(
p
,
m
);
EXPECT
(
bool
{
r
.
result
==
sum
});
}
TEST_CASE
(
match_args1
)
TEST_CASE
(
match_args1
)
{
{
migraphx
::
program
p
;
migraphx
::
program
p
;
...
...
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