teflon: Add LeakyRelu operation

Add the plumbing for LeakyRelu operations.

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-02-24 16:50:16 -06:00 committed by Marge Bot
parent 3487b15312
commit 15bc152185
2 changed files with 17 additions and 0 deletions

View file

@ -246,6 +246,13 @@ fill_operation(struct teflon_delegate *delegate, TfLiteContext *tf_context, TfLi
memcpy(operation->reshape.shape, shape, 4 * sizeof(*operation->reshape.shape));
break;
}
case kTfLiteBuiltinLeakyRelu: {
TfLiteLeakyReluParams *params = node->builtin_data;
operation->type = PIPE_ML_OPERATION_TYPE_LEAKY_RELU;
operation->leakyrelu.alpha = params->alpha;
break;
}
case kTfLiteBuiltinRelu:
operation->type = PIPE_ML_OPERATION_TYPE_RELU;
break;
@ -507,6 +514,9 @@ dump_graph(struct pipe_tensor *tensors, unsigned tensor_count, struct pipe_ml_op
case PIPE_ML_OPERATION_TYPE_MUL:
teflon_debug("%-15s ", "MUL");
break;
case PIPE_ML_OPERATION_TYPE_LEAKY_RELU:
teflon_debug("%-15s ", "LEAKY_RELU");
break;
}
char *input_buf = ralloc_strdup(NULL, "");
@ -740,6 +750,8 @@ tflite_builtin_op_name(TfLiteBuiltinOperator op)
return "SUB";
case kTfLiteBuiltinTranspose:
return "TRANSPOSE";
case kTfLiteBuiltinLeakyRelu:
return "LEAKY_RELU";
default:
return "unknown";
}

View file

@ -1068,6 +1068,7 @@ enum pipe_ml_operation_type {
PIPE_ML_OPERATION_TYPE_STRIDED_SLICE,
PIPE_ML_OPERATION_TYPE_RESIZE,
PIPE_ML_OPERATION_TYPE_MUL,
PIPE_ML_OPERATION_TYPE_LEAKY_RELU,
};
enum pipe_ml_pooling_type {
@ -1268,6 +1269,10 @@ struct pipe_ml_operation
int end[4];
int strides[4];
} slice;
struct {
float alpha;
} leakyrelu;
};
};