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

Implement Custom Ops in build #3

Open
ragavendranbala opened this issue Jun 15, 2020 · 8 comments
Open

Implement Custom Ops in build #3

ragavendranbala opened this issue Jun 15, 2020 · 8 comments

Comments

@ragavendranbala
Copy link

ragavendranbala commented Jun 15, 2020

Hi @terryky , I want to load the hairsegmentation model in python but when i try to initialize the tflite model in interpreter, it always showing MaxPoolingWithArgmax2D ops error. Can you tell me how to build this custom ops with bazel when building tensorflow. if I'm wrong please tell me how to implement custom ops. Thanks in Advance

@terryky
Copy link
Owner

terryky commented Jun 15, 2020

Hi @ragavendranbala,

I'm not familier with Tensorflow Lite python API, but It's easy to implement custom Op in C++ API.
Please refer follows:

@ragavendranbala
Copy link
Author

@terryky thanks for your reply, actually i wanted to build the plugin for android, i think , to make it work on android, i need to add this custom ops while building the plugin itelf. I have searched for links to reference the plugin in build. but no luck. i guess the build of plugin working on c++ only. I''m expecting your ideas for this

@ragavendranbala
Copy link
Author

hi @terryky , I have built the plugin which custom ops. now i need to know, is this running on CPU or GPU? is there is any possibilities to make the ops to run on GPU?

@terryky
Copy link
Owner

terryky commented Jun 16, 2020

Tensorflow Lite GPU Delegate supports following custom operations.
If your implementation enables GPU Delegate, the custom ops run on GPU.

https://github.com/tensorflow/tensorflow/blob/master/tensorflow/lite/delegates/gpu/common/model_builder.cc#L2715-L2753

@ragavendranbala
Copy link
Author

@terryky the link you have given having the ops functions, but i think it's not building with my plugin

bazel build -c opt --config android_arm64 --copt -Os --copt -DTFLITE_GPU_BINARY_RELEASE --copt -fvisibility=hidden --linkopt -s --strip always //tensorflow/lite/delegates/gpu:libtensorflowlite_gpu_delegate.so

This is command I'm using to build my GPU delegate.

Should I add any files to make it work on GPU?

@terryky
Copy link
Owner

terryky commented Jun 16, 2020

Does your app enable GPU Delegate ?

delegate = TfLiteGpuDelegateV2Create(&options);
interpreter->ModifyGraphWithDelegate(delegate)

https://github.com/terryky/tflite_gles_app/blob/master/common/util_tflite.cpp#L167-L174

@ragavendranbala
Copy link
Author

ragavendranbala commented Jun 17, 2020

@terryky The plugin I have created running deeplab v3 on smoothly but this tflite is hicking up , based on the deeplab performance, I think gpu delegate is enabled

@soham24
Copy link

soham24 commented Jan 18, 2021

@ragavendranbala can you share the android implementation

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

3 participants