Commit e8ebfa27 authored by pruthvi's avatar pruthvi

change getters signature return type to onnx runtime function signature

parent 39e82f08
...@@ -65,12 +65,12 @@ void runtime::Backend::remove_compiled_function(std::shared_ptr<Executable> exec ...@@ -65,12 +65,12 @@ void runtime::Backend::remove_compiled_function(std::shared_ptr<Executable> exec
{ {
} }
void* runtime::Backend::get_device_memory_alloc() ngraph::runtime::AllocateFunc runtime::Backend::get_device_memory_alloc()
{ {
return nullptr; return nullptr;
} }
void* runtime::Backend::get_device_memory_dealloc() ngraph::runtime::DestroyFunc runtime::Backend::get_device_memory_dealloc()
{ {
return nullptr; return nullptr;
} }
......
...@@ -117,7 +117,7 @@ public: ...@@ -117,7 +117,7 @@ public:
virtual void remove_compiled_function(std::shared_ptr<Executable> exec); virtual void remove_compiled_function(std::shared_ptr<Executable> exec);
virtual void* get_device_memory_alloc(); virtual ngraph::runtime::AllocateFunc get_device_memory_alloc();
virtual void* get_device_memory_dealloc(); virtual ngraph::runtime::DestroyFunc get_device_memory_dealloc();
virtual bool is_device_memory(); virtual bool is_device_memory();
}; };
...@@ -45,8 +45,6 @@ namespace ngraph ...@@ -45,8 +45,6 @@ namespace ngraph
namespace runtime namespace runtime
{ {
class Allocator; class Allocator;
//class SystemAllocator;
//class FrameworkAllocator;
namespace cpu namespace cpu
{ {
class CPUAllocator; class CPUAllocator;
...@@ -61,7 +59,7 @@ public: ...@@ -61,7 +59,7 @@ public:
CPUAllocator(); CPUAllocator();
~CPUAllocator(); ~CPUAllocator();
void* Malloc(void* handle, size_t size, size_t alignment) override void* Malloc(void* handle, size_t size, size_t alignment)
{ {
void* ptr = malloc(size); void* ptr = malloc(size);
// check for exception // check for exception
...@@ -72,7 +70,7 @@ public: ...@@ -72,7 +70,7 @@ public:
} }
return ptr; return ptr;
} }
void Free(void* handle, void* ptr) override void Free(void* handle, void* ptr)
{ {
if (ptr) if (ptr)
{ {
...@@ -80,75 +78,3 @@ public: ...@@ -80,75 +78,3 @@ public:
} }
} }
}; };
/*// Abstarct class for the allocator
class ngraph::runtime::Allocator
{
public:
virtual void* cpu_malloc(void*, size_t size, size_t alignment) = 0;
virtual void cpu_free(void* ptr, void*) = 0;
};
class ngraph::runtime::SystemAllocator : public ngraph::runtime::Allocator
{
public:
SystemAllocator(size_t alignment);
~SystemAllocator();
void* cpu_malloc(void*, size_t size, size_t alignment) override
{
void* ptr = malloc(size);
// check for exception
if (size != 0 && !ptr)
{
throw ngraph_error("malloc failed to allocate memory of size " + std::to_string(size));
throw std::bad_alloc();
}
return ptr;
}
void cpu_free(void* ptr, void*) override
{
if (ptr)
{
free(ptr);
}
}
private:
size_t m_alignment;
};
class ngraph::runtime::FrameworkAllocator : public ngraph::runtime::Allocator
{
public:
FrameworkAllocator(AllocateFunc allocator, DestroyFunc deallocator, size_t alignment);
~FrameworkAllocator();
void* cpu_malloc(void*, size_t size, size_t alignment) override
{
void* ptr = m_allocator(nullptr, alignment, size);
// check for exception
if (size != 0 && !ptr)
{
throw ngraph_error("malloc failed to allocate memory of size " + std::to_string(size));
throw std::bad_alloc();
}
return ptr;
}
void cpu_free(void* ptr, void*) override
{
if (ptr)
{
m_deallocator(nullptr, ptr);
}
}
private:
AllocateFunc m_allocator;
DestroyFunc m_deallocator;
size_t m_alignment;
};*/
...@@ -67,9 +67,6 @@ namespace ngraph ...@@ -67,9 +67,6 @@ namespace ngraph
bool is_supported(const Node& node) const override; bool is_supported(const Node& node) const override;
bool is_supported_property(const Property prop) const override; bool is_supported_property(const Property prop) const override;
//static inline void* MallocHook(size_t size);
//static inline void FreeHook(void *ptr);
private: private:
std::unordered_map<std::shared_ptr<Function>, std::shared_ptr<Executable>> std::unordered_map<std::shared_ptr<Function>, std::shared_ptr<Executable>>
m_exec_map; m_exec_map;
......
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