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 <tomeu@tomeuvizoso.net> Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31987>
This commit is contained in:
@@ -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.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user