Skip to content

Commit 414afae

Browse files
committed
fixed invalid delete of outputs after execution error in TF
1 parent b04ec83 commit 414afae

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/backends/tensorflow.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -530,8 +530,10 @@ int RAI_ModelRunTF(RAI_Model *model, RAI_ExecutionCtx **ectxs, RAI_Error *error)
530530
outputTensorsValues, noutputs, NULL /* target_opers */, 0 /* ntargets */,
531531
NULL /* run_Metadata */, status);
532532

533+
bool delete_output = true;
533534
if (TF_GetCode(status) != TF_OK) {
534535
RAI_SetError(error, RAI_EMODELRUN, TF_Message(status));
536+
delete_output = false;
535537
goto cleanup;
536538
}
537539

@@ -575,8 +577,10 @@ int RAI_ModelRunTF(RAI_Model *model, RAI_ExecutionCtx **ectxs, RAI_Error *error)
575577
}
576578
TF_DeleteTensor(inputTensorsValues[i]);
577579
}
578-
for (size_t i = 0; i < noutputs; i++) {
579-
TF_DeleteTensor(outputTensorsValues[i]);
580+
if (delete_output) {
581+
for (size_t i = 0; i < noutputs; i++) {
582+
TF_DeleteTensor(outputTensorsValues[i]);
583+
}
580584
}
581585
return res;
582586
}

0 commit comments

Comments
 (0)