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

Formatting

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