Skip to content

Commit 2f317bb

Browse files
jhavukainenpytorchmergebot
authored andcommitted
Missing autorelease in lstm_mps caused a ton of leaked memory (pytorch#145503)
The dictionary held onto the new MPSGraphTensorData objects and MPSNDArrays. Regression caused by pytorch#95137 Fixes pytorch#145374 Pull Request resolved: pytorch#145503 Approved by: https://github.com/Skylion007, https://github.com/malfet
1 parent 41b38f7 commit 2f317bb

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

aten/src/ATen/native/mps/operations/RnnOps.mm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,13 +322,13 @@
322322
Placeholder outputPlaceholder3 = Placeholder(cachedGraph->outputTensors_[3], zState);
323323
Placeholder outputPlaceholder4 = Placeholder(cachedGraph->outputTensors_[4], cellStateFwd);
324324

325-
NSMutableDictionary<MPSGraphTensor*, MPSGraphTensorData*>* results = [@{
325+
NSMutableDictionary<MPSGraphTensor*, MPSGraphTensorData*>* results = [[@{
326326
outputPlaceholder0.getMPSGraphTensor() : outputPlaceholder0.getMPSGraphTensorData(),
327327
outputPlaceholder1.getMPSGraphTensor() : outputPlaceholder1.getMPSGraphTensorData(),
328328
outputPlaceholder2.getMPSGraphTensor() : outputPlaceholder2.getMPSGraphTensorData(),
329329
outputPlaceholder3.getMPSGraphTensor() : outputPlaceholder3.getMPSGraphTensorData(),
330330
outputPlaceholder4.getMPSGraphTensor() : outputPlaceholder4.getMPSGraphTensorData(),
331-
} mutableCopy];
331+
} mutableCopy] autorelease];
332332

333333
if (num_layers > 1) {
334334
Placeholder outputPlaceholder5 = Placeholder(cachedGraph->outputTensors_[5], layerOutputs);

0 commit comments

Comments
 (0)