Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convolution2DTransposeBias support #165

Open
vsi-minggang opened this issue Feb 10, 2023 · 0 comments
Open

Convolution2DTransposeBias support #165

vsi-minggang opened this issue Feb 10, 2023 · 0 comments

Comments

@vsi-minggang
Copy link

I am filing this jira separately and closing the originating jira.
Mediapipe framework is very popular and has lots of useful models. A lot of these models use the Convolution2DTransposeBias custom operation. Please evaluate if it would be possible to add support for this operation. It is effectively a transposed convolution layer + add bias implemented in one operation. You can find more details in this post:
google-ai-edge/mediapipe#245

The operation is supported by tflite for a while in the GPU delegate and the XNNPACK delegate. You may even have this operation supported already but just need a code to recognize it and to convert it into acuity operation.

The GPU implementation in tflite is here:
https://github.com/tensorflow/tensorflow/blob/master/tensorflow/lite/delegates/gpu/gl/kernels/transpose_conv.cc

The XNNPACK implementation is here:
https://github.com/google/XNNPACK/blob/master/src/subgraph/deconvolution-2d.c#L356

It is effectively a transposed convolution layer + add bias implemented in one operation. You can find more details in this post:
google-ai-edge/mediapipe#245

the XNNPACK delegate implements the operation but it does not register it for some reason. You need to add a following code to your application:

/registration function/
TfLiteRegistration* RegisterConvolution2DTransposeBias() {
static TfLiteRegistration reg = {nullptr, nullptr, nullptr, nullptr};
return ®
}
... /somewhere down below where resolver is created/

// Build the interpreter with the InterpreterBuilder.
// Note: all Interpreters should be built with the InterpreterBuilder,
// which allocates memory for the Intrepter and does various set up
// tasks so that the Interpreter can read the provided model.
tflite::ops::builtin::BuiltinOpResolver resolver;
/must add custom op for it to be resolved/
resolver.AddCustom("Convolution2DTransposeBias", RegisterConvolution2DTransposeBias());

tflite::InterpreterBuilder builder(*model, resolver);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant