Skip to content

Commit d6f0e6c

Browse files
committed
MemoryHandle* --> MemoryHandlePtr
1 parent 6cde889 commit d6f0e6c

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

paddle/gserver/layers/ConvBaseProjection.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ limitations under the License. */
1717

1818
namespace paddle {
1919

20-
ThreadLocalD<std::vector<MemoryHandle *>> ConvBaseProjection::convMem_;
20+
ThreadLocalD<std::vector<MemoryHandlePtr>> ConvBaseProjection::convMem_;
2121

2222
ConvBaseProjection::ConvBaseProjection(const ProjectionConfig &config,
2323
ParameterPtr parameter,
@@ -175,18 +175,18 @@ void ConvBaseProjection::reshape(int batchSize) {
175175
}
176176

177177
void *ConvBaseProjection::getSpaceBytes(size_t size) {
178-
std::vector<MemoryHandle *> &convMem = *convMem_;
178+
std::vector<MemoryHandlePtr> &convMem = *convMem_;
179179
if (convMem.empty()) {
180180
int numDevices = hl_get_device_count();
181181
convMem.resize(numDevices);
182182
}
183183

184184
int devId = hl_get_device();
185-
MemoryHandle **localMem = &(convMem[devId]);
186-
if (NULL == *localMem || size > (*localMem)->getAllocSize()) {
187-
*localMem = new GpuMemoryHandle(size);
185+
MemoryHandlePtr localMem = convMem[devId];
186+
if (NULL == localMem || size > localMem->getAllocSize()) {
187+
localMem = std::make_shared<GpuMemoryHandle>(size);
188188
}
189-
return (*localMem)->getBuf();
189+
return localMem->getBuf();
190190
}
191191

192192
ConvBaseProjection::~ConvBaseProjection() {

paddle/gserver/layers/ConvBaseProjection.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ class ConvBaseProjection : public Projection {
105105
bool bias_;
106106

107107
std::unique_ptr<Weight> weight_;
108-
static ThreadLocalD<std::vector<MemoryHandle*>> convMem_;
108+
static ThreadLocalD<std::vector<MemoryHandlePtr>> convMem_;
109109
};
110110

111111
} // namespace paddle

0 commit comments

Comments
 (0)