Commit 52f44f87 authored by Paul's avatar Paul
Browse files

Formatting

parent d2a38cd4
......@@ -10,12 +10,10 @@ namespace migraph {
bool is_reshaper(const std::string& name)
{
static const std::unordered_set<std::string> names = {
"reshape",
"transpose",
// "broadcast",
"contiguous"
};
static const std::unordered_set<std::string> names = {"reshape",
"transpose",
// "broadcast",
"contiguous"};
return contains(names, name);
}
......@@ -31,7 +29,7 @@ void simplify_reshapes::apply(program& p) const
continue;
// Gather reshapes
std::vector<instruction_ref> reshapes{ins};
while(is_reshaper(reshapes.back()->op.name()))
while(is_reshaper(reshapes.back()->op.name()))
{
assert(!reshapes.back()->arguments.empty());
assert(p.has_instruction(reshapes.back()->arguments.front()));
......@@ -39,17 +37,19 @@ void simplify_reshapes::apply(program& p) const
}
std::pair<instruction_ref, instruction_ref> r{p.end(), p.end()};
for(auto start:iterator_for(reshapes))
for(auto start : iterator_for(reshapes))
{
auto last = std::find_if(reshapes.rbegin(), reshapes.rend(), [&](auto&& i) {
return i->result == (*start)->result and i != (*start);
});
if (last != reshapes.rend()) {
if(last != reshapes.rend())
{
r = std::make_pair(*start, *last);
break;
}
}
if(r.first != r.second) {
if(r.first != r.second)
{
p.replace_instruction(r.first, r.second);
}
}
......
......@@ -34,7 +34,7 @@ migraph::literal get_2_broadcasted()
void double_contig()
{
migraph::program p;
auto l = p.add_literal(get_2x2());
auto l = p.add_literal(get_2x2());
auto t1 = p.add_instruction(migraph::transpose{{1, 0}}, l);
auto c1 = p.add_instruction(migraph::contiguous{}, t1);
auto c2 = p.add_instruction(migraph::contiguous{}, c1);
......@@ -52,7 +52,7 @@ void double_contig()
void double_transpose()
{
migraph::program p;
auto l = p.add_literal(get_2x2());
auto l = p.add_literal(get_2x2());
auto t1 = p.add_instruction(migraph::transpose{{1, 0}}, l);
auto t2 = p.add_instruction(migraph::transpose{{1, 0}}, t1);
p.add_instruction(pass_op{}, t2);
......@@ -69,7 +69,7 @@ void double_transpose()
void double_transpose_contig()
{
migraph::program p;
auto l = p.add_literal(get_2x2());
auto l = p.add_literal(get_2x2());
auto t1 = p.add_instruction(migraph::transpose{{1, 0}}, l);
auto c1 = p.add_instruction(migraph::contiguous{}, t1);
auto t2 = p.add_instruction(migraph::transpose{{1, 0}}, c1);
......@@ -88,7 +88,7 @@ void double_transpose_contig()
void single_transpose()
{
migraph::program p;
auto l = p.add_literal(get_2x2());
auto l = p.add_literal(get_2x2());
auto t1 = p.add_instruction(migraph::transpose{{1, 0}}, l);
p.add_instruction(pass_op{}, t1);
EXPECT(not p.get_shape().standard());
......@@ -104,7 +104,7 @@ void single_transpose()
void double_transpose_sin_pass()
{
migraph::program p;
auto l = p.add_literal(get_2x2());
auto l = p.add_literal(get_2x2());
auto t1 = p.add_instruction(migraph::transpose{{1, 0}}, l);
p.add_instruction(migraph::transpose{{1, 0}}, t1);
EXPECT(p.get_shape().standard());
......
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