Commit 4f73e0ba authored by Paul's avatar Paul
Browse files

Formatting

parent d29aa711
...@@ -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,30 +23,26 @@ auto reflect_impl(rank<0>, T&, Selector) ...@@ -23,30 +23,26 @@ 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...);
});
} }
} // namespace migraph } // namespace migraph
......
...@@ -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"));
...@@ -58,7 +58,7 @@ void operation_equal_test() ...@@ -58,7 +58,7 @@ void operation_equal_test()
{ {
simple_operation s{}; simple_operation s{};
migraph::operation op1 = s; migraph::operation op1 = s;
s.data = 2; s.data = 2;
migraph::operation op2 = op1; migraph::operation op2 = op1;
migraph::operation op3 = s; migraph::operation op3 = s;
......
...@@ -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);
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment