From 0501a3b5c16673cf43dc80baabf42ed22ff5eafd Mon Sep 17 00:00:00 2001
From: Philipp Zabel
Date: Wed, 27 Nov 2024 10:20:25 +0100
Subject: [PATCH] etnaviv/ml: Create combined input tensors for addition first
Fix addition where one summand was already used as input to an earlier
operation, for example in the last operation of MobileNet V2 residual
blocks.
Fixes an assertion when trying to run MobileNet V2:
.../src/gallium/drivers/etnaviv/etnaviv_ml.c:58: etna_ml_create_tensor: Assertion `size == pipe_buffer_size(res)' failed.
Reviewed-by: Tomeu Vizoso
Signed-off-by: Philipp Zabel
Part-of:
---
src/gallium/drivers/etnaviv/etnaviv_ml.c | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/src/gallium/drivers/etnaviv/etnaviv_ml.c b/src/gallium/drivers/etnaviv/etnaviv_ml.c
index 2b29ef28ba3..3d9edfc304b 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_ml.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_ml.c
@@ -55,7 +55,7 @@ etna_ml_create_tensor(struct etna_ml_subgraph *subgraph, unsigned idx, unsigned
struct pipe_resource *res = tensors[idx];
if (res != NULL) {
- assert(size == pipe_buffer_size(res));
+ assert(size == pipe_buffer_size(res) || size == pipe_buffer_size(res) / 2);
return;
}
@@ -315,7 +315,11 @@ lower_operations(struct etna_ml_subgraph *subgraph,
}
}
+ /* Create combined input tensors first */
list_for_each_entry(struct etna_operation, operation, etna_operations, link) {
+ if (operation->input_count == 1)
+ continue;
+
etna_ml_create_tensor(subgraph, operation->input_tensors[0], operation->input_tensor_size);
for (int i = 1; i < operation->input_count; i++)
@@ -327,6 +331,14 @@ lower_operations(struct etna_ml_subgraph *subgraph,
}
+ /* Create all other input tensors */
+ list_for_each_entry(struct etna_operation, operation, etna_operations, link) {
+ if (operation->input_count != 1)
+ continue;
+
+ etna_ml_create_tensor(subgraph, operation->input_tensors[0], operation->input_tensor_size);
+ }
+
/* Create any output tensors that aren't inputs to other operations, these
* are the outputs of the graph.
*/