--- /dev/null
+#ifndef _NNC_BACKEND_INTERPRETER_PLUGIN_
+#define _NNC_BACKEND_INTERPRETER_PLUGIN_
+
+#include <unordered_map>
+
+#include "PluginInstance.h"
+#include "PluginException.h"
+#include "ConfigException.h"
+#include "PluginType.h"
+
+#include "nnc/core/linalg/TensorVariant.h"
+#include "nncc/core/ADT/tensor/Shape.h"
+
+namespace nncc
+{
+namespace contrib
+{
+namespace backend
+{
+namespace interpreter
+{
+namespace plugin
+{
+
+using namespace nncc::contrib;
+using namespace config;
+using nncc::contrib::plugin::AbstractPluginInstance;
+
+class InterpreterPlugin : public AbstractPluginInstance {
+ public:
+ static AbstractPluginInstance &getInstance();
+ void fillSession() override;
+ void checkConfig() override;
+ void *execute(void *data) override;
+
+ void setParam(const std::string &name) override;
+ void setParam(const std::string &name, const std::string &value) override;
+
+ virtual ~InterpreterPlugin();
+
+private:
+ std::unordered_map<std::string, std::string> params;
+
+ nncc::contrib::core::ADT::TensorVariant loadInput(const nncc::core::ADT::tensor::Shape &);
+ nncc::contrib::core::ADT::TensorVariant *_out;
+};
+
+} // namespace plugin
+} // namespace interpreter
+} // namespace backend
+} // namespace contrib
+} // namespace nncc
+
+#endif //_NNC_BACKEND_INTERPRETER_PLUGIN_
--- /dev/null
+#include <map>
+#include <vector>
+#include <fstream>
+
+#include "PluginParam.h"
+#include "PluginInstance.h"
+
+#include "nncc/core/ADT/tensor/Shape.h"
+
+#include "interpreter/core/Interpreter.h"
+
+#include "nnc/core/IR/model/actions/ShapeInference.h"
+#include "nnc/core/IR/model/graph/graph.h"
+
+#include "nnc/core/linalg/ShapeRange.h"
+#include "nnc/core/linalg/Tensor.h"
+
+#include "interpreter_plugin.h"
+
+namespace nncc
+{
+namespace contrib
+{
+namespace backend
+{
+namespace interpreter
+{
+namespace plugin
+{
+
+using nncc::core::ADT::tensor::Shape;
+using namespace nncc::contrib::core::IR::model;
+using nncc::contrib::backend::interpreter::core::NNInterpreter;
+using nncc::contrib::plugin::AbstractPluginInstance;
+using nncc::contrib::config::PluginParam;
+
+static const std::string pluginName = "NNInterpreterPlugin";
+static const std::string pluginVersion = "0.1";
+static const std::string pluginDesc = "NN Interpreter Plugin";
+static const auto pluginType = nncc::contrib::plugin::typeBackEnd;
+
+AbstractPluginInstance &InterpreterPlugin::getInstance() {
+ static InterpreterPlugin instance;
+ return instance;
+}
+
+void InterpreterPlugin::fillSession() {
+ static std::map<std::string, std::string> info = {{"module description", pluginDesc}};
+ static std::vector<PluginParam> moduleParams = {
+ {"filename", "Input file path", false},
+ {"input", "Input node name", false},
+ {"output", "Output node name", false}
+ };
+ AbstractPluginInstance::fillSessionBase(pluginType, pluginVersion, pluginName);
+
+ for (auto &i : info)
+ getSession()->addInfo(i.first, i.second);
+
+ for (auto &p : moduleParams)
+ getSession()->registerParam(p);
+}
+
+void InterpreterPlugin::checkConfig() {
+ //Nothing to configure
+}
+
+void *InterpreterPlugin::execute(void *data) {
+ auto g = static_cast<Graph *>(data);
+ ShapeInference shapeInference;
+
+ NNInterpreter interpreter;
+
+ g->accept(&shapeInference);
+
+ auto input = loadInput(g->getInput(params["input"])->getOperation()->getOutputShape(0));
+ interpreter.setInput(params["input"], input);
+ g->accept(&interpreter);
+
+ _out = new TensorVariant(interpreter.getResult(g->getOutput(params["output"]))[0]);
+ return _out;
+}
+
+void InterpreterPlugin::setParam(const std::string &name) {
+ //No known options
+ (void) name;
+}
+
+void InterpreterPlugin::setParam(const std::string &name, const std::string &value) {
+ params[name] = value;
+}
+
+TensorVariant InterpreterPlugin::loadInput(const Shape &shape)
+{
+ auto f = fopen(params["filename"].c_str(), "rb");
+ fseek(f, 0L, SEEK_END);
+ auto len = ftell(f);
+ rewind(f);
+ auto data = new char[len];
+ auto rlen = fread(data, len, 1, f);
+ assert(rlen == len);
+
+ return TensorVariant(shape, std::shared_ptr<char>(data, [](const char* d) { delete[] d; }), TensorVariant::DTYPE::FLOAT, sizeof(float));
+}
+
+InterpreterPlugin::~InterpreterPlugin()
+{
+ delete _out;
+}
+
+} // namespace plugin
+} // namespace interpreter
+} // namespace backend
+} // namespace contrib
+} // namespace nncc
+
+extern "C" nncc::contrib::backend::interpreter::plugin::AbstractPluginInstance *get_instance() {
+ return &nncc::contrib::backend::interpreter::plugin::InterpreterPlugin::getInstance();
+}
+