diff --git a/src/gallium/frontends/teflon/tfl_device.c b/src/gallium/frontends/teflon/tfl_device.c index 006c9ec5c6d..22411795306 100644 --- a/src/gallium/frontends/teflon/tfl_device.c +++ b/src/gallium/frontends/teflon/tfl_device.c @@ -161,6 +161,16 @@ fill_operation(struct teflon_delegate *delegate, TfLiteContext *tf_context, TfLi case kTfLiteBuiltinSplit: operation->type = PIPE_ML_OPERATION_TYPE_SPLIT; break; + case kTfLiteBuiltinPad: { + int32_t *paddings = tf_context->tensors[node->inputs->data[1]].data.data; + + operation->type = PIPE_ML_OPERATION_TYPE_PAD; + operation->pad.before_x = paddings[2]; + operation->pad.after_x = paddings[3]; + operation->pad.before_y = paddings[4]; + operation->pad.after_y = paddings[5]; + break; + } default: unreachable("Unsupported ML operation type"); } @@ -239,6 +249,9 @@ dump_graph(struct pipe_tensor *tensors, unsigned tensor_count, struct pipe_ml_op case PIPE_ML_OPERATION_TYPE_SPLIT: teflon_debug("%-6s ", "SPLIT"); break; + case PIPE_ML_OPERATION_TYPE_PAD: + teflon_debug("%-6s ", "PAD"); + break; } for (unsigned j = 0; j < operations[i].input_count; j++) { @@ -560,6 +573,18 @@ PrepareDelegate(TfLiteContext *context, TfLiteDelegate *delegate) break; } + case kTfLiteBuiltinPad: { + uint32_t *padding = context->tensors[node->inputs->data[1]].data.data; + supported = padding[0] == 0 && + padding[1] == 0 && + padding[2] == 1 && + padding[3] == 1 && + padding[4] == 1 && + padding[5] == 1 && + padding[6] == 0 && + padding[7] == 0; + break; + } } if (supported) diff --git a/src/gallium/include/pipe/p_state.h b/src/gallium/include/pipe/p_state.h index a497198708c..8d59b5decfd 100644 --- a/src/gallium/include/pipe/p_state.h +++ b/src/gallium/include/pipe/p_state.h @@ -1061,6 +1061,7 @@ enum pipe_ml_operation_type { PIPE_ML_OPERATION_TYPE_POOLING, PIPE_ML_OPERATION_TYPE_CONCATENATION, PIPE_ML_OPERATION_TYPE_SPLIT, + PIPE_ML_OPERATION_TYPE_PAD, }; /** @@ -1152,6 +1153,26 @@ struct pipe_ml_operation */ bool padding_same; } pooling; + struct { + /** + * Left padding. + */ + unsigned before_x; + + /** + * Right padding. + */ + unsigned after_x; + + /** + * Top padding. + */ + unsigned before_y; + /** + * Bottom padding. + */ + unsigned after_y; + } pad; }; };