Skip to content

Commit

Permalink
Merge pull request #5418 from pkuyym/fix-5417
Browse files Browse the repository at this point in the history
MemoryHandle* --> MemoryHandlePtr
  • Loading branch information
pkuyym authored Nov 7, 2017
2 parents 6cde889 + d6f0e6c commit 0a4a66f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions paddle/gserver/layers/ConvBaseProjection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ limitations under the License. */

namespace paddle {

ThreadLocalD<std::vector<MemoryHandle *>> ConvBaseProjection::convMem_;
ThreadLocalD<std::vector<MemoryHandlePtr>> ConvBaseProjection::convMem_;

ConvBaseProjection::ConvBaseProjection(const ProjectionConfig &config,
ParameterPtr parameter,
Expand Down Expand Up @@ -175,18 +175,18 @@ void ConvBaseProjection::reshape(int batchSize) {
}

void *ConvBaseProjection::getSpaceBytes(size_t size) {
std::vector<MemoryHandle *> &convMem = *convMem_;
std::vector<MemoryHandlePtr> &convMem = *convMem_;
if (convMem.empty()) {
int numDevices = hl_get_device_count();
convMem.resize(numDevices);
}

int devId = hl_get_device();
MemoryHandle **localMem = &(convMem[devId]);
if (NULL == *localMem || size > (*localMem)->getAllocSize()) {
*localMem = new GpuMemoryHandle(size);
MemoryHandlePtr localMem = convMem[devId];
if (NULL == localMem || size > localMem->getAllocSize()) {
localMem = std::make_shared<GpuMemoryHandle>(size);
}
return (*localMem)->getBuf();
return localMem->getBuf();
}

ConvBaseProjection::~ConvBaseProjection() {
Expand Down
2 changes: 1 addition & 1 deletion paddle/gserver/layers/ConvBaseProjection.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class ConvBaseProjection : public Projection {
bool bias_;

std::unique_ptr<Weight> weight_;
static ThreadLocalD<std::vector<MemoryHandle*>> convMem_;
static ThreadLocalD<std::vector<MemoryHandlePtr>> convMem_;
};

} // namespace paddle

0 comments on commit 0a4a66f

Please sign in to comment.