ethosu: fix blockdep to check for data dependencies
Some checks are pending
macOS-CI / macOS-CI (dri) (push) Waiting to run
macOS-CI / macOS-CI (xlib) (push) Waiting to run

calc_blockdep always returned MAX_BLOCKDEP without checking if the
previous op writes to a buffer the current op reads from. This let
the NPU start reading before the previous write was done.

Add overlap check between previous OFM and current IFM so we set
blockdep to 0 when they share the same buffer.

Update ethos-imx93-fails.txt to remove the tests that now pass.

Signed-off-by: Anders Roxell <anders.roxell@linaro.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/39594>
This commit is contained in:
Anders Roxell 2026-02-27 14:12:53 +01:00 committed by Marge Bot
parent 17435b6a58
commit ea731cda12
2 changed files with 25 additions and 4 deletions

View file

@ -1,5 +1,4 @@
Models.Op/efficientdet_efficientdet_tflite_lite0_int8_v1,Fail
Models.Op/micronetlarge_ad_large_int8,Fail
Models.Op/movenetlightning_089,Fail
Models.Op/movenetlightning_090,Fail
Models.Op/movenetlightning_093,Fail
@ -42,5 +41,3 @@ Models.Op/movenetthunder_141,Fail
Models.Op/movenetthunder_151,Fail
Models.Op/movenetthunder_152,Fail
Models.Op/movenetthunder_movenet_single_pose_thunder_ptq,Fail
Models.Op/ssdmobilenetv2_ssd_mobilenet_v2_coco_quant_postprocess,Fail
Models.Op/mobilenetv2_mobilenet_v2_tflite_1_0_224_quantized_v1,Fail

View file

@ -618,6 +618,20 @@ fill_memory_accesses(struct ethosu_subgraph *subgraph)
}
}
static bool
fm_ranges_overlap(struct ethosu_subgraph *subgraph,
struct ethosu_feature_map *a, struct ethosu_feature_map *b)
{
struct ethosu_tensor *ta = ethosu_find_tensor(subgraph, a->tensor_idx);
struct ethosu_tensor *tb = ethosu_find_tensor(subgraph, b->tensor_idx);
if (!ta || !tb || ta->size == 0 || tb->size == 0)
return false;
return ta->offset < tb->offset + tb->size &&
tb->offset < ta->offset + ta->size;
}
static unsigned
calc_blockdep(struct ethosu_subgraph *subgraph, struct ethosu_operation *prev_op, struct ethosu_operation *operation)
{
@ -630,7 +644,17 @@ calc_blockdep(struct ethosu_subgraph *subgraph, struct ethosu_operation *prev_op
if (prev_uses_lut && SHRAM_RESERVED_UNUSED_BANKS == 0 && !curr_uses_lut)
return 0;
return MAX_BLOCKDEP; /* TODO: Check if there is actually overlap between the FMs */
/* If the previous op writes to the same buffer that the current op
* reads from, we need to wait for it to finish first.
*/
bool ifm_overlaps = fm_ranges_overlap(subgraph, &prev_op->ofm, &operation->ifm);
bool ifm2_overlaps = operation->type == ETHOSU_OPERATION_TYPE_ELTWISE &&
fm_ranges_overlap(subgraph, &prev_op->ofm, &operation->ifm2);
if (ifm_overlaps || ifm2_overlaps)
return 0;
return MAX_BLOCKDEP;
}
void