teflon: Add support for the MaxPool operation

Acked-by: Christian Gmeiner <cgmeiner@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36699>
This commit is contained in:
Tomeu Vizoso 2025-08-09 10:37:01 +02:00 committed by Marge Bot
parent 48983c3198
commit 83b9eb038f
2 changed files with 27 additions and 1 deletions

View file

@ -166,9 +166,22 @@ fill_operation(struct teflon_delegate *delegate, TfLiteContext *tf_context, TfLi
operation->conv.weight_tensor->dims[2] == 1;
break;
}
case kTfLiteBuiltinAveragePool2d:
case kTfLiteBuiltinMaxPool2d:
operation->pooling.type = PIPE_ML_POOLING_TYPE_MAX;
__attribute__((fallthrough));
case kTfLiteBuiltinAveragePool2d: {
TfLitePoolParams *params = node->builtin_data;
operation->type = PIPE_ML_OPERATION_TYPE_POOLING;
/* Skip setting operation->pooling.type for PIPE_ML_POOLING_TYPE_AVG==0 */
operation->pooling.filter_height = params->filter_height;
operation->pooling.filter_width = params->filter_width;
operation->pooling.stride_x = params->stride_width;
operation->pooling.stride_y = params->stride_height;
operation->pooling.padding_same = params->padding == kTfLitePaddingSame;
break;
}
case kTfLiteBuiltinAdd:
operation->type = PIPE_ML_OPERATION_TYPE_ADD;
break;
@ -573,6 +586,8 @@ tflite_builtin_op_name(TfLiteBuiltinOperator op)
return "ADD";
case kTfLiteBuiltinAveragePool2d:
return "AVGPOOL";
case kTfLiteBuiltinMaxPool2d:
return "MAXPOOL";
case kTfLiteBuiltinConv2d:
return "CONV";
case kTfLiteBuiltinDepthwiseConv2d:

View file

@ -1056,6 +1056,11 @@ enum pipe_ml_operation_type {
PIPE_ML_OPERATION_TYPE_TRANSPOSE,
};
enum pipe_ml_pooling_type {
PIPE_ML_POOLING_TYPE_AVG,
PIPE_ML_POOLING_TYPE_MAX,
};
/**
* Information about a single operation inside a ML subgraph.
*/
@ -1124,6 +1129,12 @@ struct pipe_ml_operation
unsigned dilation_height_factor;
} conv;
struct {
/**
* Type of pooling operation.
*/
enum pipe_ml_pooling_type type;
/**
* Stride used to access the input tensor on the x axis.
*/