mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-07 00:38:48 +02:00
ethosu: Add minimum and maximum operators
Signed-off-by: Rob Herring (Arm) <robh@kernel.org> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/39975>
This commit is contained in:
parent
03e29e2fa5
commit
4e8e4ca2fc
3 changed files with 31 additions and 0 deletions
|
|
@ -724,6 +724,17 @@ simplified_elementwise_add_sub_scale(
|
|||
*out_out_scale = ethosu_quantize_scale(output_rescale_val, out_out_shift, false);
|
||||
}
|
||||
|
||||
static void
|
||||
elementwise_min_max_scale(struct ethosu_subgraph *subgraph)
|
||||
{
|
||||
if (!ethosu_ml_device(subgraph->base.device)->is_u65) {
|
||||
EMIT1(NPU_SET_OPA_SCALE, 0, 1);
|
||||
EMIT1(NPU_SET_OPB_SCALE, 0, 1);
|
||||
|
||||
}
|
||||
EMIT1(NPU_SET_OFM_SCALE, 0, 1);
|
||||
}
|
||||
|
||||
static void
|
||||
elementwise_mul_scale(
|
||||
struct ethosu_subgraph *subgraph,
|
||||
|
|
@ -815,6 +826,10 @@ emit_eltwise(struct ethosu_subgraph *subgraph, struct ethosu_operation *operatio
|
|||
op_to_scale = OP_A;
|
||||
}
|
||||
break;
|
||||
case ETHOSU_ELTWISE_TYPE_MAX:
|
||||
case ETHOSU_ELTWISE_TYPE_MIN:
|
||||
elementwise_min_max_scale(subgraph);
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -877,6 +877,20 @@ ethosu_lower_graph(struct ethosu_subgraph *subgraph,
|
|||
break;
|
||||
}
|
||||
|
||||
case PIPE_ML_OPERATION_TYPE_MAXIMUM: {
|
||||
ethosu_lower_eltwise(subgraph, &poperations[i], &operation);
|
||||
operation.eltwise.type = ETHOSU_ELTWISE_TYPE_MAX;
|
||||
util_dynarray_append(&subgraph->operations, operation);
|
||||
break;
|
||||
}
|
||||
|
||||
case PIPE_ML_OPERATION_TYPE_MINIMUM: {
|
||||
ethosu_lower_eltwise(subgraph, &poperations[i], &operation);
|
||||
operation.eltwise.type = ETHOSU_ELTWISE_TYPE_MIN;
|
||||
util_dynarray_append(&subgraph->operations, operation);
|
||||
break;
|
||||
}
|
||||
|
||||
case PIPE_ML_OPERATION_TYPE_POOLING: {
|
||||
ethosu_lower_pooling(subgraph, &poperations[i], &operation);
|
||||
util_dynarray_append(&subgraph->operations, operation);
|
||||
|
|
|
|||
|
|
@ -140,6 +140,8 @@ ethosu_ml_operation_supported(struct pipe_ml_device *pdevice,
|
|||
|
||||
break;
|
||||
}
|
||||
case PIPE_ML_OPERATION_TYPE_MAXIMUM:
|
||||
case PIPE_ML_OPERATION_TYPE_MINIMUM:
|
||||
case PIPE_ML_OPERATION_TYPE_MUL:
|
||||
case PIPE_ML_OPERATION_TYPE_ADD:
|
||||
case PIPE_ML_OPERATION_TYPE_POOLING:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue