Commit 8f76125c authored by charlie's avatar charlie
Browse files

formatting

parent c497c12d
...@@ -176,7 +176,8 @@ struct shape ...@@ -176,7 +176,8 @@ struct shape
std::vector<std::size_t> multi(std::size_t i) const; std::vector<std::size_t> multi(std::size_t i) const;
void multi_copy(std::size_t i, std::size_t* start, const std::size_t* end) const; void multi_copy(std::size_t i, std::size_t* start, const std::size_t* end) const;
/// Returns true if the shape is packed (number of elements and buffer size the same) with no padding /// Returns true if the shape is packed (number of elements and buffer size the same) with no
/// padding
bool packed() const; bool packed() const;
/// Returns true is the shape has been transposed. That is the strides are not in descending /// Returns true is the shape has been transposed. That is the strides are not in descending
......
...@@ -78,12 +78,7 @@ struct shape_impl ...@@ -78,12 +78,7 @@ struct shape_impl
if(not m_dyn_dims.empty()) if(not m_dyn_dims.empty())
{ {
auto maxes = max_lens(); auto maxes = max_lens();
return std::accumulate( return std::accumulate(maxes.begin(), maxes.end(), std::size_t{1}, std::multiplies<>());
maxes.begin(),
maxes.end(),
std::size_t{1},
std::multiplies<>()
);
} }
assert(m_lens.size() == m_strides.size()); assert(m_lens.size() == m_strides.size());
...@@ -115,45 +110,30 @@ struct shape_impl ...@@ -115,45 +110,30 @@ struct shape_impl
std::vector<std::size_t> min_lens() const std::vector<std::size_t> min_lens() const
{ {
std::vector<std::size_t> ret(m_dyn_dims.size()); std::vector<std::size_t> ret(m_dyn_dims.size());
std::transform( std::transform(m_dyn_dims.cbegin(),
m_dyn_dims.cbegin(), m_dyn_dims.cend(),
m_dyn_dims.cend(), ret.begin(),
ret.begin(), [](shape::dynamic_dimension x) { return x.min; });
[](shape::dynamic_dimension x)
{
return x.min;
}
);
return ret; return ret;
} }
std::vector<std::size_t> max_lens() const std::vector<std::size_t> max_lens() const
{ {
std::vector<std::size_t> ret(m_dyn_dims.size()); std::vector<std::size_t> ret(m_dyn_dims.size());
std::transform( std::transform(m_dyn_dims.cbegin(),
m_dyn_dims.cbegin(), m_dyn_dims.cend(),
m_dyn_dims.cend(), ret.begin(),
ret.begin(), [](shape::dynamic_dimension x) { return x.max; });
[](shape::dynamic_dimension x)
{
return x.max;
}
);
return ret; return ret;
} }
std::vector<std::size_t> opt_lens() const std::vector<std::size_t> opt_lens() const
{ {
std::vector<std::size_t> ret(m_dyn_dims.size()); std::vector<std::size_t> ret(m_dyn_dims.size());
std::transform( std::transform(m_dyn_dims.cbegin(),
m_dyn_dims.cbegin(), m_dyn_dims.cend(),
m_dyn_dims.cend(), ret.begin(),
ret.begin(), [](shape::dynamic_dimension x) { return x.opt; });
[](shape::dynamic_dimension x)
{
return x.opt;
}
);
return ret; return ret;
} }
...@@ -439,29 +419,32 @@ const std::vector<shape::dynamic_dimension>& shape::dyn_dims() const { return im ...@@ -439,29 +419,32 @@ const std::vector<shape::dynamic_dimension>& shape::dyn_dims() const { return im
std::vector<std::size_t> shape::min_lens() const std::vector<std::size_t> shape::min_lens() const
{ {
if (not this->dynamic()) if(not this->dynamic())
{ {
return this->lens(); return this->lens();
} }
return impl->min_lens();; return impl->min_lens();
;
} }
std::vector<std::size_t> shape::max_lens() const std::vector<std::size_t> shape::max_lens() const
{ {
if (not this->dynamic()) if(not this->dynamic())
{ {
return this->lens(); return this->lens();
} }
return impl->max_lens();; return impl->max_lens();
;
} }
std::vector<std::size_t> shape::opt_lens() const std::vector<std::size_t> shape::opt_lens() const
{ {
if (not this->dynamic()) if(not this->dynamic())
{ {
return this->lens(); return this->lens();
} }
return impl->opt_lens();; return impl->opt_lens();
;
} }
bool operator==(const shape& x, const shape& y) bool operator==(const shape& x, const shape& y)
...@@ -520,11 +503,11 @@ void migraphx_to_value(value& v, const shape& s) ...@@ -520,11 +503,11 @@ void migraphx_to_value(value& v, const shape& s)
result["type"] = migraphx::to_value(s.type_string()); result["type"] = migraphx::to_value(s.type_string());
if(s.dynamic()) if(s.dynamic())
{ {
result["dynamic"] = migraphx::to_value(s.dynamic()); result["dynamic"] = migraphx::to_value(s.dynamic());
result["min_lens"] = migraphx::to_value(s.min_lens()); result["min_lens"] = migraphx::to_value(s.min_lens());
result["max_lens"] = migraphx::to_value(s.max_lens()); result["max_lens"] = migraphx::to_value(s.max_lens());
result["opt_lens"] = migraphx::to_value(s.opt_lens()); result["opt_lens"] = migraphx::to_value(s.opt_lens());
result["sub_shapes"] = migraphx::to_value(s.sub_shapes()); result["sub_shapes"] = migraphx::to_value(s.sub_shapes());
} }
else else
{ {
......
...@@ -91,10 +91,7 @@ TEST_CASE(test_shape_dynamic_compares) ...@@ -91,10 +91,7 @@ TEST_CASE(test_shape_dynamic_compares)
EXPECT(s0 != s3); EXPECT(s0 != s3);
} }
TEST_CASE(test_shape_dynamic_bytes) TEST_CASE(test_shape_dynamic_bytes) {}
{
}
TEST_CASE(test_shape_dynamic_errors) TEST_CASE(test_shape_dynamic_errors)
{ {
......
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