#include "KernelGenerator.h"
#include "ShapeFixer.h"
#include "MemoryManager.h"
+#include "backend/CustomKernelRegistry.h"
namespace neurun
{
std::unique_ptr<BackendContext> newContext(const model::Operands &operands) const override
{
auto tensor_builder = std::make_shared<TensorBuilder>(createMemoryManager());
+ auto kernel_registry = std::make_shared<custom::KernelRegistry>();
return std::unique_ptr<BackendContext>{new BackendContext{
this, tensor_builder, std::make_shared<ConstantInitializer>(operands, tensor_builder),
std::make_shared<KernelGenerator>(operands, tensor_builder),
- std::make_shared<ShapeFixer>(operands, tensor_builder)}};
+ std::make_shared<ShapeFixer>(operands, tensor_builder), kernel_registry}};
}
private:
#include "KernelGenerator.h"
#include "ShapeFixer.h"
#include "MemoryManager.h"
+#include "backend/CustomKernelRegistry.h"
namespace neurun
{
std::unique_ptr<BackendContext> newContext(const model::Operands &operands) const override
{
auto tensor_builder = std::make_shared<TensorBuilder>(createMemoryManager());
+ auto kernel_registry = std::make_shared<custom::KernelRegistry>();
return std::unique_ptr<BackendContext>{new BackendContext{
this, tensor_builder, std::make_shared<ConstantInitializer>(operands, tensor_builder),
std::make_shared<KernelGenerator>(operands, tensor_builder),
- std::make_shared<ShapeFixer>(operands, tensor_builder)}};
+ std::make_shared<ShapeFixer>(operands, tensor_builder), kernel_registry}};
}
private:
#include "ConstantInitializer.h"
#include "KernelGenerator.h"
#include "ShapeFixer.h"
+#include "backend/CustomKernelRegistry.h"
namespace neurun
{
std::unique_ptr<BackendContext> newContext(const model::Operands &operands) const override
{
auto tensor_builder = std::make_shared<TensorBuilder>();
+ auto kernel_registry = std::make_shared<custom::KernelRegistry>();
return std::unique_ptr<BackendContext>{new BackendContext{
this, tensor_builder, std::make_shared<ConstantInitializer>(operands, tensor_builder),
- std::make_shared<KernelGenerator>(operands, tensor_builder),
- std::make_shared<ShapeFixer>(operands, tensor_builder)}};
+ std::make_shared<KernelGenerator>(operands, tensor_builder, kernel_registry),
+ std::make_shared<ShapeFixer>(operands, tensor_builder), kernel_registry}};
}
private:
{
KernelGenerator::KernelGenerator(const neurun::model::Operands &operand_ctx,
- const std::shared_ptr<TensorBuilder> &tensor_builder)
- : _ctx(operand_ctx), _tensor_builder(tensor_builder)
+ const std::shared_ptr<TensorBuilder> &tensor_builder,
+ const std::shared_ptr<custom::KernelRegistry> &kernel_registry)
+ : _ctx(operand_ctx), _tensor_builder(tensor_builder), _kernel_registry(kernel_registry)
{
// DO NOTHING
}
#include "backend/IKernelGenerator.h"
#include "model/Operands.h"
#include "operand/Tensor.h"
+#include "backend/CustomKernelRegistry.h"
#include "TensorBuilder.h"
namespace neurun
{
public:
KernelGenerator(const neurun::model::Operands &ctx,
- const std::shared_ptr<TensorBuilder> &tensor_builder);
+ const std::shared_ptr<TensorBuilder> &tensor_builder,
+ const std::shared_ptr<custom::KernelRegistry> &kernel_registry);
using IKernelGenerator::visit;
private:
const neurun::model::Operands &_ctx;
std::shared_ptr<TensorBuilder> _tensor_builder;
+ std::shared_ptr<custom::KernelRegistry> _kernel_registry;
model::Layout _current_subg_layout;
};
class IShapeFixer;
struct ITensorBuilder;
+namespace custom
+{
+class KernelRegistry;
+}
+
class BackendContext
{
public:
std::shared_ptr<IConstantInitializer> constant_initializer;
std::shared_ptr<IKernelGenerator> kernel_gen;
std::shared_ptr<IShapeFixer> shape_fixer;
+ std::shared_ptr<custom::KernelRegistry> _custom_kernel_registry;
};
class Backend