Skip to content

Commit aac7e36

Browse files
committed
Fix leak on tensors
1 parent 27e5799 commit aac7e36

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

src/backends/tensorflow.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,7 @@ int RAI_ModelRunTF(RAI_ModelRunCtx* mctx, RAI_Error *error) {
319319
for(size_t i = 0 ; i < array_len(mctx->outputs) ; ++i) {
320320
RAI_Tensor* output_tensor = RAI_TensorCreateFromTFTensor(outputTensorsValues[i]);
321321
mctx->outputs[i].tensor = RAI_TensorGetShallowCopy(output_tensor);
322+
RAI_TensorFree(output_tensor);
322323
}
323324

324325
TF_DeleteStatus(status);

src/backends/torch.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ int RAI_ModelRunTorch(RAI_ModelRunCtx* mctx, RAI_Error *error) {
8181
}
8282
RAI_Tensor* output_tensor = RAI_TensorCreateFromDLTensor(outputs[i]);
8383
mctx->outputs[i].tensor = RAI_TensorGetShallowCopy(output_tensor);
84+
RAI_TensorFree(output_tensor);
8485
}
8586

8687
return 0;

0 commit comments

Comments
 (0)