Commit c0edf94d authored by Pruthvi's avatar Pruthvi Committed by Scott Cyphers

remove unique_ptr from allocator static allocation (#3269)

* remove unique_ptr from allocator static allocation

* - for default allocator return address of the static object on stack instead of returning ptr to dynamically allocated object

* Revert "- for default allocator return address of the static object on stack instead of returning ptr to dynamically allocated object"

This reverts commit 126b269cb298e6eb8b99b1b9a90d5aa7cf8fb948.

* use raw pointer in set_host_memory_allocator

* fix build error
parent 818c0bcb
......@@ -51,6 +51,6 @@ public:
ngraph::runtime::Allocator* ngraph::runtime::get_default_allocator()
{
static std::unique_ptr<DefaultAllocator> allocator(new DefaultAllocator());
return allocator.get();
static DefaultAllocator* allocator = new DefaultAllocator();
return allocator;
}
......@@ -146,7 +146,7 @@ public:
virtual Allocator* get_host_memory_allocator() { return nullptr; }
/// \brief Set the host memory allocator to be used by the backend
/// \param allocator is pointer to host memory allocator object
virtual void set_host_memory_allocator(std::unique_ptr<Allocator> allocator) {}
virtual void set_host_memory_allocator(Allocator* allocator) {}
/// \brief Returns memory allocator used by backend for device allocations
virtual Allocator* get_device_memory_allocator()
{
......
......@@ -187,11 +187,10 @@ runtime::Allocator* runtime::cpu::CPU_Backend::get_host_memory_allocator()
{
return runtime::get_default_allocator();
}
return m_allocator.get();
return m_allocator;
}
void runtime::cpu::CPU_Backend::set_host_memory_allocator(
std::unique_ptr<runtime::Allocator> allocator)
void runtime::cpu::CPU_Backend::set_host_memory_allocator(Allocator* allocator)
{
if (m_allocator)
{
......@@ -200,7 +199,7 @@ void runtime::cpu::CPU_Backend::set_host_memory_allocator(
throw ngraph_error(
"Allocator already exists. Changing allocators mid-execution is not permitted.");
}
m_allocator = std::move(allocator);
m_allocator = allocator;
}
vector<runtime::PerformanceCounter> runtime::cpu::CPU_Executable::get_performance_data() const
......
......@@ -65,7 +65,7 @@ namespace ngraph
void remove_compiled_function(std::shared_ptr<Executable> exec) override;
Allocator* get_host_memory_allocator() override;
void set_host_memory_allocator(std::unique_ptr<Allocator> allocator) override;
void set_host_memory_allocator(Allocator* allocator) override;
bool is_supported(const Node& node) const override;
bool is_supported_property(const Property prop) const override;
......@@ -76,7 +76,7 @@ namespace ngraph
std::mutex m_exec_map_mutex;
std::unordered_map<std::shared_ptr<Function>, std::shared_ptr<Executable>>
m_exec_map;
std::unique_ptr<Allocator> m_allocator;
Allocator* m_allocator;
};
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