Commit f4a36aaf authored by Nick Korovaiko's avatar Nick Korovaiko Committed by Scott Cyphers

CSE for unary and binary (#982)

parent 516167f7
......@@ -24,12 +24,38 @@
#include "ngraph/graph_util.hpp"
#include "ngraph/log.hpp"
#include "ngraph/op/abs.hpp"
#include "ngraph/op/abs.hpp"
#include "ngraph/op/acos.hpp"
#include "ngraph/op/add.hpp"
#include "ngraph/op/asin.hpp"
#include "ngraph/op/atan.hpp"
#include "ngraph/op/broadcast.hpp"
#include "ngraph/op/ceiling.hpp"
#include "ngraph/op/constant.hpp"
#include "ngraph/op/cos.hpp"
#include "ngraph/op/cosh.hpp"
#include "ngraph/op/divide.hpp"
#include "ngraph/op/exp.hpp"
#include "ngraph/op/floor.hpp"
#include "ngraph/op/log.hpp"
#include "ngraph/op/maximum.hpp"
#include "ngraph/op/minimum.hpp"
#include "ngraph/op/multiply.hpp"
#include "ngraph/op/multiply.hpp"
#include "ngraph/op/negative.hpp"
#include "ngraph/op/power.hpp"
#include "ngraph/op/product.hpp"
#include "ngraph/op/relu.hpp"
#include "ngraph/op/remainder.hpp"
#include "ngraph/op/sign.hpp"
#include "ngraph/op/sin.hpp"
#include "ngraph/op/sinh.hpp"
#include "ngraph/op/softmax.hpp"
#include "ngraph/op/sqrt.hpp"
#include "ngraph/op/subtract.hpp"
#include "ngraph/op/sum.hpp"
#include "ngraph/op/tan.hpp"
#include "ngraph/op/tanh.hpp"
#include "ngraph/pattern/matcher.hpp"
using namespace ngraph;
......@@ -57,7 +83,33 @@ static std::unordered_map<std::type_index,
{
return std::unordered_map<std::type_index,
std::function<bool(std::shared_ptr<Node>, std::shared_ptr<Node>)>>({
{TI(op::Abs), cse_unarywise}, {TI(op::Add), cse_binarywise},
{TI(op::Abs), cse_unarywise},
{TI(op::Acos), cse_unarywise},
{TI(op::Asin), cse_unarywise},
{TI(op::Atan), cse_unarywise},
{TI(op::Ceiling), cse_unarywise},
{TI(op::Cos), cse_unarywise},
{TI(op::Cosh), cse_unarywise},
{TI(op::Exp), cse_unarywise},
{TI(op::Floor), cse_unarywise},
{TI(op::Log), cse_unarywise},
{TI(op::Negative), cse_unarywise},
{TI(op::Relu), cse_unarywise},
{TI(op::Sign), cse_unarywise},
{TI(op::Sin), cse_unarywise},
{TI(op::Sinh), cse_unarywise},
//{TI(op::Softmax), cse_unarywise},
{TI(op::Sqrt), cse_unarywise},
{TI(op::Tan), cse_unarywise},
{TI(op::Tanh), cse_unarywise},
{TI(op::Add), cse_binarywise},
{TI(op::Divide), cse_binarywise},
{TI(op::Maximum), cse_binarywise},
{TI(op::Minimum), cse_binarywise},
{TI(op::Multiply), cse_binarywise},
{TI(op::Power), cse_binarywise},
//{TI(op::Remainder), cse_binarywise},
{TI(op::Subtract), cse_binarywise},
});
}
......
......@@ -101,6 +101,7 @@
#include "ngraph/op/tanh.hpp"
#include "ngraph/pass/algebraic_simplification.hpp"
#include "ngraph/pass/core_fusion.hpp"
#include "ngraph/pass/cse.hpp"
#include "ngraph/pass/dump_sorted.hpp"
#include "ngraph/pass/get_output_element_elimination.hpp"
#include "ngraph/pass/liveness.hpp"
......@@ -320,6 +321,7 @@ void runtime::cpu::CPU_ExternalFunction::compile()
pass_manager.register_pass<runtime::cpu::pass::CPUNopElimination>();
pass_manager.register_pass<ngraph::pass::AlgebraicSimplification>();
pass_manager.register_pass<ngraph::pass::CommonSubexpressionElimination>();
pass_manager.register_pass<ngraph::pass::CoreFusion>();
pass_manager.register_pass<runtime::cpu::pass::CPUFusion>();
pass_manager.register_pass<runtime::cpu::pass::CPUWorkspaceInsertion>();
......
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