"src/vscode:/vscode.git/clone" did not exist on "c5bbc608555014e7b0b7108bc0a5eebb1522768f"
Commit de001f3e authored by Khalique's avatar Khalique
Browse files

formatting

parent fd150551
...@@ -40,7 +40,7 @@ void eliminate_identity::apply(program& p) const ...@@ -40,7 +40,7 @@ void eliminate_identity::apply(program& p) const
if(ins == p.begin()) if(ins == p.begin())
continue; continue;
const auto i = std::prev(ins); const auto i = std::prev(ins);
if(i->name() == "identity") if(i->name() == "identity")
{ {
p.replace_instruction(i, i->inputs().front()); p.replace_instruction(i, i->inputs().front());
...@@ -57,7 +57,7 @@ void eliminate_identity::apply(program& p) const ...@@ -57,7 +57,7 @@ void eliminate_identity::apply(program& p) const
// since this is the last instruction, removing it only // since this is the last instruction, removing it only
// requires changing "last" and calling remove below // requires changing "last" and calling remove below
last = std::prev(last); last = std::prev(last);
} }
} }
break; break;
} }
......
...@@ -19,13 +19,15 @@ TEST_CASE(simple_test) ...@@ -19,13 +19,15 @@ TEST_CASE(simple_test)
{ {
migraphx::program p; migraphx::program p;
auto one = p.add_literal(1); auto one = p.add_literal(1);
auto one_identity = p.add_instruction(migraphx::op::identity{}, one); auto one_identity = p.add_instruction(migraphx::op::identity{}, one);
auto two = p.add_literal(2); auto two = p.add_literal(2);
auto two_identity = p.add_instruction(migraphx::op::identity{}, two); auto two_identity = p.add_instruction(migraphx::op::identity{}, two);
p.add_instruction(sum_op{}, one_identity, two_identity); p.add_instruction(sum_op{}, one_identity, two_identity);
p.compile(eliminate_identity_target{}); p.compile(eliminate_identity_target{});
EXPECT(std::none_of(p.begin(), p.end(), [](const migraphx::instruction& ins){ return ins.name() == "identity"; })); EXPECT(std::none_of(p.begin(), p.end(), [](const migraphx::instruction& ins) {
return ins.name() == "identity";
}));
auto result = p.eval({}); auto result = p.eval({});
EXPECT(result == migraphx::literal{3}); EXPECT(result == migraphx::literal{3});
} }
...@@ -39,7 +41,9 @@ TEST_CASE(simple_test_end) ...@@ -39,7 +41,9 @@ TEST_CASE(simple_test_end)
auto ans = p.add_instruction(sum_op{}, one, two); auto ans = p.add_instruction(sum_op{}, one, two);
p.add_instruction(migraphx::op::identity{}, ans); p.add_instruction(migraphx::op::identity{}, ans);
p.compile(eliminate_identity_target{}); p.compile(eliminate_identity_target{});
EXPECT(std::none_of(p.begin(), p.end(), [](const migraphx::instruction& ins){ return ins.name() == "identity"; })); EXPECT(std::none_of(p.begin(), p.end(), [](const migraphx::instruction& ins) {
return ins.name() == "identity";
}));
auto result = p.eval({}); auto result = p.eval({});
EXPECT(result == migraphx::literal{3}); EXPECT(result == migraphx::literal{3});
} }
...@@ -48,17 +52,18 @@ TEST_CASE(simple_test_end_dependency) ...@@ -48,17 +52,18 @@ TEST_CASE(simple_test_end_dependency)
{ {
migraphx::program p; migraphx::program p;
auto one = p.add_literal(1.0); auto one = p.add_literal(1.0);
auto two = p.add_literal(2.0); auto two = p.add_literal(2.0);
auto three = p.add_literal(3.0); auto three = p.add_literal(3.0);
auto ans = p.add_instruction(sum_op{}, one, two); auto ans = p.add_instruction(sum_op{}, one, two);
p.add_instruction(sum_op{}, ans, three); p.add_instruction(sum_op{}, ans, three);
p.add_instruction(migraphx::op::identity{}, ans); p.add_instruction(migraphx::op::identity{}, ans);
p.compile(eliminate_identity_target{}); p.compile(eliminate_identity_target{});
EXPECT(!std::none_of(p.begin(), p.end(), [](const migraphx::instruction& ins){ return ins.name() == "identity"; })); EXPECT(!std::none_of(p.begin(), p.end(), [](const migraphx::instruction& ins) {
return ins.name() == "identity";
}));
auto result = p.eval({}); auto result = p.eval({});
EXPECT(result == migraphx::literal{3.0}); EXPECT(result == migraphx::literal{3.0});
} }
int main(int argc, const char* argv[]) { test::run(argc, argv); } int main(int argc, const char* argv[]) { test::run(argc, argv); }
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