google-coral / libedgetpu

Source code for the userspace level runtime driver for Coral.ai devices.
Apache License 2.0
179 stars 60 forks source link

added support for armv6-linux-guneabihf and riscv64-linux-{gnu,musl} #61

Open cocoa-xu opened 5 months ago

cocoa-xu commented 5 months ago

Hi this PR added support for building libedgetpu for armv6-linux-guneabihf and riscv64-linux-{gnu,musl}. It allows old armv6 devices to be able to use edgetpu devices with Tensorflow Lite, and builds for newer riscv64 single board computers.

It should be able to generate libedgetpu runtime binaries as in https://github.com/cocoa-xu/libedgetpu/releases/tag/v0.1.8, which have been used in my Erlang/OTP binding for TensorFlow Lite tflite_beam for about a year.

google-cla[bot] commented 5 months ago

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Namburger commented 5 months ago

@cocoa-xu any reason to close this PR? I was looking at it :)

cocoa-xu commented 5 months ago

Hi @Namburger, I closed this PR because it appeared that no one was interested in adding support for armv6 and riscv64 devices for this library, and was planning to maintain the support on my own fork.

Namburger commented 5 months ago

@cocoa-xu I see, I was going to ask you for your usages/test devices. I haven't use an armv6 device in a long time and don't have one to readily test your PR.

cocoa-xu commented 5 months ago

@cocoa-xu I see, I was going to ask you for your usages

As for the usages, my motivation is that if this library can be used on armv6/riscv64 devices, it allows users to use edgetpus with old armv6 boards like RPi 0, and newer riscv64 boards like MangoPi and VisionFive 2.

And there were some attempts from users who wanted to bring back armv6 support in the pycoral repo, https://github.com/google-coral/pycoral/issues/8, https://github.com/google-coral/edgetpu/issues/229#issuecomment-751504398, https://github.com/google-coral/pycoral/issues/7. But the solution was outdated and never in the official codebase.

...test devices.

As for test devices, I have a RPi 0 (armv6), Mangopi MQ Pro (riscv64) and a VisionFive 2 (riscv64).

Namburger commented 5 months ago

Interesting, I didn't know RPi 0 is armv6 o_0

And there were some attempts from users who wanted to bring back armv6 support in the pycoral repo, google-coral/pycoral#8, google-coral/edgetpu#229 (comment), google-coral/pycoral#7. But the solution was outdated and never in the official codebase.

I remember all of those issues, as you could tell it has been awhile since I'm involved with coral so there is a ton of catching up to do :)

Please re-open, I'll take a look at this PR sometimes this week!

cocoa-xu commented 5 months ago

I remember all of those issues, as you could tell it has been awhile since I'm involved with coral so there is a ton of catching up to do :)

Please re-open, I'll take a look at this PR sometimes this week!

No problem! I've re-opened this PR, and I'm happy to do further changes. :)

feranick commented 5 months ago

Quick question: libedgetpu requires tflite_runtime. This has support for arm6, but does it have also support for riscv64?

cocoa-xu commented 5 months ago

Quick question: libedgetpu requires tflite_runtime. This has support for arm6, but does it have also support for riscv64?

Yes, we can use tflite on riscv64 boards!

And we also have prebuilt images for a riscv64 board, MangoPi MQ Pro. Although TensorFlow may or may not have optimisations for riscv64 CPUs, there are prebuilt livebook images (tflite is included as a dependency) available for MangoPi MQ Pro here (also see the livebook release page and the tflite_beam release page).

cocoa-xu commented 5 months ago

And below is a screenshot of tflite (as an Erlang/Elixir binding) running on a riscv64 board in livebook. I'm using mobilenet_v2_1.0_224_inat_bird_quant.tflite and the sample image as the testing neural network and input. It took 7.6 seconds to do the inference task without the coral device (as the device is not with me at the moment, but I tested it before).

Screenshot 2024-03-08 at 01 35 48
mxchinegod commented 2 months ago

Just eager to see progress on this as it's been 4 years without arm6 support. Thank you @cocoa-xu

cocoa-xu commented 2 months ago

Hi @Namburger, it seems that this PR is kinda stale, would it be easier for us all if I split this into a few smaller PRs?

feranick commented 2 months ago

This is not my call to make as I have no admin access to the repo.

cocoa-xu commented 2 months ago

This is not my call to make as I have no admin access to the repo.

Oops.. sorry for the wrong ping!