From 0001dab219cadbda45ce773e63fa4c45d477aa7e Mon Sep 17 00:00:00 2001 From: Tomeu Vizoso Date: Sat, 9 Aug 2025 10:37:59 +0200 Subject: [PATCH] teflon: Add support for the StridedSlice operation Acked-by: Christian Gmeiner Part-of: --- src/gallium/frontends/teflon/tfl_device.c | 17 +++++++++++++++++ src/gallium/include/pipe/p_state.h | 7 +++++++ 2 files changed, 24 insertions(+) diff --git a/src/gallium/frontends/teflon/tfl_device.c b/src/gallium/frontends/teflon/tfl_device.c index 6394bb3285a..71903bea149 100644 --- a/src/gallium/frontends/teflon/tfl_device.c +++ b/src/gallium/frontends/teflon/tfl_device.c @@ -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"; } diff --git a/src/gallium/include/pipe/p_state.h b/src/gallium/include/pipe/p_state.h index d9c887bab9f..f67d813339c 100644 --- a/src/gallium/include/pipe/p_state.h +++ b/src/gallium/include/pipe/p_state.h @@ -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; }; };