Commit 21da04c5 authored by pruthvi's avatar pruthvi

style-fix

parent d676fb77
...@@ -22,20 +22,10 @@ ...@@ -22,20 +22,10 @@
using namespace ngraph; using namespace ngraph;
runtime::cpu::CPUAlignedBuffer::CPUAlignedBuffer() runtime::cpu::CPUAlignedBuffer::CPUAlignedBuffer(size_t byte_size, size_t alignment)
: m_cpu_allocator(nullptr, nullptr, 0)
, m_allocated_buffer(nullptr)
, m_aligned_buffer(nullptr)
, m_byte_size(0)
{
}
runtime::cpu::CPUAlignedBuffer::CPUAlignedBuffer(size_t byte_size,
size_t alignment,
ngraph::runtime::cpu::CPUAllocator& cpu_allocator)
{ {
m_byte_size = byte_size; m_byte_size = byte_size;
AllocateFunc allocator = ngraph::runtime::cpu::CPUAllocator::m_framework_allocator; AllocateFunc allocator = ngraph::runtime::cpu::CPUAllocator::framework_allocator;
if (m_byte_size > 0) if (m_byte_size > 0)
{ {
size_t allocation_size = m_byte_size + alignment; size_t allocation_size = m_byte_size + alignment;
...@@ -58,7 +48,7 @@ runtime::cpu::CPUAlignedBuffer::CPUAlignedBuffer(size_t byte_size, ...@@ -58,7 +48,7 @@ runtime::cpu::CPUAlignedBuffer::CPUAlignedBuffer(size_t byte_size,
runtime::cpu::CPUAlignedBuffer::~CPUAlignedBuffer() runtime::cpu::CPUAlignedBuffer::~CPUAlignedBuffer()
{ {
DestroyFunc deallocator = ngraph::runtime::cpu::CPUAllocator::m_framework_deallocator; DestroyFunc deallocator = ngraph::runtime::cpu::CPUAllocator::framework_deallocator;
if (m_allocated_buffer != nullptr) if (m_allocated_buffer != nullptr)
{ {
ngraph::runtime::cpu::cpu_free(m_allocated_buffer, deallocator); ngraph::runtime::cpu::cpu_free(m_allocated_buffer, deallocator);
......
...@@ -36,10 +36,7 @@ namespace ngraph ...@@ -36,10 +36,7 @@ namespace ngraph
class ngraph::runtime::cpu::CPUAlignedBuffer class ngraph::runtime::cpu::CPUAlignedBuffer
{ {
public: public:
CPUAlignedBuffer(size_t byte_size, CPUAlignedBuffer(size_t byte_size, size_t alignment);
size_t alignment,
ngraph::runtime::cpu::CPUAllocator& cpu_allocator);
CPUAlignedBuffer();
~CPUAlignedBuffer(); ~CPUAlignedBuffer();
size_t size() const { return m_byte_size; } size_t size() const { return m_byte_size; }
......
...@@ -126,10 +126,13 @@ void runtime::cpu::CPU_CallFrame::setup_runtime_context() ...@@ -126,10 +126,13 @@ void runtime::cpu::CPU_CallFrame::setup_runtime_context()
// Create temporary buffer pools // Create temporary buffer pools
size_t alignment = runtime::cpu::CPU_ExternalFunction::s_memory_pool_alignment; size_t alignment = runtime::cpu::CPU_ExternalFunction::s_memory_pool_alignment;
CPUAllocator cpu_allocator(nullptr, nullptr, alignment); ngraph::runtime::cpu::CPUAllocator::framework_allocator = nullptr;
ngraph::runtime::cpu::CPUAllocator::framework_deallocator = nullptr;
ngraph::runtime::cpu::CPUAllocator::alignment = alignment;
for (auto buffer_size : m_external_function->get_memory_buffer_sizes()) for (auto buffer_size : m_external_function->get_memory_buffer_sizes())
{ {
auto buffer = new CPUAlignedBuffer(buffer_size, alignment, cpu_allocator); auto buffer = new CPUAlignedBuffer(buffer_size, alignment);
ctx->memory_buffers.push_back(buffer); ctx->memory_buffers.push_back(buffer);
} }
const auto& mkldnn_emitter = m_external_function->get_mkldnn_emitter(); const auto& mkldnn_emitter = m_external_function->get_mkldnn_emitter();
......
...@@ -17,14 +17,17 @@ ...@@ -17,14 +17,17 @@
#include "ngraph/runtime/cpu/cpu_mkl_allocator.hpp" #include "ngraph/runtime/cpu/cpu_mkl_allocator.hpp"
#include <string> #include <string>
#include "ngraph/except.hpp" #include "ngraph/except.hpp"
#include "ngraph/runtime/cpu/cpu_external_function.hpp"
ngraph::runtime::cpu::CPUAllocator::CPUAllocator() ngraph::runtime::cpu::CPUAllocator::CPUAllocator()
{ {
} }
AllocateFunc ngraph::runtime::cpu::CPUAllocator::m_framework_allocator = nullptr; AllocateFunc ngraph::runtime::cpu::CPUAllocator::framework_allocator = nullptr;
DestroyFunc ngraph::runtime::cpu::CPUAllocator::m_framework_deallocator = nullptr; DestroyFunc ngraph::runtime::cpu::CPUAllocator::framework_deallocator = nullptr;
size_t ngraph::runtime::cpu::CPUAllocator::m_alignment = 4096; size_t ngraph::runtime::cpu::CPUAllocator::alignment =
ngraph::runtime::cpu::CPU_ExternalFunction::s_memory_pool_alignment;
;
ngraph::runtime::cpu::CPUAllocator::CPUAllocator(AllocateFunc allocator, ngraph::runtime::cpu::CPUAllocator::CPUAllocator(AllocateFunc allocator,
DestroyFunc deallocator, DestroyFunc deallocator,
......
...@@ -60,18 +60,18 @@ public: ...@@ -60,18 +60,18 @@ public:
CPUAllocator(); CPUAllocator();
~CPUAllocator(); ~CPUAllocator();
static AllocateFunc m_framework_allocator; static AllocateFunc framework_allocator;
static DestroyFunc m_framework_deallocator; static DestroyFunc framework_deallocator;
static size_t m_alignment; static size_t alignment;
private: private:
static inline void* MallocHook(size_t size) static inline void* MallocHook(size_t size)
{ {
ngraph::runtime::cpu::cpu_malloc(size, m_alignment, m_framework_allocator); ngraph::runtime::cpu::cpu_malloc(size, alignment, framework_allocator);
} }
static inline void FreeHook(void* ptr) static inline void FreeHook(void* ptr)
{ {
ngraph::runtime::cpu::cpu_free(ptr, m_framework_deallocator); ngraph::runtime::cpu::cpu_free(ptr, framework_deallocator);
} }
}; };
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