Commit 7abdd2f0 authored by Paul's avatar Paul
Browse files

Formatting

parent eea003a5
...@@ -51,6 +51,7 @@ shared<T> share(T p) ...@@ -51,6 +51,7 @@ shared<T> share(T p)
} // namespace migraph } // namespace migraph
#define MIGRAPH_MANAGE_PTR(T, F) migraph::manage_ptr<std::remove_pointer_t<T>, decltype(&F), &F> // NOLINT #define MIGRAPH_MANAGE_PTR(T, F) \
migraph::manage_ptr<std::remove_pointer_t<T>, decltype(&F), &F> // NOLINT
#endif #endif
...@@ -34,7 +34,7 @@ struct check_shapes ...@@ -34,7 +34,7 @@ struct check_shapes
assert(shapes != nullptr); assert(shapes != nullptr);
if(shapes->size() != n) if(shapes->size() != n)
MIGRAPH_THROW(prefix() + "Wrong number of arguments: expected " + std::to_string(n) + MIGRAPH_THROW(prefix() + "Wrong number of arguments: expected " + std::to_string(n) +
" but given " + std::to_string(shapes->size())); " but given " + std::to_string(shapes->size()));
return *this; return *this;
} }
...@@ -97,7 +97,10 @@ struct check_shapes ...@@ -97,7 +97,10 @@ struct check_shapes
struct not_computable struct not_computable
{ {
argument compute(context&, shape, std::vector<argument>) const { MIGRAPH_THROW("not computable"); } argument compute(context&, shape, std::vector<argument>) const
{
MIGRAPH_THROW("not computable");
}
}; };
struct convolution struct convolution
...@@ -167,7 +170,10 @@ struct convolution ...@@ -167,7 +170,10 @@ struct convolution
} }
} }
argument compute(context&, shape, std::vector<argument>) const { MIGRAPH_THROW("not computable"); } argument compute(context&, shape, std::vector<argument>) const
{
MIGRAPH_THROW("not computable");
}
friend std::ostream& operator<<(std::ostream& os, const convolution& op) friend std::ostream& operator<<(std::ostream& os, const convolution& op)
{ {
...@@ -214,7 +220,10 @@ struct pooling ...@@ -214,7 +220,10 @@ struct pooling
}}; }};
} }
argument compute(context&, shape, std::vector<argument>) const { MIGRAPH_THROW("not computable"); } argument compute(context&, shape, std::vector<argument>) const
{
MIGRAPH_THROW("not computable");
}
friend std::ostream& operator<<(std::ostream& os, const pooling& op) friend std::ostream& operator<<(std::ostream& os, const pooling& op)
{ {
...@@ -237,7 +246,10 @@ struct activation ...@@ -237,7 +246,10 @@ struct activation
return inputs.front(); return inputs.front();
} }
argument compute(context&, shape, std::vector<argument>) const { MIGRAPH_THROW("not computable"); } argument compute(context&, shape, std::vector<argument>) const
{
MIGRAPH_THROW("not computable");
}
friend std::ostream& operator<<(std::ostream& os, const activation& op) friend std::ostream& operator<<(std::ostream& os, const activation& op)
{ {
os << op.name() << ":" << op.mode; os << op.name() << ":" << op.mode;
...@@ -275,7 +287,10 @@ struct transpose ...@@ -275,7 +287,10 @@ struct transpose
} }
return {t, output_lens, output_strides}; return {t, output_lens, output_strides};
} }
argument compute(context&, shape, std::vector<argument>) const { MIGRAPH_THROW("not computable"); } argument compute(context&, shape, std::vector<argument>) const
{
MIGRAPH_THROW("not computable");
}
}; };
struct contiguous struct contiguous
...@@ -292,7 +307,10 @@ struct contiguous ...@@ -292,7 +307,10 @@ struct contiguous
} }
return {t, lens}; return {t, lens};
} }
argument compute(context&, shape, std::vector<argument>) const { MIGRAPH_THROW("not computable"); } argument compute(context&, shape, std::vector<argument>) const
{
MIGRAPH_THROW("not computable");
}
}; };
struct reshape struct reshape
...@@ -320,7 +338,10 @@ struct reshape ...@@ -320,7 +338,10 @@ struct reshape
return s; return s;
} }
argument compute(context&, shape, std::vector<argument>) const { MIGRAPH_THROW("not computable"); } argument compute(context&, shape, std::vector<argument>) const
{
MIGRAPH_THROW("not computable");
}
friend std::ostream& operator<<(std::ostream& os, const reshape& op) friend std::ostream& operator<<(std::ostream& os, const reshape& op)
{ {
...@@ -346,7 +367,10 @@ struct gemm ...@@ -346,7 +367,10 @@ struct gemm
return {t, {a.lens()[0], b.lens()[1]}}; return {t, {a.lens()[0], b.lens()[1]}};
} }
argument compute(context&, shape, std::vector<argument>) const { MIGRAPH_THROW("not computable"); } argument compute(context&, shape, std::vector<argument>) const
{
MIGRAPH_THROW("not computable");
}
friend std::ostream& operator<<(std::ostream& os, const gemm& op) friend std::ostream& operator<<(std::ostream& os, const gemm& op)
{ {
...@@ -363,7 +387,10 @@ struct unary ...@@ -363,7 +387,10 @@ struct unary
check_shapes{inputs}.has(1); check_shapes{inputs}.has(1);
return inputs.at(0); return inputs.at(0);
} }
argument compute(context&, shape, std::vector<argument>) const { MIGRAPH_THROW("not computable"); } argument compute(context&, shape, std::vector<argument>) const
{
MIGRAPH_THROW("not computable");
}
}; };
struct identity : unary struct identity : unary
...@@ -477,7 +504,10 @@ struct binary ...@@ -477,7 +504,10 @@ struct binary
check_shapes{inputs}.has(2).same_type().same_dims(); check_shapes{inputs}.has(2).same_type().same_dims();
return inputs.at(0); return inputs.at(0);
} }
argument compute(context&, shape, std::vector<argument>) const { MIGRAPH_THROW("not computable"); } argument compute(context&, shape, std::vector<argument>) const
{
MIGRAPH_THROW("not computable");
}
}; };
struct add : binary struct add : binary
......
...@@ -131,7 +131,8 @@ struct raw_data : raw_data_base ...@@ -131,7 +131,8 @@ struct raw_data : raw_data_base
template <class T, template <class T,
class U, class U,
MIGRAPH_REQUIRES(std::is_base_of<raw_data_base, T>{} && std::is_base_of<raw_data_base, U>{})> MIGRAPH_REQUIRES(std::is_base_of<raw_data_base, T>{} &&
std::is_base_of<raw_data_base, U>{})>
bool operator==(const T& x, const U& y) bool operator==(const T& x, const U& y)
{ {
auto&& xshape = x.get_shape(); auto&& xshape = x.get_shape();
...@@ -153,7 +154,8 @@ bool operator==(const T& x, const U& y) ...@@ -153,7 +154,8 @@ bool operator==(const T& x, const U& y)
template <class T, template <class T,
class U, class U,
MIGRAPH_REQUIRES(std::is_base_of<raw_data_base, T>{} && std::is_base_of<raw_data_base, U>{})> MIGRAPH_REQUIRES(std::is_base_of<raw_data_base, T>{} &&
std::is_base_of<raw_data_base, U>{})>
bool operator!=(const T& x, const U& y) bool operator!=(const T& x, const U& y)
{ {
return !(x == y); return !(x == y);
......
...@@ -16,7 +16,7 @@ using bool_c = std::integral_constant<bool, B>; ...@@ -16,7 +16,7 @@ using bool_c = std::integral_constant<bool, B>;
#ifdef CPPCHECK #ifdef CPPCHECK
#define MIGRAPH_REQUIRES(...) class = void #define MIGRAPH_REQUIRES(...) class = void
#else #else
#define MIGRAPH_REQUIRES(...) \ #define MIGRAPH_REQUIRES(...) \
bool PrivateRequires##__LINE__ = true, \ bool PrivateRequires##__LINE__ = true, \
class = typename std::enable_if<and_<__VA_ARGS__, PrivateRequires##__LINE__>{}>::type class = typename std::enable_if<and_<__VA_ARGS__, PrivateRequires##__LINE__>{}>::type
#endif #endif
......
...@@ -37,7 +37,7 @@ struct shape ...@@ -37,7 +37,7 @@ struct shape
template <class T, class = void> template <class T, class = void>
struct get_type; struct get_type;
#define MIGRAPH_SHAPE_GET_TYPE(x, t) \ #define MIGRAPH_SHAPE_GET_TYPE(x, t) \
template <class T> \ template <class T> \
struct get_type<t, T> : std::integral_constant<type_t, x> \ struct get_type<t, T> : std::integral_constant<type_t, x> \
{ \ { \
......
...@@ -25,7 +25,10 @@ struct unknown ...@@ -25,7 +25,10 @@ struct unknown
else else
return input.front(); return input.front();
} }
argument compute(context&, shape, std::vector<argument>) const { MIGRAPH_THROW("not computable"); } argument compute(context&, shape, std::vector<argument>) const
{
MIGRAPH_THROW("not computable");
}
friend std::ostream& operator<<(std::ostream& os, const unknown& x) friend std::ostream& operator<<(std::ostream& os, const unknown& x)
{ {
os << x.name(); os << x.name();
......
...@@ -26,7 +26,8 @@ migraph::argument run_gpu(std::string file) ...@@ -26,7 +26,8 @@ migraph::argument run_gpu(std::string file)
auto s = p.get_parameter_shape("Input3"); auto s = p.get_parameter_shape("Input3");
auto input3 = migraph::miopen::to_gpu(migraph::generate_argument(s)); auto input3 = migraph::miopen::to_gpu(migraph::generate_argument(s));
auto output = migraph::miopen::to_gpu(migraph::generate_argument(p.get_parameter_shape("output"))); auto output =
migraph::miopen::to_gpu(migraph::generate_argument(p.get_parameter_shape("output")));
auto handle = migraph::miopen::make_obj<migraph::miopen::miopen_handle>(&miopenCreate); auto handle = migraph::miopen::make_obj<migraph::miopen::miopen_handle>(&miopenCreate);
auto out = p.eval({{"Input3", input3}, {"output", output}}); auto out = p.eval({{"Input3", input3}, {"output", output}});
......
...@@ -8,14 +8,15 @@ ...@@ -8,14 +8,15 @@
namespace migraph { namespace migraph {
namespace miopen { namespace miopen {
using miopen_handle = MIGRAPH_MANAGE_PTR(miopenHandle_t, miopenDestroy); using miopen_handle = MIGRAPH_MANAGE_PTR(miopenHandle_t, miopenDestroy);
using tensor_descriptor = MIGRAPH_MANAGE_PTR(miopenTensorDescriptor_t, miopenDestroyTensorDescriptor); using tensor_descriptor = MIGRAPH_MANAGE_PTR(miopenTensorDescriptor_t,
miopenDestroyTensorDescriptor);
using convolution_descriptor = MIGRAPH_MANAGE_PTR(miopenConvolutionDescriptor_t, using convolution_descriptor = MIGRAPH_MANAGE_PTR(miopenConvolutionDescriptor_t,
miopenDestroyConvolutionDescriptor); miopenDestroyConvolutionDescriptor);
using pooling_descriptor = MIGRAPH_MANAGE_PTR(miopenPoolingDescriptor_t, using pooling_descriptor = MIGRAPH_MANAGE_PTR(miopenPoolingDescriptor_t,
miopenDestroyPoolingDescriptor); miopenDestroyPoolingDescriptor);
using activation_descriptor = MIGRAPH_MANAGE_PTR(miopenActivationDescriptor_t, using activation_descriptor = MIGRAPH_MANAGE_PTR(miopenActivationDescriptor_t,
miopenDestroyActivationDescriptor); miopenDestroyActivationDescriptor);
template <class Result, class F, class... Ts> template <class Result, class F, class... Ts>
Result make_obj(F f, Ts... xs) Result make_obj(F f, Ts... xs)
......
...@@ -8,7 +8,8 @@ ...@@ -8,7 +8,8 @@
struct sum_op struct sum_op
{ {
std::string name() const { return "sum"; } std::string name() const { return "sum"; }
migraph::argument compute(migraph::context&, migraph::shape, std::vector<migraph::argument> args) const migraph::argument
compute(migraph::context&, migraph::shape, std::vector<migraph::argument> args) const
{ {
migraph::argument result; migraph::argument result;
if(args.size() != 2) if(args.size() != 2)
...@@ -37,7 +38,8 @@ struct sum_op ...@@ -37,7 +38,8 @@ struct sum_op
struct minus_op struct minus_op
{ {
std::string name() const { return "minus"; } std::string name() const { return "minus"; }
migraph::argument compute(migraph::context&, migraph::shape, std::vector<migraph::argument> args) const migraph::argument
compute(migraph::context&, migraph::shape, std::vector<migraph::argument> args) const
{ {
migraph::argument result; migraph::argument result;
if(args.size() != 2) if(args.size() != 2)
...@@ -118,8 +120,8 @@ void param_test() ...@@ -118,8 +120,8 @@ void param_test()
auto y = p.add_parameter("y", {migraph::shape::int64_type}); auto y = p.add_parameter("y", {migraph::shape::int64_type});
p.add_instruction(sum_op{}, x, y); p.add_instruction(sum_op{}, x, y);
auto result = auto result = p.eval(
p.eval({{"x", migraph::literal{1}.get_argument()}, {"y", migraph::literal{2}.get_argument()}}); {{"x", migraph::literal{1}.get_argument()}, {"y", migraph::literal{2}.get_argument()}});
EXPECT(result == migraph::literal{3}); EXPECT(result == migraph::literal{3});
EXPECT(result != migraph::literal{4}); EXPECT(result != migraph::literal{4});
} }
......
...@@ -35,7 +35,8 @@ migraph::argument run_gpu() ...@@ -35,7 +35,8 @@ migraph::argument run_gpu()
e.second = migraph::miopen::to_gpu(e.second); e.second = migraph::miopen::to_gpu(e.second);
} }
m["output"] = migraph::miopen::to_gpu(migraph::generate_argument(p.get_parameter_shape("output"))); m["output"] =
migraph::miopen::to_gpu(migraph::generate_argument(p.get_parameter_shape("output")));
return migraph::miopen::from_gpu(p.eval(m)); return migraph::miopen::from_gpu(p.eval(m));
} }
...@@ -96,9 +97,10 @@ struct test_conv_relu ...@@ -96,9 +97,10 @@ struct test_conv_relu
migraph::program create_program() const migraph::program create_program() const
{ {
migraph::program p; migraph::program p;
auto input = p.add_parameter("x", migraph::shape{migraph::shape::float_type, {4, 3, 3, 3}}); auto input = p.add_parameter("x", migraph::shape{migraph::shape::float_type, {4, 3, 3, 3}});
auto weights = p.add_parameter("w", migraph::shape{migraph::shape::float_type, {4, 3, 3, 3}}); auto weights =
auto conv = p.add_instruction(migraph::convolution{}, input, weights); p.add_parameter("w", migraph::shape{migraph::shape::float_type, {4, 3, 3, 3}});
auto conv = p.add_instruction(migraph::convolution{}, input, weights);
p.add_instruction(migraph::activation{"relu"}, conv); p.add_instruction(migraph::activation{"relu"}, conv);
return p; return p;
} }
...@@ -117,8 +119,10 @@ struct test_conv_pooling ...@@ -117,8 +119,10 @@ struct test_conv_pooling
migraph::program create_program() const migraph::program create_program() const
{ {
migraph::program p; migraph::program p;
auto input = p.add_parameter("x", migraph::shape{migraph::shape::float_type, {4, 3, 32, 32}}); auto input =
auto weights = p.add_parameter("w", migraph::shape{migraph::shape::float_type, {4, 3, 3, 3}}); p.add_parameter("x", migraph::shape{migraph::shape::float_type, {4, 3, 32, 32}});
auto weights =
p.add_parameter("w", migraph::shape{migraph::shape::float_type, {4, 3, 3, 3}});
auto conv = p.add_instruction(migraph::convolution{}, input, weights); auto conv = p.add_instruction(migraph::convolution{}, input, weights);
auto pooling = p.add_instruction(migraph::pooling{"max"}, conv); auto pooling = p.add_instruction(migraph::pooling{"max"}, conv);
p.add_instruction(migraph::activation{"relu"}, pooling); p.add_instruction(migraph::activation{"relu"}, pooling);
......
...@@ -8,8 +8,12 @@ struct simple_operation ...@@ -8,8 +8,12 @@ struct simple_operation
{ {
int data = 1; int data = 1;
std::string name() const { return "simple"; } std::string name() const { return "simple"; }
migraph::shape compute_shape(std::vector<migraph::shape>) const { MIGRAPH_THROW("not computable"); } migraph::shape compute_shape(std::vector<migraph::shape>) const
migraph::argument compute(migraph::context&, migraph::shape, std::vector<migraph::argument>) const {
MIGRAPH_THROW("not computable");
}
migraph::argument
compute(migraph::context&, migraph::shape, std::vector<migraph::argument>) const
{ {
MIGRAPH_THROW("not computable"); MIGRAPH_THROW("not computable");
} }
...@@ -23,8 +27,12 @@ struct simple_operation ...@@ -23,8 +27,12 @@ struct simple_operation
struct simple_operation_no_print struct simple_operation_no_print
{ {
std::string name() const { return "simple"; } std::string name() const { return "simple"; }
migraph::shape compute_shape(std::vector<migraph::shape>) const { MIGRAPH_THROW("not computable"); } migraph::shape compute_shape(std::vector<migraph::shape>) const
migraph::argument compute(migraph::context&, migraph::shape, std::vector<migraph::argument>) const {
MIGRAPH_THROW("not computable");
}
migraph::argument
compute(migraph::context&, migraph::shape, std::vector<migraph::argument>) const
{ {
MIGRAPH_THROW("not computable"); MIGRAPH_THROW("not computable");
} }
......
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