Commit 47d6fd28 authored by charlie's avatar charlie
Browse files

Remove operator-(size_t, dyn_dim), add tests

The operator-(size_t ,dyn_dim) is not used and somewhat bug prone
parent 9738d01d
...@@ -112,7 +112,6 @@ struct shape ...@@ -112,7 +112,6 @@ struct shape
friend dynamic_dimension operator+(const dynamic_dimension& x, const std::size_t& y); friend dynamic_dimension operator+(const dynamic_dimension& x, const std::size_t& y);
friend dynamic_dimension operator+(const std::size_t& x, const dynamic_dimension& y); friend dynamic_dimension operator+(const std::size_t& x, const dynamic_dimension& y);
friend dynamic_dimension operator-(const dynamic_dimension& x, const std::size_t& y); friend dynamic_dimension operator-(const dynamic_dimension& x, const std::size_t& y);
friend dynamic_dimension operator-(const std::size_t& x, const dynamic_dimension& y);
}; };
static const std::vector<type_t>& types(); static const std::vector<type_t>& types();
......
...@@ -541,10 +541,6 @@ shape::dynamic_dimension operator-(const shape::dynamic_dimension& x, const std: ...@@ -541,10 +541,6 @@ shape::dynamic_dimension operator-(const shape::dynamic_dimension& x, const std:
{ {
return {x.min - y, x.max - y, x.opt == 0 ? 0 : x.opt - y}; return {x.min - y, x.max - y, x.opt == 0 ? 0 : x.opt - y};
} }
shape::dynamic_dimension operator-(const std::size_t& x, const shape::dynamic_dimension& y)
{
return {x - y.min, x - y.max, y.opt == 0 ? 0 : x - y.opt};
}
bool operator==(const shape& x, const shape& y) bool operator==(const shape& x, const shape& y)
{ {
......
...@@ -174,6 +174,28 @@ TEST_CASE(dynamic_dimension_size_t_compares) ...@@ -174,6 +174,28 @@ TEST_CASE(dynamic_dimension_size_t_compares)
EXPECT(static_cast<std::size_t>(2) != b); EXPECT(static_cast<std::size_t>(2) != b);
} }
TEST_CASE(dynamic_dimension_add_sub_fixed)
{
using migraphx::shape;
auto a = shape::dynamic_dimension{2, 5, 2};
auto b = shape::dynamic_dimension{3, 6, 3};
EXPECT((a + 1) == b);
EXPECT((1 + a) == b);
EXPECT((b - 1) == a);
auto c = shape::dynamic_dimension{4, 7, 4};
EXPECT((a + 2) == c);
EXPECT((2 + a) == c);
EXPECT((c - 2) == a);
auto d = shape::dynamic_dimension{4, 8, 0};
auto e = shape::dynamic_dimension{2, 6, 0};
EXPECT((d - 2) == e);
EXPECT((e + 2) == d);
EXPECT((2 + e) == d);
}
TEST_CASE(test_shape_dynamic_errors) TEST_CASE(test_shape_dynamic_errors)
{ {
using migraphx::shape; using migraphx::shape;
......
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