Commit 2bd9e144 authored by Jaikrishnan Menon's avatar Jaikrishnan Menon

CPU: Implement op::Divide

parent 0c5d5a65
......@@ -233,3 +233,22 @@ void Emitter::EMITTER_DECL(EmitConcat)
TU += " }\n";
}
}
void Emitter::EMITTER_DECL(EmitDivide)
{
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 arg1 = call_frame->get_tensor_view_data<" + element_type_names[TI(et)] + ">(" + to_string(inputs[1].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()) ") /\n"
" EigenArray1d<" + element_type_names[TI(et)] + ">(arg1, "
EIGEN_VECTOR_FORMAT(inputs[1].get_layout<DenseTensorViewLayout>()->get_size()) ");\n"
" }\n";
}
......@@ -51,6 +51,7 @@ namespace ngraph
void EMITTER_DECL(EmitTuple);
void EMITTER_DECL(EmitAbs);
void EMITTER_DECL(EmitConcat);
void EMITTER_DECL(EmitDivide);
};
}
......
......@@ -73,7 +73,8 @@ static const OpMap dispatcher{{TI(ngraph::op::Add), &Emitter::EmitAdd},
{TI(ngraph::op::GetTupleElement), &Emitter::EmitGetTupleElement},
{TI(ngraph::op::Tuple), &Emitter::EmitTuple},
{TI(ngraph::op::Abs), &Emitter::EmitAbs},
{TI(ngraph::op::Concat), &Emitter::EmitConcat}
{TI(ngraph::op::Concat), &Emitter::EmitConcat},
{TI(ngraph::op::Divide), &Emitter::EmitDivide}
};
#undef TI
......
......@@ -388,10 +388,9 @@ TEST(cpu, concat_vector)
ASSERT_EQ((vector<float>{2, 4, 8, 16, 1, 2, 4, 8, 16, 32, 18, 19}), result->get_vector());
}
/*
TEST(execute, divide)
TEST(cpu, divide)
{
auto manager = runtime::Manager::get("NGVM");
auto manager = runtime::Manager::get("CPU");
auto backend = manager->allocate_backend();
auto shape = Shape{2, 2};
......@@ -419,6 +418,7 @@ TEST(execute, divide)
ASSERT_EQ((vector<float>{2, 2, 2, 2}), result->get_vector());
}
/*
TEST(execute, equal)
{
auto shape = Shape{2, 2, 2};
......
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