teflon: Release the arrays of tensors in operations

We were leaking the arrays themselves. Also reorder the dereferencing of
the tensors to get the lifecycle right.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34627>
This commit is contained in:
Tomeu Vizoso 2025-04-15 09:40:52 +02:00 committed by Marge Bot
parent 63251d43ae
commit a99e5be446

View file

@ -369,9 +369,6 @@ partition_init(TfLiteContext *tf_context, const char *buffer, size_t length)
operations,
params->nodes_to_replace->size);
for (int i = 0; i < tf_context->tensors_size; i++)
pipe_resource_reference(&tensors[i].resource, NULL);
struct teflon_subgraph *tsubgraph = calloc(1, sizeof(*tsubgraph));
tsubgraph->base = subgraph;
@ -402,6 +399,14 @@ partition_init(TfLiteContext *tf_context, const char *buffer, size_t length)
free(tensors[i].zero_points);
}
for (int i = 0; i < params->nodes_to_replace->size; i++) {
free(operations[i].input_tensors);
free(operations[i].output_tensors);
}
for (int i = 0; i < tf_context->tensors_size; i++)
pipe_resource_reference(&tensors[i].resource, NULL);
return tsubgraph;
}