Commit 60d38bfb authored by Jaikrishnan Menon's avatar Jaikrishnan Menon

CPU: Optimize Eigen Cwise sum

parent fce3c524
...@@ -37,6 +37,8 @@ ...@@ -37,6 +37,8 @@
#include "ngraph/runtime/cpu/cpu_kernel_emitters.hpp" #include "ngraph/runtime/cpu/cpu_kernel_emitters.hpp"
#include "ngraph/util.hpp" #include "ngraph/util.hpp"
#define EMIT_BREAKPOINT "__asm__ volatile(\"int $0x03\");\n"
using namespace std; using namespace std;
using namespace ngraph; using namespace ngraph;
...@@ -62,13 +64,19 @@ void runtime::cpu::CPU_Emitter::EmitAdd(const ngraph::Node* n, ...@@ -62,13 +64,19 @@ void runtime::cpu::CPU_Emitter::EmitAdd(const ngraph::Node* n,
const vector<runtime::cpu::TensorViewWrapper>& args, const vector<runtime::cpu::TensorViewWrapper>& args,
const vector<runtime::cpu::TensorViewWrapper>& out) const vector<runtime::cpu::TensorViewWrapper>& out)
{ {
// TODO: Audit all uses of Add and fix this to use
// the right alignment instead of Eigen::Unaligned
m_out << "{ // " << n->get_name() << "\n"; m_out << "{ // " << n->get_name() << "\n";
m_out.indent++; m_out.indent++;
m_out << emit_array1d(out[0]) << " = \n"; m_out << "Eigen::Map<Eigen::Array<" << out[0].get_element_type().c_type_string() << ", "
m_out.indent++; << out[0].get_size() << ", 1>, Eigen::Unaligned> out(" << out[0].get_name() << ");\n";
m_out << emit_array1d(args[0]) << " +\n "; m_out << "Eigen::Map<Eigen::Array<" << args[0].get_element_type().c_type_string() << ", "
m_out << emit_array1d(args[1]) << ";\n"; << args[0].get_size() << ", 1>, Eigen::Unaligned> arg0(" << args[0].get_name() << ");\n";
m_out.indent -= 2; m_out << "Eigen::Map<Eigen::Array<" << args[1].get_element_type().c_type_string() << ", "
<< args[1].get_size() << ", 1>, Eigen::Unaligned> arg1(" << args[1].get_name() << ");\n";
m_out << "out = arg0 + arg1;\n";
m_out.indent--;
m_out << "}\n"; m_out << "}\n";
} }
......
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