Commit 22e1368a authored by Jaikrishnan Menon's avatar Jaikrishnan Menon

CPU: Apply formatting fixes from clang-format

parent 75623f48
...@@ -46,10 +46,8 @@ public: ...@@ -46,10 +46,8 @@ public:
void enable_pch() { pch_enabled = true; } void enable_pch() { pch_enabled = true; }
void disable_pch() { pch_enabled = false; } void disable_pch() { pch_enabled = false; }
void enable_debuginfo() { debuginfo_enabled = true; } void enable_debuginfo() { debuginfo_enabled = true; }
void disable_debuginfo() { debuginfo_enabled = false; } void disable_debuginfo() { debuginfo_enabled = false; }
std::unique_ptr<llvm::Module> compile(const std::string& source, const std::string& name = ""); std::unique_ptr<llvm::Module> compile(const std::string& source, const std::string& name = "");
bool add_module(std::unique_ptr<llvm::Module>&); bool add_module(std::unique_ptr<llvm::Module>&);
......
...@@ -14,9 +14,9 @@ ...@@ -14,9 +14,9 @@
#pragma once #pragma once
#include <functional>
#include <memory> #include <memory>
#include <vector> #include <vector>
#include <functional>
#include "ngraph/function.hpp" #include "ngraph/function.hpp"
#include "ngraph/runtime/call_frame.hpp" #include "ngraph/runtime/call_frame.hpp"
...@@ -31,17 +31,17 @@ namespace ngraph ...@@ -31,17 +31,17 @@ namespace ngraph
namespace cpu namespace cpu
{ {
class CallFrame; class CallFrame;
using EntryPoint = std::function<void(ngraph::runtime::cpu::CallFrame*, ngraph::runtime::TensorViewPtrs&)>; using EntryPoint = std::function<void(ngraph::runtime::cpu::CallFrame*,
ngraph::runtime::TensorViewPtrs&)>;
// Compile and execute graphs // Compile and execute graphs
class CallFrame : public ngraph::runtime::CallFrame class CallFrame : public ngraph::runtime::CallFrame
{ {
public: public:
CallFrame( CallFrame(EntryPoint compiled_function,
EntryPoint compiled_function, size_t n_inputs,
size_t n_inputs, size_t n_outputs,
size_t n_outputs, const TensorViewPtrs& temps);
const TensorViewPtrs& temps);
/// @brief Invoke the function with values matching the signature of the function. /// @brief Invoke the function with values matching the signature of the function.
/// ///
......
...@@ -14,9 +14,9 @@ ...@@ -14,9 +14,9 @@
#include <memory> #include <memory>
#include "ngraph/runtime/cpu/external_function.hpp"
#include "ngraph/runtime/cpu/cpu_backend.hpp" #include "ngraph/runtime/cpu/cpu_backend.hpp"
#include "ngraph/runtime/cpu/cpu_manager.hpp" #include "ngraph/runtime/cpu/cpu_manager.hpp"
#include "ngraph/runtime/cpu/external_function.hpp"
using namespace ngraph::runtime::cpu; using namespace ngraph::runtime::cpu;
......
...@@ -16,8 +16,8 @@ ...@@ -16,8 +16,8 @@
#include <memory> #include <memory>
#include "ngraph/runtime/manager.hpp"
#include "ngraph/codegen/compiler.hpp" #include "ngraph/codegen/compiler.hpp"
#include "ngraph/runtime/manager.hpp"
namespace ngraph namespace ngraph
{ {
...@@ -34,6 +34,7 @@ namespace ngraph ...@@ -34,6 +34,7 @@ namespace ngraph
{ {
protected: protected:
ngraph::codegen::execution_state exec_state; ngraph::codegen::execution_state exec_state;
public: public:
virtual std::shared_ptr<Backend> allocate_backend() override; virtual std::shared_ptr<Backend> allocate_backend() override;
......
...@@ -13,19 +13,19 @@ ...@@ -13,19 +13,19 @@
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
#include <iostream> #include <iostream>
#include <vector>
#include <typeindex>
#include <string> #include <string>
#include <typeindex>
#include <unordered_map> #include <unordered_map>
#include <vector>
#include "ngraph/node.hpp"
#include "ngraph/descriptor/layout/dense_tensor_view_layout.hpp" #include "ngraph/descriptor/layout/dense_tensor_view_layout.hpp"
#include "ngraph/node.hpp"
#include "ngraph/ops/concatenate.hpp" #include "ngraph/ops/concatenate.hpp"
#include "ngraph/ops/constant.hpp" #include "ngraph/ops/constant.hpp"
#include "ngraph/ops/get_tuple_element.hpp" #include "ngraph/ops/get_tuple_element.hpp"
#include "ngraph/runtime/tensor_view_info.hpp"
#include "ngraph/runtime/cpu/external_function.hpp"
#include "ngraph/runtime/cpu/emitter.hpp" #include "ngraph/runtime/cpu/emitter.hpp"
#include "ngraph/runtime/cpu/external_function.hpp"
#include "ngraph/runtime/tensor_view_info.hpp"
using namespace std; using namespace std;
using namespace ngraph::runtime::cpu; using namespace ngraph::runtime::cpu;
...@@ -34,21 +34,19 @@ using ngraph::descriptor::layout::DenseTensorViewLayout; ...@@ -34,21 +34,19 @@ using ngraph::descriptor::layout::DenseTensorViewLayout;
#define TI(x) type_index(typeid(x)) #define TI(x) type_index(typeid(x))
static unordered_map<type_index, string> element_type_names = {{TI(ngraph::element::Bool), "Bool"}, static unordered_map<type_index, string> element_type_names = {
{TI(ngraph::element::Float32), "Float32"}, {TI(ngraph::element::Bool), "Bool"},
{TI(ngraph::element::Int8), "Int8"}, {TI(ngraph::element::Float32), "Float32"},
{TI(ngraph::element::Int32), "Int32"}, {TI(ngraph::element::Int8), "Int8"},
{TI(ngraph::element::Int64), "Int64"}, {TI(ngraph::element::Int32), "Int32"},
{TI(ngraph::element::UInt8), "UInt8"}, {TI(ngraph::element::Int64), "Int64"},
{TI(ngraph::element::UInt32), "UInt32"}, {TI(ngraph::element::UInt8), "UInt8"},
{TI(ngraph::element::UInt64), "UInt64"} {TI(ngraph::element::UInt32), "UInt32"},
}; {TI(ngraph::element::UInt64), "UInt64"}};
#define EIGEN_VECTOR_FORMAT(x) "fmt::V{" + to_string(x) + "}" #define EIGEN_VECTOR_FORMAT(x) "fmt::V{" + to_string(x) + "}"
static std::string EIGEN_MATRIX_FORMAT(const ngraph::Shape& shape, static std::string EIGEN_MATRIX_FORMAT(const ngraph::Shape& shape, const ngraph::Strides& strides)
const ngraph::Strides& strides)
{ {
std::string I; std::string I;
for (size_t i = 0; i < shape.size(); i++) for (size_t i = 0; i < shape.size(); i++)
...@@ -84,9 +82,9 @@ void Emitter::EMITTER_DECL(EmitNop) ...@@ -84,9 +82,9 @@ void Emitter::EMITTER_DECL(EmitNop)
void Emitter::EMITTER_DECL(EmitAdd) void Emitter::EMITTER_DECL(EmitAdd)
{ {
const element::Type& et = (dynamic_pointer_cast<const TensorViewType>( const element::Type& et =
n->get_arguments().at(0)->get_value_type())) (dynamic_pointer_cast<const TensorViewType>(n->get_arguments().at(0)->get_value_type()))
->get_element_type(); ->get_element_type();
TU += " {\n" TU += " {\n"
" auto arg0 = call_frame->get_tensor_view_data<" + element_type_names[TI(et)] + ">(" + to_string(inputs[0].get_index()) + ");\n" " auto arg0 = call_frame->get_tensor_view_data<" + element_type_names[TI(et)] + ">(" + to_string(inputs[0].get_index()) + ");\n"
...@@ -178,20 +176,30 @@ void Emitter::EMITTER_DECL(EmitDot) ...@@ -178,20 +176,30 @@ void Emitter::EMITTER_DECL(EmitDot)
auto arg1_layout = inputs[1].get_layout<DenseTensorViewLayout>(); auto arg1_layout = inputs[1].get_layout<DenseTensorViewLayout>();
auto out_layout = outputs[0].get_layout<DenseTensorViewLayout>(); auto out_layout = outputs[0].get_layout<DenseTensorViewLayout>();
TU += " {\n" TU +=
" auto arg0 = call_frame->get_tensor_view_data<" + element_type_names[TI(arg0_element_type)] + ">(" + " {\n"
to_string(inputs[0].get_index()) + ");\n" " auto arg0 = call_frame->get_tensor_view_data<" +
" auto arg1 = call_frame->get_tensor_view_data<" + element_type_names[TI(arg0_element_type)] + ">(" + element_type_names[TI(arg0_element_type)] + ">(" + to_string(inputs[0].get_index()) +
to_string(inputs[1].get_index()) + ");\n" ");\n"
" auto out = call_frame->get_tensor_view_data<" + element_type_names[TI(arg0_element_type)] + ">(" + " auto arg1 = call_frame->get_tensor_view_data<" +
to_string(outputs[0].get_index()) + ");\n" element_type_names[TI(arg0_element_type)] + ">(" + to_string(inputs[1].get_index()) +
" EigenMatrix<" + element_type_names[TI(arg0_element_type)] + ">(out, " + ");\n"
EIGEN_MATRIX_FORMAT(out_layout->get_shape(), out_layout->get_strides()) + ") = \n" " auto out = call_frame->get_tensor_view_data<" +
" EigenMatrix<" + element_type_names[TI(arg0_element_type)] + ">(arg0, " + element_type_names[TI(arg0_element_type)] + ">(" + to_string(outputs[0].get_index()) +
EIGEN_MATRIX_FORMAT(arg0_layout->get_shape(), arg0_layout->get_strides()) + ") * " ");\n"
"EigenMatrix<" + element_type_names[TI(arg0_element_type)] + ">(arg1, " + " EigenMatrix<" +
EIGEN_MATRIX_FORMAT(arg1_layout->get_shape(), arg1_layout->get_strides()) + ");\n" element_type_names[TI(arg0_element_type)] + ">(out, " +
" }\n"; EIGEN_MATRIX_FORMAT(out_layout->get_shape(), out_layout->get_strides()) +
") = \n"
" EigenMatrix<" +
element_type_names[TI(arg0_element_type)] + ">(arg0, " +
EIGEN_MATRIX_FORMAT(arg0_layout->get_shape(), arg0_layout->get_strides()) +
") * "
"EigenMatrix<" +
element_type_names[TI(arg0_element_type)] + ">(arg1, " +
EIGEN_MATRIX_FORMAT(arg1_layout->get_shape(), arg1_layout->get_strides()) +
");\n"
" }\n";
} }
else else
{ {
...@@ -201,9 +209,9 @@ void Emitter::EMITTER_DECL(EmitDot) ...@@ -201,9 +209,9 @@ void Emitter::EMITTER_DECL(EmitDot)
void Emitter::EMITTER_DECL(EmitMultiply) void Emitter::EMITTER_DECL(EmitMultiply)
{ {
const element::Type& et = (dynamic_pointer_cast<const TensorViewType>( const element::Type& et =
n->get_arguments().at(0)->get_value_type())) (dynamic_pointer_cast<const TensorViewType>(n->get_arguments().at(0)->get_value_type()))
->get_element_type(); ->get_element_type();
TU += " {\n" TU += " {\n"
" auto arg0 = call_frame->get_tensor_view_data<" + element_type_names[TI(et)] + ">(" + to_string(inputs[0].get_index()) + ");\n" " auto arg0 = call_frame->get_tensor_view_data<" + element_type_names[TI(et)] + ">(" + to_string(inputs[0].get_index()) + ");\n"
...@@ -221,17 +229,20 @@ void Emitter::EMITTER_DECL(EmitMultiply) ...@@ -221,17 +229,20 @@ void Emitter::EMITTER_DECL(EmitMultiply)
void Emitter::EMITTER_DECL(EmitGetTupleElement) void Emitter::EMITTER_DECL(EmitGetTupleElement)
{ {
auto get_tuple_element = static_cast<const op::GetTupleElement*>(n); auto get_tuple_element = static_cast<const op::GetTupleElement*>(n);
auto result_tensor_type = auto result_tensor_type = dynamic_pointer_cast<const TensorViewType>(n->get_value_type());
dynamic_pointer_cast<const TensorViewType>(n->get_value_type());
assert(result_tensor_type); assert(result_tensor_type);
auto& result_element_type = result_tensor_type->get_element_type(); auto& result_element_type = result_tensor_type->get_element_type();
TU += " {\n" TU +=
" call_frame->get_parameterized_tensor_view<" + element_type_names[TI(result_element_type)] + ">(" + " {\n"
to_string(outputs.at(0).get_index()) + ")->get_vector() =\n" " call_frame->get_parameterized_tensor_view<" +
" call_frame->get_parameterized_tensor_view<" + element_type_names[TI(result_element_type)] + ">(" + element_type_names[TI(result_element_type)] + ">(" + to_string(outputs.at(0).get_index()) +
to_string(inputs.at(get_tuple_element->get_n()).get_index()) + ")->get_vector();\n" ")->get_vector() =\n"
" }\n"; " call_frame->get_parameterized_tensor_view<" +
element_type_names[TI(result_element_type)] + ">(" +
to_string(inputs.at(get_tuple_element->get_n()).get_index()) +
")->get_vector();\n"
" }\n";
} }
void Emitter::EMITTER_DECL(EmitTuple) void Emitter::EMITTER_DECL(EmitTuple)
...@@ -242,19 +253,21 @@ void Emitter::EMITTER_DECL(EmitTuple) ...@@ -242,19 +253,21 @@ void Emitter::EMITTER_DECL(EmitTuple)
for (size_t i = 0; i < inputs.size(); ++i) for (size_t i = 0; i < inputs.size(); ++i)
{ {
auto& et = inputs.at(i).get_tensor_view_layout()->get_element_type(); auto& et = inputs.at(i).get_tensor_view_layout()->get_element_type();
TU += " call_frame->get_parameterized_tensor_view<" + element_type_names[TI(et)] + ">(" + TU += " call_frame->get_parameterized_tensor_view<" + element_type_names[TI(et)] +
to_string(outputs.at(i).get_index()) + ")->get_vector() =\n" ">(" + to_string(outputs.at(i).get_index()) +
" call_frame->get_parameterized_tensor_view<" + element_type_names[TI(et)] + ">(" + ")->get_vector() =\n"
to_string(inputs.at(i).get_index()) + ")->get_vector();\n"; " call_frame->get_parameterized_tensor_view<" +
element_type_names[TI(et)] + ">(" + to_string(inputs.at(i).get_index()) +
")->get_vector();\n";
} }
TU += " }\n"; TU += " }\n";
} }
void Emitter::EMITTER_DECL(EmitAbs) void Emitter::EMITTER_DECL(EmitAbs)
{ {
const element::Type& et = (dynamic_pointer_cast<const TensorViewType>( const element::Type& et =
n->get_arguments().at(0)->get_value_type())) (dynamic_pointer_cast<const TensorViewType>(n->get_arguments().at(0)->get_value_type()))
->get_element_type(); ->get_element_type();
TU += " {\n" TU += " {\n"
" auto arg0 = call_frame->get_tensor_view_data<" + element_type_names[TI(et)] + ">(" + to_string(inputs[0].get_index()) + ");\n" " auto arg0 = call_frame->get_tensor_view_data<" + element_type_names[TI(et)] + ">(" + to_string(inputs[0].get_index()) + ");\n"
...@@ -268,8 +281,7 @@ void Emitter::EMITTER_DECL(EmitAbs) ...@@ -268,8 +281,7 @@ void Emitter::EMITTER_DECL(EmitAbs)
void Emitter::EMITTER_DECL(EmitConcat) void Emitter::EMITTER_DECL(EmitConcat)
{ {
auto result_tensor_type = auto result_tensor_type = dynamic_pointer_cast<const TensorViewType>(n->get_value_type());
dynamic_pointer_cast<const TensorViewType>(n->get_value_type());
assert(result_tensor_type); assert(result_tensor_type);
auto result_shape = result_tensor_type->get_shape(); auto result_shape = result_tensor_type->get_shape();
...@@ -277,21 +289,30 @@ void Emitter::EMITTER_DECL(EmitConcat) ...@@ -277,21 +289,30 @@ void Emitter::EMITTER_DECL(EmitConcat)
if (result_shape.size() == 1) if (result_shape.size() == 1)
{ {
TU += " {\n" TU +=
" auto out = call_frame->get_tensor_view_data<" + element_type_names[TI(result_element_type)] + " {\n"
">(" + to_string(outputs[0].get_index()) + ");\n" " auto out = call_frame->get_tensor_view_data<" +
" EigenVector<" + element_type_names[TI(result_element_type)] + "> out_vector(out, " element_type_names[TI(result_element_type)] + ">(" + to_string(outputs[0].get_index()) +
EIGEN_VECTOR_FORMAT(outputs[0].get_layout<DenseTensorViewLayout>()->get_size()) ");\n"; ");\n"
" EigenVector<" +
element_type_names[TI(result_element_type)] +
"> out_vector(out, " EIGEN_VECTOR_FORMAT(
outputs[0].get_layout<DenseTensorViewLayout>()->get_size()) ");\n";
size_t concat_pos = 0; size_t concat_pos = 0;
for (size_t i = 0; i < inputs.size(); i++) for (size_t i = 0; i < inputs.size(); i++)
{ {
TU += " out_vector.segment(" + to_string(concat_pos) + ", " + TU += " out_vector.segment(" + to_string(concat_pos) + ", " +
to_string(inputs[i].get_tensor_view_layout()->get_shape().at(0)) + ") << " to_string(inputs[i].get_tensor_view_layout()->get_shape().at(0)) +
"EigenVector<" + element_type_names[TI(result_element_type)] + ">(call_frame->" ") << "
"get_tensor_view_data<" + element_type_names[TI(result_element_type)] + ">(" + "EigenVector<" +
to_string(inputs[i].get_index()) + "), " element_type_names[TI(result_element_type)] +
EIGEN_VECTOR_FORMAT(inputs[i].get_layout<DenseTensorViewLayout>()->get_size()) ");\n"; ">(call_frame->"
"get_tensor_view_data<" +
element_type_names[TI(result_element_type)] + ">(" +
to_string(inputs[i].get_index()) +
"), " EIGEN_VECTOR_FORMAT(
inputs[i].get_layout<DenseTensorViewLayout>()->get_size()) ");\n";
concat_pos += inputs[i].get_tensor_view_layout()->get_shape().at(0); concat_pos += inputs[i].get_tensor_view_layout()->get_shape().at(0);
} }
...@@ -302,11 +323,14 @@ void Emitter::EMITTER_DECL(EmitConcat) ...@@ -302,11 +323,14 @@ void Emitter::EMITTER_DECL(EmitConcat)
auto out_layout = outputs[0].get_layout<DenseTensorViewLayout>(); auto out_layout = outputs[0].get_layout<DenseTensorViewLayout>();
auto axis = (dynamic_cast<const op::Concat*>(n))->get_concatenation_axis(); auto axis = (dynamic_cast<const op::Concat*>(n))->get_concatenation_axis();
TU += " {\n" TU +=
" auto out = call_frame->get_tensor_view_data<" + element_type_names[TI(result_element_type)] + " {\n"
">(" + to_string(outputs[0].get_index()) + ");\n" " auto out = call_frame->get_tensor_view_data<" +
" EigenMatrix<" + element_type_names[TI(result_element_type)] + "> out_matrix(out, " + element_type_names[TI(result_element_type)] + ">(" + to_string(outputs[0].get_index()) +
EIGEN_MATRIX_FORMAT(out_layout->get_shape(), out_layout->get_strides()) + ");\n"; ");\n"
" EigenMatrix<" +
element_type_names[TI(result_element_type)] + "> out_matrix(out, " +
EIGEN_MATRIX_FORMAT(out_layout->get_shape(), out_layout->get_strides()) + ");\n";
size_t concat_pos[2]{0, 0}; size_t concat_pos[2]{0, 0};
for (size_t i = 0; i < inputs.size(); i++) for (size_t i = 0; i < inputs.size(); i++)
...@@ -316,9 +340,13 @@ void Emitter::EMITTER_DECL(EmitConcat) ...@@ -316,9 +340,13 @@ void Emitter::EMITTER_DECL(EmitConcat)
TU += " out_matrix.block(" + to_string(concat_pos[0]) + ", " + TU += " out_matrix.block(" + to_string(concat_pos[0]) + ", " +
to_string(concat_pos[1]) + ", " + to_string(arg_shape.at(0)) + ", " + to_string(concat_pos[1]) + ", " + to_string(arg_shape.at(0)) + ", " +
to_string(arg_shape.at(1)) + ") << " to_string(arg_shape.at(1)) +
"EigenMatrix<" + element_type_names[TI(result_element_type)] + ">(call_frame->" ") << "
"get_tensor_view_data<" + element_type_names[TI(result_element_type)] + ">(" + "EigenMatrix<" +
element_type_names[TI(result_element_type)] +
">(call_frame->"
"get_tensor_view_data<" +
element_type_names[TI(result_element_type)] + ">(" +
to_string(inputs[i].get_index()) + "), " + to_string(inputs[i].get_index()) + "), " +
EIGEN_MATRIX_FORMAT(arg_layout->get_shape(), arg_layout->get_strides()) + ");\n"; EIGEN_MATRIX_FORMAT(arg_layout->get_shape(), arg_layout->get_strides()) + ");\n";
...@@ -331,9 +359,9 @@ void Emitter::EMITTER_DECL(EmitConcat) ...@@ -331,9 +359,9 @@ void Emitter::EMITTER_DECL(EmitConcat)
void Emitter::EMITTER_DECL(EmitDivide) void Emitter::EMITTER_DECL(EmitDivide)
{ {
const element::Type& et = (dynamic_pointer_cast<const TensorViewType>( const element::Type& et =
n->get_arguments().at(0)->get_value_type())) (dynamic_pointer_cast<const TensorViewType>(n->get_arguments().at(0)->get_value_type()))
->get_element_type(); ->get_element_type();
TU += " {\n" TU += " {\n"
" auto arg0 = call_frame->get_tensor_view_data<" + element_type_names[TI(et)] + ">(" + to_string(inputs[0].get_index()) + ");\n" " auto arg0 = call_frame->get_tensor_view_data<" + element_type_names[TI(et)] + ">(" + to_string(inputs[0].get_index()) + ");\n"
...@@ -350,9 +378,9 @@ void Emitter::EMITTER_DECL(EmitDivide) ...@@ -350,9 +378,9 @@ void Emitter::EMITTER_DECL(EmitDivide)
void Emitter::EMITTER_DECL(EmitEqual) void Emitter::EMITTER_DECL(EmitEqual)
{ {
const element::Type& et = (dynamic_pointer_cast<const TensorViewType>( const element::Type& et =
n->get_arguments().at(0)->get_value_type())) (dynamic_pointer_cast<const TensorViewType>(n->get_arguments().at(0)->get_value_type()))
->get_element_type(); ->get_element_type();
TU += " {\n" TU += " {\n"
" auto arg0 = call_frame->get_tensor_view_data<" + element_type_names[TI(et)] + ">(" + to_string(inputs[0].get_index()) + ");\n" " auto arg0 = call_frame->get_tensor_view_data<" + element_type_names[TI(et)] + ">(" + to_string(inputs[0].get_index()) + ");\n"
...@@ -369,9 +397,9 @@ void Emitter::EMITTER_DECL(EmitEqual) ...@@ -369,9 +397,9 @@ void Emitter::EMITTER_DECL(EmitEqual)
void Emitter::EMITTER_DECL(EmitGreater) void Emitter::EMITTER_DECL(EmitGreater)
{ {
const element::Type& et = (dynamic_pointer_cast<const TensorViewType>( const element::Type& et =
n->get_arguments().at(0)->get_value_type())) (dynamic_pointer_cast<const TensorViewType>(n->get_arguments().at(0)->get_value_type()))
->get_element_type(); ->get_element_type();
TU += " {\n" TU += " {\n"
" auto arg0 = call_frame->get_tensor_view_data<" + element_type_names[TI(et)] + ">(" + to_string(inputs[0].get_index()) + ");\n" " auto arg0 = call_frame->get_tensor_view_data<" + element_type_names[TI(et)] + ">(" + to_string(inputs[0].get_index()) + ");\n"
...@@ -388,9 +416,9 @@ void Emitter::EMITTER_DECL(EmitGreater) ...@@ -388,9 +416,9 @@ void Emitter::EMITTER_DECL(EmitGreater)
void Emitter::EMITTER_DECL(EmitGreaterEq) void Emitter::EMITTER_DECL(EmitGreaterEq)
{ {
const element::Type& et = (dynamic_pointer_cast<const TensorViewType>( const element::Type& et =
n->get_arguments().at(0)->get_value_type())) (dynamic_pointer_cast<const TensorViewType>(n->get_arguments().at(0)->get_value_type()))
->get_element_type(); ->get_element_type();
TU += " {\n" TU += " {\n"
" auto arg0 = call_frame->get_tensor_view_data<" + element_type_names[TI(et)] + ">(" + to_string(inputs[0].get_index()) + ");\n" " auto arg0 = call_frame->get_tensor_view_data<" + element_type_names[TI(et)] + ">(" + to_string(inputs[0].get_index()) + ");\n"
...@@ -407,9 +435,9 @@ void Emitter::EMITTER_DECL(EmitGreaterEq) ...@@ -407,9 +435,9 @@ void Emitter::EMITTER_DECL(EmitGreaterEq)
void Emitter::EMITTER_DECL(EmitLess) void Emitter::EMITTER_DECL(EmitLess)
{ {
const element::Type& et = (dynamic_pointer_cast<const TensorViewType>( const element::Type& et =
n->get_arguments().at(0)->get_value_type())) (dynamic_pointer_cast<const TensorViewType>(n->get_arguments().at(0)->get_value_type()))
->get_element_type(); ->get_element_type();
TU += " {\n" TU += " {\n"
" auto arg0 = call_frame->get_tensor_view_data<" + element_type_names[TI(et)] + ">(" + to_string(inputs[0].get_index()) + ");\n" " auto arg0 = call_frame->get_tensor_view_data<" + element_type_names[TI(et)] + ">(" + to_string(inputs[0].get_index()) + ");\n"
...@@ -426,9 +454,9 @@ void Emitter::EMITTER_DECL(EmitLess) ...@@ -426,9 +454,9 @@ void Emitter::EMITTER_DECL(EmitLess)
void Emitter::EMITTER_DECL(EmitLessEq) void Emitter::EMITTER_DECL(EmitLessEq)
{ {
const element::Type& et = (dynamic_pointer_cast<const TensorViewType>( const element::Type& et =
n->get_arguments().at(0)->get_value_type())) (dynamic_pointer_cast<const TensorViewType>(n->get_arguments().at(0)->get_value_type()))
->get_element_type(); ->get_element_type();
TU += " {\n" TU += " {\n"
" auto arg0 = call_frame->get_tensor_view_data<" + element_type_names[TI(et)] + ">(" + to_string(inputs[0].get_index()) + ");\n" " auto arg0 = call_frame->get_tensor_view_data<" + element_type_names[TI(et)] + ">(" + to_string(inputs[0].get_index()) + ");\n"
...@@ -445,9 +473,9 @@ void Emitter::EMITTER_DECL(EmitLessEq) ...@@ -445,9 +473,9 @@ void Emitter::EMITTER_DECL(EmitLessEq)
void Emitter::EMITTER_DECL(EmitLog) void Emitter::EMITTER_DECL(EmitLog)
{ {
const element::Type& et = (dynamic_pointer_cast<const TensorViewType>( const element::Type& et =
n->get_arguments().at(0)->get_value_type())) (dynamic_pointer_cast<const TensorViewType>(n->get_arguments().at(0)->get_value_type()))
->get_element_type(); ->get_element_type();
TU += " {\n" TU += " {\n"
" auto arg0 = call_frame->get_tensor_view_data<" + element_type_names[TI(et)] + ">(" + to_string(inputs[0].get_index()) + ");\n" " auto arg0 = call_frame->get_tensor_view_data<" + element_type_names[TI(et)] + ">(" + to_string(inputs[0].get_index()) + ");\n"
...@@ -461,9 +489,9 @@ void Emitter::EMITTER_DECL(EmitLog) ...@@ -461,9 +489,9 @@ void Emitter::EMITTER_DECL(EmitLog)
void Emitter::EMITTER_DECL(EmitMaximum) void Emitter::EMITTER_DECL(EmitMaximum)
{ {
const element::Type& et = (dynamic_pointer_cast<const TensorViewType>( const element::Type& et =
n->get_arguments().at(0)->get_value_type())) (dynamic_pointer_cast<const TensorViewType>(n->get_arguments().at(0)->get_value_type()))
->get_element_type(); ->get_element_type();
TU += " {\n" TU += " {\n"
" auto arg0 = call_frame->get_tensor_view_data<" + element_type_names[TI(et)] + ">(" + to_string(inputs[0].get_index()) + ");\n" " auto arg0 = call_frame->get_tensor_view_data<" + element_type_names[TI(et)] + ">(" + to_string(inputs[0].get_index()) + ");\n"
...@@ -480,9 +508,9 @@ void Emitter::EMITTER_DECL(EmitMaximum) ...@@ -480,9 +508,9 @@ void Emitter::EMITTER_DECL(EmitMaximum)
void Emitter::EMITTER_DECL(EmitNegative) void Emitter::EMITTER_DECL(EmitNegative)
{ {
const element::Type& et = (dynamic_pointer_cast<const TensorViewType>( const element::Type& et =
n->get_arguments().at(0)->get_value_type())) (dynamic_pointer_cast<const TensorViewType>(n->get_arguments().at(0)->get_value_type()))
->get_element_type(); ->get_element_type();
TU += " {\n" TU += " {\n"
" auto arg0 = call_frame->get_tensor_view_data<" + element_type_names[TI(et)] + ">(" + to_string(inputs[0].get_index()) + ");\n" " auto arg0 = call_frame->get_tensor_view_data<" + element_type_names[TI(et)] + ">(" + to_string(inputs[0].get_index()) + ");\n"
...@@ -496,9 +524,9 @@ void Emitter::EMITTER_DECL(EmitNegative) ...@@ -496,9 +524,9 @@ void Emitter::EMITTER_DECL(EmitNegative)
void Emitter::EMITTER_DECL(EmitNotEqual) void Emitter::EMITTER_DECL(EmitNotEqual)
{ {
const element::Type& et = (dynamic_pointer_cast<const TensorViewType>( const element::Type& et =
n->get_arguments().at(0)->get_value_type())) (dynamic_pointer_cast<const TensorViewType>(n->get_arguments().at(0)->get_value_type()))
->get_element_type(); ->get_element_type();
TU += " {\n" TU += " {\n"
" auto arg0 = call_frame->get_tensor_view_data<" + element_type_names[TI(et)] + ">(" + to_string(inputs[0].get_index()) + ");\n" " auto arg0 = call_frame->get_tensor_view_data<" + element_type_names[TI(et)] + ">(" + to_string(inputs[0].get_index()) + ");\n"
...@@ -515,9 +543,9 @@ void Emitter::EMITTER_DECL(EmitNotEqual) ...@@ -515,9 +543,9 @@ void Emitter::EMITTER_DECL(EmitNotEqual)
void Emitter::EMITTER_DECL(EmitSelect) void Emitter::EMITTER_DECL(EmitSelect)
{ {
const element::Type& et = (dynamic_pointer_cast<const TensorViewType>( const element::Type& et =
n->get_arguments().at(1)->get_value_type())) (dynamic_pointer_cast<const TensorViewType>(n->get_arguments().at(1)->get_value_type()))
->get_element_type(); ->get_element_type();
TU += " {\n" TU += " {\n"
" auto arg0 = call_frame->get_tensor_view_data<Bool>(" + to_string(inputs[0].get_index()) + ");\n" " auto arg0 = call_frame->get_tensor_view_data<Bool>(" + to_string(inputs[0].get_index()) + ");\n"
...@@ -536,9 +564,9 @@ void Emitter::EMITTER_DECL(EmitSelect) ...@@ -536,9 +564,9 @@ void Emitter::EMITTER_DECL(EmitSelect)
void Emitter::EMITTER_DECL(EmitSubtract) void Emitter::EMITTER_DECL(EmitSubtract)
{ {
const element::Type& et = (dynamic_pointer_cast<const TensorViewType>( const element::Type& et =
n->get_arguments().at(0)->get_value_type())) (dynamic_pointer_cast<const TensorViewType>(n->get_arguments().at(0)->get_value_type()))
->get_element_type(); ->get_element_type();
TU += " {\n" TU += " {\n"
" auto arg0 = call_frame->get_tensor_view_data<" + element_type_names[TI(et)] + ">(" + to_string(inputs[0].get_index()) + ");\n" " auto arg0 = call_frame->get_tensor_view_data<" + element_type_names[TI(et)] + ">(" + to_string(inputs[0].get_index()) + ");\n"
...@@ -555,12 +583,16 @@ void Emitter::EMITTER_DECL(EmitSubtract) ...@@ -555,12 +583,16 @@ void Emitter::EMITTER_DECL(EmitSubtract)
void Emitter::EMITTER_DECL(EmitParameterizedConstantBool) void Emitter::EMITTER_DECL(EmitParameterizedConstantBool)
{ {
auto value = dynamic_cast<const op::ParameterizedConstant<ngraph::element::Bool>*>(n)->get_value()->get_vector(); auto value = dynamic_cast<const op::ParameterizedConstant<ngraph::element::Bool>*>(n)
->get_value()
->get_vector();
TU += " {\n" TU +=
" call_frame->get_parameterized_tensor_view<" + element_type_names[TI(ngraph::element::Bool)] + " {\n"
">(" + to_string(outputs[0].get_index()) + ")->get_vector() = std::vector<" + element_type_names[TI(ngraph::element::Bool)] + " call_frame->get_parameterized_tensor_view<" +
"::type>{"; element_type_names[TI(ngraph::element::Bool)] + ">(" + to_string(outputs[0].get_index()) +
")->get_vector() = std::vector<" + element_type_names[TI(ngraph::element::Bool)] +
"::type>{";
for (size_t i = 0; i < value.size(); i++) for (size_t i = 0; i < value.size(); i++)
{ {
...@@ -581,12 +613,16 @@ void Emitter::EMITTER_DECL(EmitParameterizedConstantBool) ...@@ -581,12 +613,16 @@ void Emitter::EMITTER_DECL(EmitParameterizedConstantBool)
void Emitter::EMITTER_DECL(EmitParameterizedConstantFloat32) void Emitter::EMITTER_DECL(EmitParameterizedConstantFloat32)
{ {
auto value = dynamic_cast<const op::ParameterizedConstant<ngraph::element::Float32>*>(n)->get_value()->get_vector(); auto value = dynamic_cast<const op::ParameterizedConstant<ngraph::element::Float32>*>(n)
->get_value()
->get_vector();
TU += " {\n" TU +=
" call_frame->get_parameterized_tensor_view<" + element_type_names[TI(ngraph::element::Float32)] + " {\n"
">(" + to_string(outputs[0].get_index()) + ")->get_vector() = std::vector<" + element_type_names[TI(ngraph::element::Float32)] + " call_frame->get_parameterized_tensor_view<" +
"::type>{"; element_type_names[TI(ngraph::element::Float32)] + ">(" +
to_string(outputs[0].get_index()) + ")->get_vector() = std::vector<" +
element_type_names[TI(ngraph::element::Float32)] + "::type>{";
for (size_t i = 0; i < value.size(); i++) for (size_t i = 0; i < value.size(); i++)
{ {
...@@ -600,12 +636,16 @@ void Emitter::EMITTER_DECL(EmitParameterizedConstantFloat32) ...@@ -600,12 +636,16 @@ void Emitter::EMITTER_DECL(EmitParameterizedConstantFloat32)
void Emitter::EMITTER_DECL(EmitParameterizedConstantInt8) void Emitter::EMITTER_DECL(EmitParameterizedConstantInt8)
{ {
auto value = dynamic_cast<const op::ParameterizedConstant<ngraph::element::Int8>*>(n)->get_value()->get_vector(); auto value = dynamic_cast<const op::ParameterizedConstant<ngraph::element::Int8>*>(n)
->get_value()
->get_vector();
TU += " {\n" TU +=
" call_frame->get_parameterized_tensor_view<" + element_type_names[TI(ngraph::element::Int8)] + " {\n"
">(" + to_string(outputs[0].get_index()) + ")->get_vector() = std::vector<" + element_type_names[TI(ngraph::element::Int8)] + " call_frame->get_parameterized_tensor_view<" +
"::type>{"; element_type_names[TI(ngraph::element::Int8)] + ">(" + to_string(outputs[0].get_index()) +
")->get_vector() = std::vector<" + element_type_names[TI(ngraph::element::Int8)] +
"::type>{";
for (size_t i = 0; i < value.size(); i++) for (size_t i = 0; i < value.size(); i++)
{ {
...@@ -619,12 +659,16 @@ void Emitter::EMITTER_DECL(EmitParameterizedConstantInt8) ...@@ -619,12 +659,16 @@ void Emitter::EMITTER_DECL(EmitParameterizedConstantInt8)
void Emitter::EMITTER_DECL(EmitParameterizedConstantInt32) void Emitter::EMITTER_DECL(EmitParameterizedConstantInt32)
{ {
auto value = dynamic_cast<const op::ParameterizedConstant<ngraph::element::Int32>*>(n)->get_value()->get_vector(); auto value = dynamic_cast<const op::ParameterizedConstant<ngraph::element::Int32>*>(n)
->get_value()
->get_vector();
TU += " {\n" TU +=
" call_frame->get_parameterized_tensor_view<" + element_type_names[TI(ngraph::element::Int32)] + " {\n"
">(" + to_string(outputs[0].get_index()) + ")->get_vector() = std::vector<" + element_type_names[TI(ngraph::element::Int32)] + " call_frame->get_parameterized_tensor_view<" +
"::type>{"; element_type_names[TI(ngraph::element::Int32)] + ">(" + to_string(outputs[0].get_index()) +
")->get_vector() = std::vector<" + element_type_names[TI(ngraph::element::Int32)] +
"::type>{";
for (size_t i = 0; i < value.size(); i++) for (size_t i = 0; i < value.size(); i++)
{ {
...@@ -638,12 +682,16 @@ void Emitter::EMITTER_DECL(EmitParameterizedConstantInt32) ...@@ -638,12 +682,16 @@ void Emitter::EMITTER_DECL(EmitParameterizedConstantInt32)
void Emitter::EMITTER_DECL(EmitParameterizedConstantInt64) void Emitter::EMITTER_DECL(EmitParameterizedConstantInt64)
{ {
auto value = dynamic_cast<const op::ParameterizedConstant<ngraph::element::Int64>*>(n)->get_value()->get_vector(); auto value = dynamic_cast<const op::ParameterizedConstant<ngraph::element::Int64>*>(n)
->get_value()
->get_vector();
TU += " {\n" TU +=
" call_frame->get_parameterized_tensor_view<" + element_type_names[TI(ngraph::element::Int64)] + " {\n"
">(" + to_string(outputs[0].get_index()) + ")->get_vector() = std::vector<" + element_type_names[TI(ngraph::element::Int64)] + " call_frame->get_parameterized_tensor_view<" +
"::type>{"; element_type_names[TI(ngraph::element::Int64)] + ">(" + to_string(outputs[0].get_index()) +
")->get_vector() = std::vector<" + element_type_names[TI(ngraph::element::Int64)] +
"::type>{";
for (size_t i = 0; i < value.size(); i++) for (size_t i = 0; i < value.size(); i++)
{ {
...@@ -657,12 +705,16 @@ void Emitter::EMITTER_DECL(EmitParameterizedConstantInt64) ...@@ -657,12 +705,16 @@ void Emitter::EMITTER_DECL(EmitParameterizedConstantInt64)
void Emitter::EMITTER_DECL(EmitParameterizedConstantUInt8) void Emitter::EMITTER_DECL(EmitParameterizedConstantUInt8)
{ {
auto value = dynamic_cast<const op::ParameterizedConstant<ngraph::element::UInt8>*>(n)->get_value()->get_vector(); auto value = dynamic_cast<const op::ParameterizedConstant<ngraph::element::UInt8>*>(n)
->get_value()
->get_vector();
TU += " {\n" TU +=
" call_frame->get_parameterized_tensor_view<" + element_type_names[TI(ngraph::element::UInt8)] + " {\n"
">(" + to_string(outputs[0].get_index()) + ")->get_vector() = std::vector<" + element_type_names[TI(ngraph::element::UInt8)] + " call_frame->get_parameterized_tensor_view<" +
"::type>{"; element_type_names[TI(ngraph::element::UInt8)] + ">(" + to_string(outputs[0].get_index()) +
")->get_vector() = std::vector<" + element_type_names[TI(ngraph::element::UInt8)] +
"::type>{";
for (size_t i = 0; i < value.size(); i++) for (size_t i = 0; i < value.size(); i++)
{ {
...@@ -676,12 +728,16 @@ void Emitter::EMITTER_DECL(EmitParameterizedConstantUInt8) ...@@ -676,12 +728,16 @@ void Emitter::EMITTER_DECL(EmitParameterizedConstantUInt8)
void Emitter::EMITTER_DECL(EmitParameterizedConstantUInt32) void Emitter::EMITTER_DECL(EmitParameterizedConstantUInt32)
{ {
auto value = dynamic_cast<const op::ParameterizedConstant<ngraph::element::UInt32>*>(n)->get_value()->get_vector(); auto value = dynamic_cast<const op::ParameterizedConstant<ngraph::element::UInt32>*>(n)
->get_value()
->get_vector();
TU += " {\n" TU +=
" call_frame->get_parameterized_tensor_view<" + element_type_names[TI(ngraph::element::UInt32)] + " {\n"
">(" + to_string(outputs[0].get_index()) + ")->get_vector() = std::vector<" + element_type_names[TI(ngraph::element::UInt32)] + " call_frame->get_parameterized_tensor_view<" +
"::type>{"; element_type_names[TI(ngraph::element::UInt32)] + ">(" + to_string(outputs[0].get_index()) +
")->get_vector() = std::vector<" + element_type_names[TI(ngraph::element::UInt32)] +
"::type>{";
for (size_t i = 0; i < value.size(); i++) for (size_t i = 0; i < value.size(); i++)
{ {
...@@ -695,12 +751,16 @@ void Emitter::EMITTER_DECL(EmitParameterizedConstantUInt32) ...@@ -695,12 +751,16 @@ void Emitter::EMITTER_DECL(EmitParameterizedConstantUInt32)
void Emitter::EMITTER_DECL(EmitParameterizedConstantUInt64) void Emitter::EMITTER_DECL(EmitParameterizedConstantUInt64)
{ {
auto value = dynamic_cast<const op::ParameterizedConstant<ngraph::element::UInt64>*>(n)->get_value()->get_vector(); auto value = dynamic_cast<const op::ParameterizedConstant<ngraph::element::UInt64>*>(n)
->get_value()
TU += " {\n" ->get_vector();
" call_frame->get_parameterized_tensor_view<" + element_type_names[TI(ngraph::element::UInt64)] +
">(" + to_string(outputs[0].get_index()) + ")->get_vector() = std::vector<" + element_type_names[TI(ngraph::element::UInt64)] + TU +=
"::type>{"; " {\n"
" call_frame->get_parameterized_tensor_view<" +
element_type_names[TI(ngraph::element::UInt64)] + ">(" + to_string(outputs[0].get_index()) +
")->get_vector() = std::vector<" + element_type_names[TI(ngraph::element::UInt64)] +
"::type>{";
for (size_t i = 0; i < value.size(); i++) for (size_t i = 0; i < value.size(); i++)
{ {
......
...@@ -14,19 +14,19 @@ ...@@ -14,19 +14,19 @@
#pragma once #pragma once
#include <vector>
#include <string> #include <string>
#include <vector>
#include "ngraph/node.hpp" #include "ngraph/node.hpp"
#include "ngraph/runtime/tensor_view_info.hpp"
#include "ngraph/runtime/cpu/external_function.hpp" #include "ngraph/runtime/cpu/external_function.hpp"
#include "ngraph/runtime/tensor_view_info.hpp"
#define EMITTER_DECL(E) E(const ngraph::Node* n, \ #define EMITTER_DECL(E) \
ExternalFunction* ef, \ E(const ngraph::Node* n, \
FunctionMap& function_map, \ ExternalFunction* ef, \
const std::vector<TensorViewInfo>& inputs, \ FunctionMap& function_map, \
const std::vector<TensorViewInfo>& outputs) const std::vector<TensorViewInfo>& inputs, \
const std::vector<TensorViewInfo>& outputs)
namespace ngraph namespace ngraph
{ {
...@@ -40,9 +40,11 @@ namespace ngraph ...@@ -40,9 +40,11 @@ namespace ngraph
std::string TU; std::string TU;
public: public:
Emitter() : TU("") { } Emitter()
: TU("")
{
}
std::string& GetTU() { return TU; } std::string& GetTU() { return TU; }
void EMITTER_DECL(EmitNop); void EMITTER_DECL(EmitNop);
void EMITTER_DECL(EmitAdd); void EMITTER_DECL(EmitAdd);
void EMITTER_DECL(EmitDot); void EMITTER_DECL(EmitDot);
...@@ -71,7 +73,6 @@ namespace ngraph ...@@ -71,7 +73,6 @@ namespace ngraph
void EMITTER_DECL(EmitParameterizedConstantUInt8); void EMITTER_DECL(EmitParameterizedConstantUInt8);
void EMITTER_DECL(EmitParameterizedConstantUInt32); void EMITTER_DECL(EmitParameterizedConstantUInt32);
void EMITTER_DECL(EmitParameterizedConstantUInt64); void EMITTER_DECL(EmitParameterizedConstantUInt64);
}; };
} }
} }
......
...@@ -12,13 +12,13 @@ ...@@ -12,13 +12,13 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
#include <fstream>
#include <memory> #include <memory>
#include <string>
#include <tuple> #include <tuple>
#include <typeindex> #include <typeindex>
#include <typeinfo> #include <typeinfo>
#include <unordered_map> #include <unordered_map>
#include <string>
#include <fstream>
#include "ngraph/codegen/compiler.hpp" #include "ngraph/codegen/compiler.hpp"
#include "ngraph/descriptor/input.hpp" #include "ngraph/descriptor/input.hpp"
...@@ -70,36 +70,45 @@ using ngraph::descriptor::layout::DenseTensorViewLayout; ...@@ -70,36 +70,45 @@ using ngraph::descriptor::layout::DenseTensorViewLayout;
#define TI(x) type_index(typeid(x)) #define TI(x) type_index(typeid(x))
static const OpMap dispatcher{{TI(ngraph::op::Add), &Emitter::EmitAdd}, static const OpMap dispatcher{
{TI(ngraph::op::Dot), &Emitter::EmitDot}, {TI(ngraph::op::Add), &Emitter::EmitAdd},
{TI(ngraph::op::Multiply), &Emitter::EmitMultiply}, {TI(ngraph::op::Dot), &Emitter::EmitDot},
{TI(ngraph::op::Parameter), &Emitter::EmitNop}, {TI(ngraph::op::Multiply), &Emitter::EmitMultiply},
{TI(ngraph::op::GetTupleElement), &Emitter::EmitGetTupleElement}, {TI(ngraph::op::Parameter), &Emitter::EmitNop},
{TI(ngraph::op::Tuple), &Emitter::EmitTuple}, {TI(ngraph::op::GetTupleElement), &Emitter::EmitGetTupleElement},
{TI(ngraph::op::Abs), &Emitter::EmitAbs}, {TI(ngraph::op::Tuple), &Emitter::EmitTuple},
{TI(ngraph::op::Concat), &Emitter::EmitConcat}, {TI(ngraph::op::Abs), &Emitter::EmitAbs},
{TI(ngraph::op::Divide), &Emitter::EmitDivide}, {TI(ngraph::op::Concat), &Emitter::EmitConcat},
{TI(ngraph::op::Equal), &Emitter::EmitEqual}, {TI(ngraph::op::Divide), &Emitter::EmitDivide},
{TI(ngraph::op::Greater), &Emitter::EmitGreater}, {TI(ngraph::op::Equal), &Emitter::EmitEqual},
{TI(ngraph::op::GreaterEq), &Emitter::EmitGreaterEq}, {TI(ngraph::op::Greater), &Emitter::EmitGreater},
{TI(ngraph::op::Less), &Emitter::EmitLess}, {TI(ngraph::op::GreaterEq), &Emitter::EmitGreaterEq},
{TI(ngraph::op::LessEq), &Emitter::EmitLessEq}, {TI(ngraph::op::Less), &Emitter::EmitLess},
{TI(ngraph::op::Log), &Emitter::EmitLog}, {TI(ngraph::op::LessEq), &Emitter::EmitLessEq},
{TI(ngraph::op::Maximum), &Emitter::EmitMaximum}, {TI(ngraph::op::Log), &Emitter::EmitLog},
{TI(ngraph::op::Negative), &Emitter::EmitNegative}, {TI(ngraph::op::Maximum), &Emitter::EmitMaximum},
{TI(ngraph::op::NotEqual), &Emitter::EmitNotEqual}, {TI(ngraph::op::Negative), &Emitter::EmitNegative},
{TI(ngraph::op::Select), &Emitter::EmitSelect}, {TI(ngraph::op::NotEqual), &Emitter::EmitNotEqual},
{TI(ngraph::op::Subtract), &Emitter::EmitSubtract}, {TI(ngraph::op::Select), &Emitter::EmitSelect},
{TI(ngraph::op::ParameterizedConstant<ngraph::element::Bool>), &Emitter::EmitParameterizedConstantBool}, {TI(ngraph::op::Subtract), &Emitter::EmitSubtract},
{TI(ngraph::op::ParameterizedConstant<ngraph::element::Float32>), &Emitter::EmitParameterizedConstantFloat32}, {TI(ngraph::op::ParameterizedConstant<ngraph::element::Bool>),
{TI(ngraph::op::ParameterizedConstant<ngraph::element::Int8>), &Emitter::EmitParameterizedConstantInt8}, &Emitter::EmitParameterizedConstantBool},
{TI(ngraph::op::ParameterizedConstant<ngraph::element::Int32>), &Emitter::EmitParameterizedConstantInt32}, {TI(ngraph::op::ParameterizedConstant<ngraph::element::Float32>),
{TI(ngraph::op::ParameterizedConstant<ngraph::element::Int64>), &Emitter::EmitParameterizedConstantInt64}, &Emitter::EmitParameterizedConstantFloat32},
{TI(ngraph::op::ParameterizedConstant<ngraph::element::UInt8>), &Emitter::EmitParameterizedConstantUInt8}, {TI(ngraph::op::ParameterizedConstant<ngraph::element::Int8>),
{TI(ngraph::op::ParameterizedConstant<ngraph::element::UInt32>), &Emitter::EmitParameterizedConstantUInt32}, &Emitter::EmitParameterizedConstantInt8},
{TI(ngraph::op::ParameterizedConstant<ngraph::element::UInt64>), &Emitter::EmitParameterizedConstantUInt64}, {TI(ngraph::op::ParameterizedConstant<ngraph::element::Int32>),
&Emitter::EmitParameterizedConstantInt32},
}; {TI(ngraph::op::ParameterizedConstant<ngraph::element::Int64>),
&Emitter::EmitParameterizedConstantInt64},
{TI(ngraph::op::ParameterizedConstant<ngraph::element::UInt8>),
&Emitter::EmitParameterizedConstantUInt8},
{TI(ngraph::op::ParameterizedConstant<ngraph::element::UInt32>),
&Emitter::EmitParameterizedConstantUInt32},
{TI(ngraph::op::ParameterizedConstant<ngraph::element::UInt64>),
&Emitter::EmitParameterizedConstantUInt64},
};
#undef TI #undef TI
...@@ -183,15 +192,15 @@ void ExternalFunction::compile(FunctionMap& function_map) ...@@ -183,15 +192,15 @@ void ExternalFunction::compile(FunctionMap& function_map)
Emitter emitter; Emitter emitter;
auto& TU = emitter.GetTU(); auto& TU = emitter.GetTU();
TU += R"( TU += R"(
#include <vector>
#include <memory> #include <memory>
#include <vector>
#include <Eigen/Dense> #include <Eigen/Dense>
#include "ngraph/descriptor/layout/dense_tensor_view_layout.hpp" #include "ngraph/descriptor/layout/dense_tensor_view_layout.hpp"
#include "ngraph/runtime/tensor_view_info.hpp"
#include "ngraph/runtime/cpu/call_frame.hpp" #include "ngraph/runtime/cpu/call_frame.hpp"
#include "ngraph/runtime/cpu/eigen_utils.hpp" #include "ngraph/runtime/cpu/eigen_utils.hpp"
#include "ngraph/runtime/tensor_view_info.hpp"
void *__dso_handle = 0; void *__dso_handle = 0;
...@@ -247,8 +256,8 @@ extern "C" void __entrypoint(ngraph::runtime::cpu::CallFrame* call_frame, ...@@ -247,8 +256,8 @@ extern "C" void __entrypoint(ngraph::runtime::cpu::CallFrame* call_frame,
assert(llvm_module); assert(llvm_module);
estate.add_module(llvm_module); estate.add_module(llvm_module);
estate.finalize(); estate.finalize();
compiled_function = estate.find_function<void(ngraph::runtime::cpu::CallFrame*, compiled_function = estate.find_function<void(
ngraph::runtime::TensorViewPtrs&)>("__entrypoint"); ngraph::runtime::cpu::CallFrame*, ngraph::runtime::TensorViewPtrs&)>("__entrypoint");
assert(compiled_function); assert(compiled_function);
m_is_compiled = true; m_is_compiled = true;
......
...@@ -14,14 +14,14 @@ ...@@ -14,14 +14,14 @@
#pragma once #pragma once
#include <functional>
#include <memory> #include <memory>
#include <typeindex> #include <typeindex>
#include <typeinfo> #include <typeinfo>
#include <unordered_map> #include <unordered_map>
#include <functional>
#include "ngraph/function.hpp"
#include "ngraph/codegen/compiler.hpp" #include "ngraph/codegen/compiler.hpp"
#include "ngraph/function.hpp"
#include "ngraph/runtime/external_function.hpp" #include "ngraph/runtime/external_function.hpp"
#include "ngraph/runtime/tensor_view_info.hpp" #include "ngraph/runtime/tensor_view_info.hpp"
...@@ -35,8 +35,8 @@ namespace ngraph ...@@ -35,8 +35,8 @@ namespace ngraph
class Emitter; class Emitter;
class CallFrame; class CallFrame;
using FunctionMap = std::unordered_map<std::shared_ptr<Function>, using FunctionMap =
std::shared_ptr<ExternalFunction>>; std::unordered_map<std::shared_ptr<Function>, std::shared_ptr<ExternalFunction>>;
using OpFunction = std::function<void(Emitter*, using OpFunction = std::function<void(Emitter*,
const ngraph::Node*, const ngraph::Node*,
...@@ -47,7 +47,8 @@ namespace ngraph ...@@ -47,7 +47,8 @@ namespace ngraph
using OpMap = std::unordered_map<std::type_index, OpFunction>; using OpMap = std::unordered_map<std::type_index, OpFunction>;
using EntryPoint = std::function<void(ngraph::runtime::cpu::CallFrame*, ngraph::runtime::TensorViewPtrs&)>; using EntryPoint = std::function<void(ngraph::runtime::cpu::CallFrame*,
ngraph::runtime::TensorViewPtrs&)>;
class ExternalFunction : public ngraph::runtime::ExternalFunction class ExternalFunction : public ngraph::runtime::ExternalFunction
{ {
...@@ -55,6 +56,7 @@ namespace ngraph ...@@ -55,6 +56,7 @@ namespace ngraph
ExternalFunction(const std::shared_ptr<ngraph::Function>& function, ExternalFunction(const std::shared_ptr<ngraph::Function>& function,
bool release_function = true); bool release_function = true);
std::shared_ptr<ngraph::runtime::CallFrame> make_call_frame(); std::shared_ptr<ngraph::runtime::CallFrame> make_call_frame();
protected: protected:
void compile(FunctionMap& function_map); void compile(FunctionMap& function_map);
......
...@@ -803,7 +803,6 @@ TEST(cpu, greater) ...@@ -803,7 +803,6 @@ TEST(cpu, greater)
ASSERT_EQ((vector<char>{0, 1, 0, 1, 0, 1, 1, 0}), result->get_vector()); ASSERT_EQ((vector<char>{0, 1, 0, 1, 0, 1, 1, 0}), result->get_vector());
} }
TEST(cpu, greatereq) TEST(cpu, greatereq)
{ {
auto shape = Shape{2, 2, 2}; 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