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
4f73e0ba
Commit
4f73e0ba
authored
Oct 17, 2018
by
Paul
Browse files
Formatting
parent
d29aa711
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
27 deletions
+36
-27
src/include/migraph/reflect.hpp
src/include/migraph/reflect.hpp
+11
-15
test/operation.cpp
test/operation.cpp
+2
-2
tools/include/operation.hpp
tools/include/operation.hpp
+23
-10
No files found.
src/include/migraph/reflect.hpp
View file @
4f73e0ba
...
@@ -9,13 +9,13 @@ namespace migraph {
...
@@ -9,13 +9,13 @@ namespace migraph {
namespace
detail
{
namespace
detail
{
template
<
class
T
,
class
Selector
>
template
<
class
T
,
class
Selector
>
auto
reflect_impl
(
rank
<
1
>
,
T
&
x
,
Selector
f
)
->
decltype
(
T
::
reflect
(
x
,
f
))
auto
reflect_impl
(
rank
<
1
>
,
T
&
x
,
Selector
f
)
->
decltype
(
T
::
reflect
(
x
,
f
))
{
{
return
T
::
reflect
(
x
,
std
::
move
(
f
));
return
T
::
reflect
(
x
,
std
::
move
(
f
));
}
}
template
<
class
T
,
class
Selector
>
template
<
class
T
,
class
Selector
>
auto
reflect_impl
(
rank
<
0
>
,
T
&
,
Selector
)
auto
reflect_impl
(
rank
<
0
>
,
T
&
,
Selector
)
{
{
return
pack
();
return
pack
();
...
@@ -23,29 +23,25 @@ auto reflect_impl(rank<0>, T&, Selector)
...
@@ -23,29 +23,25 @@ auto reflect_impl(rank<0>, T&, Selector)
}
// namespace detail
}
// namespace detail
template
<
class
T
,
class
Selector
>
template
<
class
T
,
class
Selector
>
auto
reflect
(
T
&
x
,
Selector
f
)
auto
reflect
(
T
&
x
,
Selector
f
)
{
{
return
detail
::
reflect_impl
(
rank
<
1
>
{},
x
,
std
::
move
(
f
));
return
detail
::
reflect_impl
(
rank
<
1
>
{},
x
,
std
::
move
(
f
));
}
}
template
<
class
T
>
template
<
class
T
>
auto
reflect_tie
(
T
&
x
)
auto
reflect_tie
(
T
&
x
)
{
{
return
reflect
(
x
,
[](
auto
&&
y
,
auto
&&
...)
{
return
std
::
ref
(
y
);
})([](
auto
&&
...
xs
)
{
return
reflect
(
x
,
[](
auto
&&
y
,
auto
&&
...)
{
return
std
::
ref
(
y
);
})(
return
std
::
tie
(
xs
.
get
()...);
[](
auto
&&
...
xs
)
{
return
std
::
tie
(
xs
.
get
()...);
});
});
}
}
template
<
class
T
,
class
F
>
template
<
class
T
,
class
F
>
void
reflect_each
(
T
&
x
,
F
f
)
void
reflect_each
(
T
&
x
,
F
f
)
{
{
return
reflect
(
x
,
[](
auto
&&
y
,
auto
...
ys
)
{
return
pack
(
std
::
ref
(
y
),
ys
...);
})([
&
](
auto
&&
...
xs
)
{
return
reflect
(
x
,
[](
auto
&&
y
,
auto
...
ys
)
{
return
pack
(
std
::
ref
(
y
),
ys
...);
})(
each_args
([
&
](
auto
p
)
{
[
&
](
auto
&&
...
xs
)
{
p
([
&
](
auto
&&
y
,
auto
...
ys
)
{
each_args
([
&
](
auto
p
)
{
p
([
&
](
auto
&&
y
,
auto
...
ys
)
{
f
(
y
,
ys
...);
});
},
xs
...);
f
(
y
,
ys
...);
});
},
xs
...);
});
});
}
}
...
...
test/operation.cpp
View file @
4f73e0ba
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
struct
simple_operation
struct
simple_operation
{
{
template
<
class
T
,
class
F
>
template
<
class
T
,
class
F
>
static
auto
reflect
(
T
&
x
,
F
f
)
static
auto
reflect
(
T
&
x
,
F
f
)
{
{
return
migraph
::
pack
(
f
(
x
.
data
,
"data"
));
return
migraph
::
pack
(
f
(
x
.
data
,
"data"
));
...
...
tools/include/operation.hpp
View file @
4f73e0ba
...
@@ -98,16 +98,29 @@ compute_op(const T& x, context& ctx, const shape& output_shape, const std::vecto
...
@@ -98,16 +98,29 @@ compute_op(const T& x, context& ctx, const shape& output_shape, const std::vecto
}
}
<%
<%
interface
(
'
operation
'
,
interface
(
virtual
(
'
name
'
,
returns
=
'
std
::
string
'
,
const
=
True
),
'
operation
'
,
virtual
(
'
compute_shape
'
,
returns
=
'
shape
'
,
input
=
'
const
std
::
vector
<
shape
>&
'
,
const
=
True
),
virtual
(
'
name
'
,
returns
=
'
std
::
string
'
,
const
=
True
),
virtual
(
'
compute
'
,
returns
=
'
argument
'
,
ctx
=
'
context
&
'
,
output
=
'
const
shape
&
'
,
input
=
'
const
std
::
vector
<
argument
>&
'
,
const
=
True
,
default
=
'
compute_op
'
),
virtual
(
'
compute_shape
'
,
returns
=
'
shape
'
,
input
=
'
const
std
::
vector
<
shape
>&
'
,
const
=
True
),
friend
(
'
operator
<<
'
,
returns
=
'
std
::
ostream
&
'
,
os
=
'
std
::
ostream
&
'
,
op
=
'
const
operation
&
'
,
using
=
'
migraph
::
operation_stream
::
operator
<<
'
),
virtual
(
'
compute
'
,
friend
(
'
operator
==
'
,
returns
=
'
bool
'
,
x
=
'
const
operation
&
'
,
y
=
'
const
operation
&
'
,
using
=
'
migraph
::
operation_equal
::
operator
==
'
)
returns
=
'
argument
'
,
)
ctx
=
'
context
&
'
,
%>
output
=
'
const
shape
&
'
,
input
=
'
const
std
::
vector
<
argument
>&
'
,
inline
bool
operator
!=
(
const
operation
&
x
,
const
operation
&
y
)
const
=
True
,
default
=
'
compute_op
'
),
friend
(
'
operator
<<
'
,
returns
=
'
std
::
ostream
&
'
,
os
=
'
std
::
ostream
&
'
,
op
=
'
const
operation
&
'
,
using
=
'
migraph
::
operation_stream
::
operator
<<
'
),
friend
(
'
operator
==
'
,
returns
=
'
bool
'
,
x
=
'
const
operation
&
'
,
y
=
'
const
operation
&
'
,
using
=
'
migraph
::
operation_equal
::
operator
==
'
))
%>
inline
bool
operator
!=
(
const
operation
&
x
,
const
operation
&
y
)
{
{
return
!
(
x
==
y
);
return
!
(
x
==
y
);
}
}
...
...
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