teflon: Add support for the StridedSlice 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:59 +02:00 committed by Marge Bot
parent 83b9eb038f
commit 0001dab219
2 changed files with 24 additions and 0 deletions

View file

@ -257,6 +257,18 @@ fill_operation(struct teflon_delegate *delegate, TfLiteContext *tf_context, TfLi
memcpy(operation->transpose.perm, perm, 4 * sizeof(*operation->transpose.perm));
break;
}
case kTfLiteBuiltinStridedSlice: {
int *begin = tf_context->tensors[node->inputs->data[1]].data.data;
int *end = tf_context->tensors[node->inputs->data[2]].data.data;
int *strides = tf_context->tensors[node->inputs->data[3]].data.data;
operation->type = PIPE_ML_OPERATION_TYPE_STRIDED_SLICE;
memcpy(operation->slice.begin, begin, sizeof(operation->slice.begin));
memcpy(operation->slice.end, end, sizeof(operation->slice.end));
memcpy(operation->slice.strides, strides, sizeof(operation->slice.strides));
break;
}
default:
return false;
}
@ -405,6 +417,9 @@ dump_graph(struct pipe_tensor *tensors, unsigned tensor_count, struct pipe_ml_op
case PIPE_ML_OPERATION_TYPE_TRANSPOSE:
teflon_debug("%-6s ", "TRANSPOSE");
break;
case PIPE_ML_OPERATION_TYPE_STRIDED_SLICE:
teflon_debug("%-6s ", "STRIDED_SLICE");
break;
}
for (unsigned j = 0; j < operations[i].input_count; j++) {
@ -612,6 +627,8 @@ tflite_builtin_op_name(TfLiteBuiltinOperator op)
return "FC";
case kTfLiteBuiltinMean:
return "MEAN";
case kTfLiteBuiltinStridedSlice:
return "STRIDED_SLICE";
default:
return "unknown";
}

View file

@ -1054,6 +1054,7 @@ enum pipe_ml_operation_type {
PIPE_ML_OPERATION_TYPE_LOGISTIC,
PIPE_ML_OPERATION_TYPE_SUBTRACT,
PIPE_ML_OPERATION_TYPE_TRANSPOSE,
PIPE_ML_OPERATION_TYPE_STRIDED_SLICE,
};
enum pipe_ml_pooling_type {
@ -1232,6 +1233,12 @@ struct pipe_ml_operation
struct {
unsigned perm[4];
} transpose;
struct {
int begin[4];
int end[4];
int strides[4];
} slice;
};
};