Commit ab34197e authored by pruthvi's avatar pruthvi

- add virtual destructor method to CPU allocator

- fix clang errors
parent 65eb0f09
......@@ -148,13 +148,13 @@ void runtime::cpu::CPU_CallFrame::setup_runtime_context()
ngraph::runtime::cpu::CPUAllocator* allocator = nullptr;
if (m_framework_allocator && m_framework_deallocator)
{
auto fw_allocator = new ngraph::runtime::FrameworkAllocator(
m_framework_allocator, m_framework_deallocator, alignment);
auto fw_allocator =
new ngraph::runtime::FrameworkAllocator(m_framework_allocator, m_framework_deallocator);
allocator = new ngraph::runtime::cpu::CPUAllocator(fw_allocator, alignment);
}
else
{
auto sys_allocator = new ngraph::runtime::SystemAllocator(alignment);
auto sys_allocator = new ngraph::runtime::SystemAllocator();
allocator = new ngraph::runtime::cpu::CPUAllocator(sys_allocator, alignment);
}
......
......@@ -31,7 +31,7 @@ ngraph::runtime::cpu::CPUAllocator::~CPUAllocator()
void* ngraph::runtime::cpu::CPUAllocator::malloc(size_t size)
{
m_allocator->cpu_malloc(nullptr, size, m_alignment);
return m_allocator->cpu_malloc(nullptr, size, m_alignment);
}
void ngraph::runtime::cpu::CPUAllocator::free(void* ptr)
......@@ -39,16 +39,21 @@ void ngraph::runtime::cpu::CPUAllocator::free(void* ptr)
m_allocator->cpu_free(nullptr, ptr);
}
ngraph::runtime::SystemAllocator::SystemAllocator(size_t alignment)
: m_alignment(alignment)
ngraph::runtime::SystemAllocator::SystemAllocator()
{
}
ngraph::runtime::FrameworkAllocator::FrameworkAllocator(AllocateFunc allocator,
DestroyFunc deallocator,
size_t alignment)
ngraph::runtime::SystemAllocator::~SystemAllocator()
{
}
ngraph::runtime::FrameworkAllocator::~FrameworkAllocator()
{
}
ngraph::runtime::FrameworkAllocator::FrameworkAllocator(AllocateFunc& allocator,
DestroyFunc& deallocator)
: m_allocator(allocator)
, m_deallocator(deallocator)
, m_alignment(alignment)
{
}
......@@ -22,7 +22,6 @@
#include "ngraph/runtime/aligned_buffer.hpp"
#include "ngraph/util.hpp"
using namespace ngraph;
using AllocateFunc = void* (*)(void*, size_t, size_t);
using DestroyFunc = void (*)(void*, void*);
......@@ -75,6 +74,7 @@ private:
class ngraph::runtime::Allocator
{
public:
virtual ~Allocator() = default;
virtual void* cpu_malloc(void*, size_t size, size_t alignment) = 0;
virtual void cpu_free(void* ptr, void*) = 0;
};
......@@ -84,7 +84,7 @@ public:
class ngraph::runtime::SystemAllocator : public ngraph::runtime::Allocator
{
public:
SystemAllocator(size_t alignment);
SystemAllocator();
~SystemAllocator();
void* cpu_malloc(void*, size_t size, size_t alignment) override
......@@ -107,9 +107,6 @@ public:
free(ptr);
}
}
private:
size_t m_alignment;
};
// FrameworkAllocator overides and implements "cpu_malloc" & "cpu_free" of Alloctaor interface class,
......@@ -117,7 +114,7 @@ private:
class ngraph::runtime::FrameworkAllocator : public ngraph::runtime::Allocator
{
public:
FrameworkAllocator(AllocateFunc allocator, DestroyFunc deallocator, size_t alignment);
FrameworkAllocator(AllocateFunc& allocator, DestroyFunc& deallocator);
~FrameworkAllocator();
void* cpu_malloc(void*, size_t size, size_t alignment) override
......@@ -144,5 +141,4 @@ public:
private:
AllocateFunc m_allocator;
DestroyFunc m_deallocator;
size_t m_alignment;
};
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