Commit 84af2e9e authored by Paul's avatar Paul
Browse files

Formatting

parent 5f04935f
...@@ -84,8 +84,10 @@ bool shape::packed() const { return this->m_packed; } ...@@ -84,8 +84,10 @@ bool shape::packed() const { return this->m_packed; }
bool shape::broadcasted() const bool shape::broadcasted() const
{ {
assert(this->lens().size() == this->strides().size()); assert(this->lens().size() == this->strides().size());
return std::accumulate( return std::accumulate(this->strides().begin(),
this->strides().begin(), this->strides().end(), std::size_t{1}, std::multiplies<std::size_t>()) == 0; this->strides().end(),
std::size_t{1},
std::multiplies<std::size_t>()) == 0;
} }
std::size_t shape::element_space() const std::size_t shape::element_space() const
......
...@@ -105,17 +105,21 @@ struct miopen_add ...@@ -105,17 +105,21 @@ struct miopen_add
argument compute(shape output_shape, std::vector<argument> args) const argument compute(shape output_shape, std::vector<argument> args) const
{ {
if(args[2].get_shape().broadcasted()) { if(args[2].get_shape().broadcasted())
{
argument result{output_shape}; argument result{output_shape};
visit_all(result, from_gpu(args[1]), from_gpu(args[2]))([&](auto output, auto input1, auto input2) { visit_all(result, from_gpu(args[1]), from_gpu(args[2]))(
[&](auto output, auto input1, auto input2) {
shape_for_each(output.get_shape(), [&](const auto& idx) { shape_for_each(output.get_shape(), [&](const auto& idx) {
output(idx.begin(), idx.end()) = output(idx.begin(), idx.end()) =
input1(idx.begin(), idx.end()) + input2(idx.begin(), idx.end()); input1(idx.begin(), idx.end()) + input2(idx.begin(), idx.end());
}); });
}); });
return to_gpu(result); return to_gpu(result);
} else { }
else
{
float alpha = 1, beta = 0; float alpha = 1, beta = 0;
auto a_desc = make_tensor(args[1].get_shape()); auto a_desc = make_tensor(args[1].get_shape());
auto b_desc = make_tensor(args[2].get_shape()); auto b_desc = make_tensor(args[2].get_shape());
......
...@@ -114,7 +114,7 @@ struct capture ...@@ -114,7 +114,7 @@ struct capture
}; };
template <class T, class F> template <class T, class F>
void failed(T x, const char* msg, const char * func, const char* file, int line, F f) void failed(T x, const char* msg, const char* func, const char* file, int line, F f)
{ {
if(!x.value()) if(!x.value())
{ {
...@@ -164,10 +164,17 @@ void run_test() ...@@ -164,10 +164,17 @@ void run_test()
// NOLINTNEXTLINE // NOLINTNEXTLINE
#define CHECK(...) \ #define CHECK(...) \
test::failed(test::capture{}->*__VA_ARGS__, #__VA_ARGS__, __PRETTY_FUNCTION__, __FILE__, __LINE__, [] {}) test::failed( \
test::capture{}->*__VA_ARGS__, #__VA_ARGS__, __PRETTY_FUNCTION__, __FILE__, __LINE__, [] { \
})
// NOLINTNEXTLINE // NOLINTNEXTLINE
#define EXPECT(...) \ #define EXPECT(...) \
test::failed(test::capture{}->*__VA_ARGS__, #__VA_ARGS__, __PRETTY_FUNCTION__, __FILE__, __LINE__, &std::abort) test::failed(test::capture{}->*__VA_ARGS__, \
#__VA_ARGS__, \
__PRETTY_FUNCTION__, \
__FILE__, \
__LINE__, \
&std::abort)
// NOLINTNEXTLINE // NOLINTNEXTLINE
#define STATUS(...) EXPECT((__VA_ARGS__) == 0) #define STATUS(...) EXPECT((__VA_ARGS__) == 0)
......
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