Commit c5aa44c8 authored by Jaikrishnan Menon's avatar Jaikrishnan Menon

CPU: Implement op::Sign

parent f6fe106d
......@@ -1310,3 +1310,19 @@ void Emitter::EMITTER_DECL(EmitReduce)
throw ngraph_error("Reduce: only vectors and matrices are currently supported");
}
}
void Emitter::EMITTER_DECL(EmitSign)
{
const element::Type& et =
(dynamic_pointer_cast<const TensorViewType>(n->get_arguments().at(0)->get_value_type()))
->get_element_type();
TU += " {\n"
" auto arg0 = call_frame->get_tensor_view_data<" + element_type_names[TI(et)] + ">(" + to_string(inputs[0].get_index()) + ");\n"
" auto out = call_frame->get_tensor_view_data<" + element_type_names[TI(et)] + ">(" + to_string(outputs[0].get_index()) + ");\n"
" EigenArray1d<" + element_type_names[TI(et)] + ">(out, "
EIGEN_VECTOR_FORMAT(outputs[0].get_layout<DenseTensorViewLayout>()->get_size()) ") =\n"
" EigenArray1d<" + element_type_names[TI(et)] + ">(arg0, "
EIGEN_VECTOR_FORMAT(inputs[0].get_layout<DenseTensorViewLayout>()->get_size()) ").sign();\n"
" }\n";
}
......@@ -80,6 +80,7 @@ namespace ngraph
void EMITTER_DECL(EmitReshape);
void EMITTER_DECL(EmitFunctionCall);
void EMITTER_DECL(EmitReduce);
void EMITTER_DECL(EmitSign);
};
}
}
......
......@@ -50,6 +50,7 @@
#include "ngraph/ops/reduce.hpp"
#include "ngraph/ops/reshape.hpp"
#include "ngraph/ops/select.hpp"
#include "ngraph/ops/sign.hpp"
#include "ngraph/ops/subtract.hpp"
#include "ngraph/ops/tuple.hpp"
#include "ngraph/pass/assign_layout.hpp"
......@@ -113,6 +114,7 @@ static const OpMap dispatcher{
{TI(ngraph::op::Reshape), &Emitter::EmitReshape},
{TI(ngraph::op::FunctionCall), &Emitter::EmitFunctionCall},
{TI(ngraph::op::Reduce), &Emitter::EmitReduce},
{TI(ngraph::op::Sign), &Emitter::EmitSign},
};
#undef TI
......
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