{"id":19416846,"url":"https://github.com/acceleratehs/accelerate-tensorflow","last_synced_at":"2025-10-09T03:40:06.983Z","repository":{"id":45000447,"uuid":"408870814","full_name":"AccelerateHS/accelerate-tensorflow","owner":"AccelerateHS","description":null,"archived":false,"fork":false,"pushed_at":"2023-09-18T12:58:57.000Z","size":287,"stargazers_count":3,"open_issues_count":6,"forks_count":3,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-04-24T13:41:00.968Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Haskell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AccelerateHS.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2021-09-21T15:18:09.000Z","updated_at":"2023-08-24T02:18:11.000Z","dependencies_parsed_at":"2025-04-24T13:49:08.374Z","dependency_job_id":null,"html_url":"https://github.com/AccelerateHS/accelerate-tensorflow","commit_stats":null,"previous_names":["acceleratehs/accelerate-tensorflow"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/AccelerateHS/accelerate-tensorflow","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AccelerateHS%2Faccelerate-tensorflow","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AccelerateHS%2Faccelerate-tensorflow/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AccelerateHS%2Faccelerate-tensorflow/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AccelerateHS%2Faccelerate-tensorflow/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AccelerateHS","download_url":"https://codeload.github.com/AccelerateHS/accelerate-tensorflow/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AccelerateHS%2Faccelerate-tensorflow/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279000714,"owners_count":26082911,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-09T02:00:07.460Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-10T13:05:46.776Z","updated_at":"2025-10-09T03:40:06.955Z","avatar_url":"https://github.com/AccelerateHS.png","language":"Haskell","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\u003cimg width=\"450\" src=\"https://github.com/AccelerateHS/accelerate/raw/master/images/accelerate-logo-text-v.png?raw=true\" alt=\"henlo, my name is Theia\"/\u003e\n\n# TensorFlow backend for the Accelerate array language\n\n[![CI-Linux](https://github.com/tmcdonell/accelerate-tensorflow/workflows/ci-linux/badge.svg)](https://github.com/tmcdonell/accelerate-tensorflow/actions?query=workflow%3Aci-linux)\n[![CI-MacOS](https://github.com/tmcdonell/accelerate-tensorflow/workflows/ci-macos/badge.svg)](https://github.com/tmcdonell/accelerate-tensorflow/actions?query=workflow%3Aci-macos)\n[![CI-Windows](https://github.com/tmcdonell/accelerate-tensorflow/workflows/ci-windows/badge.svg)](https://github.com/tmcdonell/accelerate-tensorflow/actions?query=workflow%3Aci-windows)\n\u003cbr\u003e\n[![Stackage LTS](https://stackage.org/package/accelerate-tensorflow/badge/lts)](https://stackage.org/lts/package/accelerate-tensorflow)\n[![Stackage Nightly](https://stackage.org/package/accelerate-tensorflow/badge/nightly)](https://stackage.org/nightly/package/accelerate-tensorflow)\n[![Hackage](https://img.shields.io/hackage/v/accelerate-tensorflow.svg)](https://hackage.haskell.org/package/accelerate-tensorflow)\n\n\u003c/div\u003e\n\n# EXPERIMENTAL: BE AWARE\n\nThis repository contains experimental code.\nNeither the plain TensorFlow CPU backend nor the TFLite backend support all Accelerate primitives, and there are multiple compatibility as well as correctness issues with Coral's TPU SDK and (probably) our usage of it.\n\nThe packages here are **NOT** yet suitable for actual use.\n\n## Packages\n\nThis repository contains two packages:\n- `accelerate-tensorflow` compiles\n  [Accelerate](https://github.com/AccelerateHS/accelerate) code to a\n  [TensorFlow](https://www.tensorflow.org) graph. It allows running that graph\n  on the default TensorFlow backend (CPU).\n- `accelerate-tensorflow-lite` extends `accelerate-tensorflow` and allows\n  running the graph on a TPU using [Coral (from Google)](https://coral.ai/)'s\n  `libedgetpu` and the accompanying `edgetpu_compiler`. This works by\n  converting the graph to a TensorFlow Lite (TFLite) model, hence the name of\n  the package.\n\nContributions and bug reports are welcome.\n\n## Dependencies\n\nMany things are built from source in this repository, either because we need to apply some patches or because we need somewhat different transitive dependency versions than the upstream pre-compiled download has.\nStill, a few things need to be installed on the system.\n\n1. From the [Coral apt repository](https://coral.ai/software/#debian-packages), get the `edgetpu_compiler` package.\n   (The other edgetpu libraries are either not needed or compiled from source here.)\n\n2. Furthermore, install the following packages:\n   - GHC 8.10.7 and its dependencies (see the ghcup instructions)\n   - All dependencies needed by GHC\n   - The protobuf compiler `protoc` (`protobuf-compiler` on Ubuntu, or see [here](https://google.github.io/proto-lens/installing-protoc.html)).\n   - `curl`, `gawk`, `libusb-1.0-0-dev` (on Ubuntu)\n   - Python 3.10 (not 3.11!), including `pip`. Furthermore ensure that `python3` is available in PATH under the name `python`, to satisfy TensorFlow's build process.\n\nA sequence of commands starting from a (virtual) machine running fresh, \"minimal\" Ubuntu Server 22.04.3 and ending up with running the test suite is listed in [ubuntu-build-instructions.txt](ubuntu-build-instructions.txt), but note that this excludes two things:\n1. The installation of the Coral `edgetpu_compiler`;\n2. The setup of the udev rules: see the next section.\n\n\n## Udev rules\n\nIn order to be able to access the TPU hardware using a non-root user, you will need to set up udev rules.\nFor the Coral USB Accelerator, the following rules work: (note that both rules are necessary)\n```\n$ cat /etc/udev/rules.d/99-edgetpu-accelerator.rules\nSUBSYSTEM==\"usb\",ATTRS{idVendor}==\"1a6e\",GROUP=\"edgetpu\"\nSUBSYSTEM==\"usb\",ATTRS{idVendor}==\"18d1\",GROUP=\"edgetpu\"\n```\nTo get access to the hardware, one then needs to add your Linux user to the `edgetpu` group.\n(This is the `GROUP=` field in the udev rules; you can name this group differently if you want.)\nDo not forget to re-login after updating your Linux user.\n\nNote that while this may also work for other Coral EdgeTPU hardware, you may need to consult the vendor of your specific hardware for details on the device IDs.\n\nA symptom that these udev rules are not set up correctly is getting `ERROR: Failed to retrieve TPU context.`; when `strace`ing the executable, one then sees that you're getting \"Permission denied\" errors when accessing the USB device.\n\n\n## Compiling using Cabal\n\n```sh\nmake setup  # see 'make help' for what this does; note, can take hours as this also builds a full copy of Tensorflow\n\nENV=\"$PWD/extra-deps/tensorflow-haskell/third_party/tensorflow/bazel-bin/tensorflow:$PWD/extra-deps/libedgetpu/out/throttled/k8:$PWD/build:$(echo \"$PWD/build/_deps/abseil-cpp-build/absl/\"{flags,hash,container,strings} | sed 's/ /:/g')\"\n\nenv LD_LIBRARY_PATH=\"$ENV\" cabal build all\n\n# To run tests:\nenv LD_LIBRARY_PATH=\"$ENV\" cabal run nofib-tensorflow-lite\n# Without cabal:\nenv LD_LIBRARY_PATH=\"$ENV\" accelerate_tensorflow_lite_datadir=\"$PWD/accelerate-tensorflow-lite\" \"$(cabal list-bin nofib-tensorflow-lite)\"\n```\n\nA shorthand for the `env LD_LIBRARY_PATH=\"...\"` prefix is [`./in-env.sh`](in-env.sh).\n\nThe version of TensorFlow being used is that in the submodule contained within the `tensorflow-haskell` submodule.\nThis is TensorFlow version 2.10.1.\nBoth repositories have some patches applied at the time of writing, and are hence forks of upstream.\n\n\n## Usage example\n\nFor an example of how to use both backends defined in this repository, see [accelerate-tensorflow-lite/test/examples/Main.hs](accelerate-tensorflow-lite/test/examples/Main.hs).\n\n\n## Further documentation\n\nSome further documentation on the implementation of the backends can be found in the [doc](doc) directory.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Facceleratehs%2Faccelerate-tensorflow","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Facceleratehs%2Faccelerate-tensorflow","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Facceleratehs%2Faccelerate-tensorflow/lists"}