Commit 3beb5fe3 authored by pruthvi's avatar pruthvi

- added getter's and setter's method for framework allocators object

parent 3f2ba6f9
......@@ -18,7 +18,7 @@
void* ngraph::runtime::Allocator::Malloc(void* handle, size_t size, size_t alignment)
{
void* ptr = malloc(size);
void* ptr = ngraph::aligned_alloc(alignment, size);
// check for exception
if (size != 0 && !ptr)
......@@ -32,6 +32,6 @@ void ngraph::runtime::Allocator::Free(void* handle, void* ptr)
{
if (ptr)
{
free(ptr);
ngraph::aligned_free(ptr);
}
}
......@@ -65,6 +65,16 @@ void runtime::Backend::remove_compiled_function(std::shared_ptr<Executable> exec
{
}
std::shared_ptr<ngraph::runtime::Allocator> runtime::Backend::get_framework_memory_allocator()
{
return nullptr;
}
void runtime::Backend::set_framework_memory_allocator(
const std::shared_ptr<ngraph::runtime::Allocator>& allocator)
{
}
ngraph::runtime::AllocateFunc runtime::Backend::get_device_memory_alloc()
{
return nullptr;
......
......@@ -20,6 +20,7 @@
#include "ngraph/function.hpp"
#include "ngraph/pass/pass_config.hpp"
#include "ngraph/runtime/allocator.hpp"
#include "ngraph/runtime/executable.hpp"
#include "ngraph/runtime/performance_counter.hpp"
#include "ngraph/shape.hpp"
......@@ -117,6 +118,9 @@ public:
virtual void remove_compiled_function(std::shared_ptr<Executable> exec);
virtual std::shared_ptr<ngraph::runtime::Allocator> get_framework_memory_allocator();
virtual void set_framework_memory_allocator(
const std::shared_ptr<ngraph::runtime::Allocator>& allocator);
virtual ngraph::runtime::AllocateFunc get_device_memory_alloc();
virtual ngraph::runtime::DestroyFunc get_device_memory_dealloc();
virtual bool is_device_memory();
......
......@@ -50,6 +50,14 @@ namespace
} s_cpu_static_init;
}
runtime::cpu::CPU_Backend::CPU_Backend()
{
m_allocator = make_shared<ngraph::runtime::Allocator>();
}
runtime::cpu::CPU_Backend::~CPU_Backend()
{
}
shared_ptr<runtime::cpu::CPU_CallFrame> runtime::cpu::CPU_Backend::make_call_frame(
const shared_ptr<runtime::cpu::CPU_ExternalFunction>& external_function,
ngraph::pass::PassConfig& pass_config,
......@@ -65,6 +73,17 @@ shared_ptr<runtime::Tensor>
return make_shared<runtime::cpu::CPUTensorView>(element_type, shape, this);
}
shared_ptr<ngraph::runtime::Allocator> runtime::cpu::CPU_Backend::get_framework_memory_allocator()
{
return m_allocator;
}
void runtime::cpu::CPU_Backend::set_framework_memory_allocator(
const std::shared_ptr<ngraph::runtime::Allocator>& allocator)
{
m_allocator = allocator;
}
shared_ptr<runtime::Tensor> runtime::cpu::CPU_Backend::create_tensor(
const element::Type& element_type, const Shape& shape, void* memory_pointer)
{
......
......@@ -21,6 +21,7 @@
#include "cpu_backend_visibility.h"
#include "ngraph/pass/pass_config.hpp"
#include "ngraph/runtime/allocator.hpp"
#include "ngraph/runtime/backend.hpp"
#include "ngraph/runtime/cpu/cpu_allocator.hpp"
......@@ -36,6 +37,8 @@ namespace ngraph
class CPU_BACKEND_API CPU_Backend : public runtime::Backend
{
public:
CPU_Backend();
~CPU_Backend();
std::shared_ptr<CPU_CallFrame>
make_call_frame(const std::shared_ptr<CPU_ExternalFunction>& external_function,
ngraph::pass::PassConfig& pass_config,
......@@ -64,12 +67,17 @@ namespace ngraph
void remove_compiled_function(std::shared_ptr<Executable> exec) override;
std::shared_ptr<ngraph::runtime::Allocator>
get_framework_memory_allocator() override;
void set_framework_memory_allocator(
const std::shared_ptr<ngraph::runtime::Allocator>& allocator) override;
bool is_supported(const Node& node) const override;
bool is_supported_property(const Property prop) const override;
private:
std::unordered_map<std::shared_ptr<Function>, std::shared_ptr<Executable>>
m_exec_map;
std::shared_ptr<ngraph::runtime::Allocator> m_allocator = nullptr;
};
class CPU_BACKEND_API CPU_Executable : public runtime::Executable
......
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