Commit 95312b8e authored by Fenglei's avatar Fenglei Committed by Robert Kimball

gpu emitter using template function (#610)

* update gpu_emitter use template

* add template
parent b3d2ff59
This diff is collapsed.
...@@ -24,12 +24,12 @@ ...@@ -24,12 +24,12 @@
#include "ngraph/runtime/gpu/gpu_external_function.hpp" #include "ngraph/runtime/gpu/gpu_external_function.hpp"
#include "ngraph/runtime/gpu/gpu_tensor_view_wrapper.hpp" #include "ngraph/runtime/gpu/gpu_tensor_view_wrapper.hpp"
#define EMITTER_DECL(E) \ #define EMITTER_DECL(op_name) \
E(codegen::CodeWriter& writer, \ emit<op_name>(GPU_ExternalFunction * external_function, \
const ngraph::Node* n, \ codegen::CodeWriter & writer, \
const std::vector<ngraph::runtime::gpu::GPU_TensorViewWrapper>& args, \ const ngraph::Node* node, \
const std::vector<ngraph::runtime::gpu::GPU_TensorViewWrapper>& out) const std::vector<GPU_TensorViewWrapper>& args, \
const std::vector<GPU_TensorViewWrapper>& out)
namespace ngraph namespace ngraph
{ {
namespace runtime namespace runtime
...@@ -39,45 +39,30 @@ namespace ngraph ...@@ -39,45 +39,30 @@ namespace ngraph
class GPU_Emitter class GPU_Emitter
{ {
public: public:
static void EMITTER_DECL(EmitNop); template <typename OP>
static void EMITTER_DECL(EmitAdd); static void emit(GPU_ExternalFunction* external_function,
static void EMITTER_DECL(EmitDot); codegen::CodeWriter& writer,
static void EMITTER_DECL(EmitMultiply); const ngraph::Node* node,
static void EMITTER_DECL(EmitGetOutputElement); const std::vector<GPU_TensorViewWrapper>& args,
static void EMITTER_DECL(EmitXLAGetTupleElement); const std::vector<GPU_TensorViewWrapper>& out)
static void EMITTER_DECL(EmitUnaryElementwise); {
static void EMITTER_DECL(EmitTuple); throw std::runtime_error("Unimplemented op in GPU emitter for " +
static void EMITTER_DECL(EmitConcat); node->get_name());
static void EMITTER_DECL(EmitDivide); }
static void EMITTER_DECL(EmitEqual);
static void EMITTER_DECL(EmitGreater); static void nop(GPU_ExternalFunction* external_function,
static void EMITTER_DECL(EmitGreaterEq); codegen::CodeWriter& writer,
static void EMITTER_DECL(EmitLess); const ngraph::Node* node,
static void EMITTER_DECL(EmitLessEq); const std::vector<GPU_TensorViewWrapper>& args,
static void EMITTER_DECL(EmitMaximum); const std::vector<GPU_TensorViewWrapper>& out)
static void EMITTER_DECL(EmitMinimum); {
static void EMITTER_DECL(EmitNegative); }
static void EMITTER_DECL(EmitNotEqual);
static void EMITTER_DECL(EmitSelect); static void EmitUnaryElementwise(GPU_ExternalFunction* external_function,
static void EMITTER_DECL(EmitSubtract); codegen::CodeWriter& writer,
static void EMITTER_DECL(EmitBroadcast); const ngraph::Node* node,
static void EMITTER_DECL(EmitConvert); const std::vector<GPU_TensorViewWrapper>& args,
static void EMITTER_DECL(EmitConstant); const std::vector<GPU_TensorViewWrapper>& out);
static void EMITTER_DECL(EmitReshape);
static void EMITTER_DECL(EmitFunctionCall);
static void EMITTER_DECL(EmitReduce);
static void EMITTER_DECL(EmitSlice);
static void EMITTER_DECL(EmitSum);
static void EMITTER_DECL(EmitPower);
static void EMITTER_DECL(EmitReplaceSlice);
static void EMITTER_DECL(EmitOneHot);
static void EMITTER_DECL(EmitSqrt);
static void EMITTER_DECL(EmitConvolution);
static void EMITTER_DECL(EmitMaxPool);
static void EMITTER_DECL(EmitReverse);
static void EMITTER_DECL(EmitReduceWindow);
static void EMITTER_DECL(EmitSelectAndScatter);
static void EMITTER_DECL(EmitResult);
}; };
} }
} }
......
...@@ -41,7 +41,8 @@ namespace ngraph ...@@ -41,7 +41,8 @@ namespace ngraph
class GPU_CallFrame; class GPU_CallFrame;
using OpFunction = using OpFunction =
std::function<void(codegen::CodeWriter&, std::function<void(GPU_ExternalFunction* external_function,
codegen::CodeWriter&,
const ngraph::Node*, const ngraph::Node*,
const std::vector<GPU_TensorViewWrapper>& inputs, const std::vector<GPU_TensorViewWrapper>& inputs,
const std::vector<GPU_TensorViewWrapper>& outputs)>; const std::vector<GPU_TensorViewWrapper>& outputs)>;
......
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