ethosu: Add quantize operation

The quantize operation lowers to a pooling nop operation.

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:
Rob Herring (Arm) 2026-03-10 20:50:41 -05:00 committed by Marge Bot
parent e6f4f6aa5d
commit 08d93a60f5
2 changed files with 27 additions and 0 deletions

View file

@ -582,6 +582,26 @@ ethosu_lower_leakyrelu(struct ethosu_subgraph *subgraph,
ethosu_sched_operation(subgraph, operation);
}
static void
ethosu_lower_quantize(struct ethosu_subgraph *subgraph,
const struct pipe_ml_operation *poperation,
struct ethosu_operation *operation)
{
operation->type = ETHOSU_OPERATION_TYPE_POOLING;
operation->round_mode = ETHOSU_ROUNDING_DOUBLE;
operation->pooling.nop = true;
if (ethosu_ml_device(subgraph->base.device)->is_u65)
operation->pooling.type = ETHOSU_POOLING_TYPE_AVG;
else
operation->pooling.type = ETHOSU_POOLING_TYPE_SUM;
set_feature_maps(subgraph, poperation->input_tensors[0], poperation->output_tensors[0], operation);
allocate_feature_maps(subgraph, operation);
ethosu_sched_operation(subgraph, operation);
}
static void
ethosu_lower_concatenation(struct ethosu_subgraph *subgraph,
const struct pipe_ml_operation *poperation,
@ -914,6 +934,12 @@ ethosu_lower_graph(struct ethosu_subgraph *subgraph,
break;
}
case PIPE_ML_OPERATION_TYPE_QUANTIZE: {
ethosu_lower_quantize(subgraph, &poperations[i], &operation);
util_dynarray_append(&subgraph->operations, operation);
break;
}
default:
DBG("poperation->type %d\n", poperations[i].type);
UNREACHABLE("Unsupported ML operation type");

View file

@ -149,6 +149,7 @@ ethosu_ml_operation_supported(struct pipe_ml_device *pdevice,
case PIPE_ML_OPERATION_TYPE_TANH:
case PIPE_ML_OPERATION_TYPE_HSWISH:
case PIPE_ML_OPERATION_TYPE_LEAKY_RELU:
case PIPE_ML_OPERATION_TYPE_QUANTIZE:
supported = true;
break;
case PIPE_ML_OPERATION_TYPE_RESIZE: {