File tree Expand file tree Collapse file tree 2 files changed +7
-7
lines changed Expand file tree Collapse file tree 2 files changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ limitations under the License. */
17
17
18
18
namespace paddle {
19
19
20
- ThreadLocalD<std::vector<MemoryHandle * >> ConvBaseProjection::convMem_;
20
+ ThreadLocalD<std::vector<MemoryHandlePtr >> ConvBaseProjection::convMem_;
21
21
22
22
ConvBaseProjection::ConvBaseProjection (const ProjectionConfig &config,
23
23
ParameterPtr parameter,
@@ -175,18 +175,18 @@ void ConvBaseProjection::reshape(int batchSize) {
175
175
}
176
176
177
177
void *ConvBaseProjection::getSpaceBytes (size_t size) {
178
- std::vector<MemoryHandle * > &convMem = *convMem_;
178
+ std::vector<MemoryHandlePtr > &convMem = *convMem_;
179
179
if (convMem.empty ()) {
180
180
int numDevices = hl_get_device_count ();
181
181
convMem.resize (numDevices);
182
182
}
183
183
184
184
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);
188
188
}
189
- return (* localMem) ->getBuf ();
189
+ return localMem->getBuf ();
190
190
}
191
191
192
192
ConvBaseProjection::~ConvBaseProjection () {
Original file line number Diff line number Diff line change @@ -105,7 +105,7 @@ class ConvBaseProjection : public Projection {
105
105
bool bias_;
106
106
107
107
std::unique_ptr<Weight> weight_;
108
- static ThreadLocalD<std::vector<MemoryHandle* >> convMem_;
108
+ static ThreadLocalD<std::vector<MemoryHandlePtr >> convMem_;
109
109
};
110
110
111
111
} // namespace paddle
You can’t perform that action at this time.
0 commit comments