提交 b12c77da 编写于 作者: Y Yu Yang

Fix unittests

test=develop
上级 19e669a9
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include "paddle/fluid/memory/allocation/allocator.h" #include "paddle/fluid/memory/allocation/allocator.h"
#include <gflags/gflags.h> #include <gflags/gflags.h>
#include <map> #include <map>
#include <string>
#include <unordered_map> #include <unordered_map>
#include <vector> #include <vector>
#include "paddle/fluid/memory/allocation/aligned_allocator.h" #include "paddle/fluid/memory/allocation/aligned_allocator.h"
...@@ -209,6 +210,7 @@ class AllocatorFacadePrivate { ...@@ -209,6 +210,7 @@ class AllocatorFacadePrivate {
for (int dev_id = 0; dev_id < platform::GetCUDADeviceCount(); ++dev_id) { for (int dev_id = 0; dev_id < platform::GetCUDADeviceCount(); ++dev_id) {
places.emplace_back(platform::CUDAPlace(dev_id)); places.emplace_back(platform::CUDAPlace(dev_id));
} }
places.emplace_back(platform::CUDAPinnedPlace());
#endif #endif
for (auto& p : places) { for (auto& p : places) {
allocators_[p] = std::make_shared<LegacyAllocator>(p); allocators_[p] = std::make_shared<LegacyAllocator>(p);
...@@ -255,13 +257,17 @@ AllocatorFacade& AllocatorFacade::Instance() { ...@@ -255,13 +257,17 @@ AllocatorFacade& AllocatorFacade::Instance() {
std::shared_ptr<Allocation> AllocatorFacade::AllocShared( std::shared_ptr<Allocation> AllocatorFacade::AllocShared(
const platform::Place& place, size_t size, Allocator::Attr attr) { const platform::Place& place, size_t size, Allocator::Attr attr) {
return std::shared_ptr<Allocation>( return std::shared_ptr<Allocation>(Alloc(place, size, attr).release(),
m_->allocators_.at(place)->Allocate(size, attr).release(), AllocationDeleter());
AllocationDeleter());
} }
AllocationPtr AllocatorFacade::Alloc(const platform::Place& place, size_t size, AllocationPtr AllocatorFacade::Alloc(const platform::Place& place, size_t size,
Allocator::Attr attr) { Allocator::Attr attr) {
auto it = m_->allocators_.find(place);
if (it == m_->allocators_.end()) {
throw BadAlloc(
string::Sprintf("No such allocator for the place, %s", place));
}
return m_->allocators_.at(place)->Allocate(size, attr); return m_->allocators_.at(place)->Allocate(size, attr);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册