diff --git a/src/gallium/frontends/teflon/tfl_device.c b/src/gallium/frontends/teflon/tfl_device.c index 012dfacd74f..15069ffa38a 100644 --- a/src/gallium/frontends/teflon/tfl_device.c +++ b/src/gallium/frontends/teflon/tfl_device.c @@ -304,6 +304,11 @@ fill_operation(struct teflon_delegate *delegate, TfLiteContext *tf_context, TfLi operation->type = PIPE_ML_OPERATION_TYPE_QUANTIZE; break; } + case kTfLiteBuiltinCustom: { + operation->type = PIPE_ML_OPERATION_TYPE_CUSTOM; + operation->custom.name = node_registration->custom_name ? strdup(node_registration->custom_name) : NULL; + break; + } default: return false; } @@ -536,6 +541,9 @@ dump_graph(struct pipe_tensor *tensors, unsigned tensor_count, struct pipe_ml_op case PIPE_ML_OPERATION_TYPE_LEAKY_RELU: teflon_debug("%-15s ", "LEAKY_RELU"); break; + case PIPE_ML_OPERATION_TYPE_CUSTOM: + teflon_debug("%-15s ", "CUSTOM"); + break; } char *input_buf = ralloc_strdup(NULL, ""); @@ -775,6 +783,8 @@ tflite_builtin_op_name(TfLiteBuiltinOperator op) return "TRANSPOSE"; case kTfLiteBuiltinLeakyRelu: return "LEAKY_RELU"; + case kTfLiteBuiltinCustom: + return "CUSTOM"; default: return "unknown"; } @@ -929,8 +939,12 @@ PrepareDelegate(TfLiteContext *tf_context, TfLiteDelegate *tf_delegate) } teflon_debug("\n"); - if (supported) + if (supported) { supported_nodes->data[node_count++] = node_index; + // If custom node is claimed by teflon delegate, tell other delegates to skip it + if (registration->builtin_code == kTfLiteBuiltinCustom) + registration->builtin_code = kTfLiteBuiltinDelegate; + } } supported_nodes->size = node_count; diff --git a/src/gallium/include/pipe/p_state.h b/src/gallium/include/pipe/p_state.h index cbce129eea2..45f625d110c 100644 --- a/src/gallium/include/pipe/p_state.h +++ b/src/gallium/include/pipe/p_state.h @@ -1072,6 +1072,7 @@ enum pipe_ml_operation_type { PIPE_ML_OPERATION_TYPE_QUANTIZE, PIPE_ML_OPERATION_TYPE_MAXIMUM, PIPE_ML_OPERATION_TYPE_MINIMUM, + PIPE_ML_OPERATION_TYPE_CUSTOM, }; enum pipe_ml_pooling_type { @@ -1276,6 +1277,9 @@ struct pipe_ml_operation struct { float alpha; } leakyrelu; + struct { + char *name; + } custom; }; };