{"id":14958712,"url":"https://github.com/tensorflow/ngraph-bridge","last_synced_at":"2025-10-23T17:37:03.959Z","repository":{"id":54371202,"uuid":"171723172","full_name":"tensorflow/ngraph-bridge","owner":"tensorflow","description":"TensorFlow-nGraph bridge","archived":false,"fork":false,"pushed_at":"2021-02-25T19:48:22.000Z","size":5987,"stargazers_count":136,"open_issues_count":36,"forks_count":64,"subscribers_count":13,"default_branch":"master","last_synced_at":"2025-03-30T11:09:00.102Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tensorflow.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-02-20T17:59:47.000Z","updated_at":"2025-02-10T05:44:27.000Z","dependencies_parsed_at":"2022-08-13T13:40:38.642Z","dependency_job_id":null,"html_url":"https://github.com/tensorflow/ngraph-bridge","commit_stats":null,"previous_names":[],"tags_count":78,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tensorflow%2Fngraph-bridge","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tensorflow%2Fngraph-bridge/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tensorflow%2Fngraph-bridge/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tensorflow%2Fngraph-bridge/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tensorflow","download_url":"https://codeload.github.com/tensorflow/ngraph-bridge/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247478324,"owners_count":20945266,"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","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-09-24T13:18:02.324Z","updated_at":"2025-10-23T17:37:03.880Z","avatar_url":"https://github.com/tensorflow.png","language":"C++","readme":"\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"images/ngraph-logo.png\"\u003e\n\u003c/p\u003e\n\n# Intel® nGraph™ Compiler and Runtime for TensorFlow*\n\nThis repository contains the code needed to enable Intel(R) nGraph(TM) Compiler and \nruntime engine for TensorFlow. Use it to speed up your TensorFlow training and \ninference workloads. The nGraph Library and runtime suite can also be used to \ncustomize and deploy Deep Learning inference models that will \"just work\" with \na variety of nGraph-enabled backends: CPU, and custom silicon like the \n[Intel(R) Nervana(TM) NNP](https://itpeernetwork.intel.com/inteldcisummit-artificial-intelligence/).\n\n[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://github.com/tensorflow/ngraph-bridge/blob/master/LICENSE)\n[![Build Status](https://badge.buildkite.com/180bbf814f1a884219849b4838cbda5fa1e03715e494185be3.svg?branch=master)](https://buildkite.com/ngraph/cpu)\n[![Build Status](https://badge.buildkite.com/ae8d39ef4a18eb238b58ab0637fb97e85b86e85822a08b96d1.svg?branch=master)](https://buildkite.com/ngraph/models-cpu)\n[![Build Status](https://badge.buildkite.com/0aeaff43e378d387a160d30083f203f7147f010e3fb15b01d1.svg?branch=master)](https://buildkite.com/ngraph/cpu-intel-tf)\n\n\n#### *** This repository is currently undergoing heavy refactoring for optimization of inference use-cases. If you are looking for the latest stable baseline, please use the following tag: [v0.22.0-rc4](https://github.com/tensorflow/ngraph-bridge/tree/v0.22.0-rc4) ***\n\n## Installation\n\n### Requirements\n\n|Using pre-built packages| Building from source|\n| -----------------------|-------------------|\n|Python 3| Python 3|\n|TensorFlow v2.2.0|GCC 7.5 (Ubuntu), Clang/LLVM (macOS)|\n|        |`cmake` 3.4 or higher|\n|        |Bazelisk|\n|        |`virtualenv` 16.0.0+|\n|        |`patchelf`|\n\n### Use pre-built packages\n\n nGraph bridge enables you to use the nGraph Library with TensorFlow.\n Complete the following steps to install a pre-built nGraph bridge for\n TensorFlow.\n\n1. Ensure the following pip version is being used:\n\n        pip install --upgrade pip==19.3.1\n\n2. Install TensorFlow:\n\n        pip install -U tensorflow==1.14.0\n\n3. Install `ngraph-tensorflow-bridge`:\n\n        pip install -U ngraph-tensorflow-bridge\n\n### Build nGraph from source\n\nTo use the latest version of nGraph Library, complete the following steps to\nbuild nGraph bridge from source. \n\n#### Note to macOS users\n\nThe build and installation instructions are identical for Ubuntu 16.04 and\nmacOS. However, the Python setup may vary across different versions of Mac OS.\nTensorFlow build instructions recommend using Homebrew but developers often use\nPyenv. Some users prefer Anaconda/Miniconda. Before building nGraph, ensure that\nyou can successfully build TensorFlow on macOS with a suitable Python\nenvironment.\n\nThe requirements for building nGraph bridge are identical to the requirements for \nbuilding TensorFlow from source. For more information, review the [TensorFlow configuration] \ndetails. \n\n##### Prepare your build environment\n\nInstall the following requirements before building the `ngraph-bridge`. \n\nInstall [Bazelisk](https://github.com/bazelbuild/bazelisk):\n\n        wget https://github.com/bazelbuild/bazelisk/releases/download/v1.7.4/bazelisk-linux-amd64\n        mv bazelisk-linux-amd64 ~/bin/bazel\n        chmod +x ~/bin/bazel\n\nAdd and source the `bin` path to your `~/.bashrc` file to call\nbazel:\n\n        export PATH=$PATH:~/bin\n        source ~/.bashrc   \n\nInstall `cmake`, `virtualenv`, and `gcc`.\n\n##### Build nGraph bridge\n\nOnce TensorFlow's dependencies are installed, clone the `ngraph-bridge` repo:\n\n        git clone https://github.com/tensorflow/ngraph-bridge.git\n        cd ngraph-bridge\n\nRun the following Python script to build TensorFlow, nGraph, and the bridge. Use Python 3:\n\n        python3 build_ngtf.py --use_prebuilt_tensorflow\n\nWhen the build finishes, a new `virtualenv` directory is created in `build_cmake/venv-tf-py3`. Build artifacts (i.e., the `ngraph_tensorflow_bridge-\u003cVERSION\u003e-py2.py3-none-manylinux1_x86_64.whl`) are created in the `build_cmake/artifacts` directory. \n\nFor more build options:\n        \n        python3 build_ngtf.py --help\n\nTo use the `ngraph-tensorflow-bridge`, activate the following `virtualenv` to start using nGraph with TensorFlow. \n\n        source build_cmake/venv-tf-py3/bin/activate\n \nAlternatively, you can also install the TensorFlow and nGraph bridge outside of a `virtualenv`. The Python `whl` files are located in the `build_cmake/artifacts/` and `build_cmake/artifacts/tensorflow` directories, respectively.\n\nSelect the help option of `build_ngtf.py` script to learn more about various build options. \n\nVerify that `ngraph-bridge` installed correctly:\n\n    python -c \"import tensorflow as tf; print('TensorFlow version: ',tf.__version__);\\\n                import ngraph_bridge; print(ngraph_bridge.__version__)\"\n\nThis will produce something like this:\n\n        TensorFlow version:  2.2.0\n        nGraph bridge version: b'0.22.0-rc3'\n        nGraph version used for this build: b'0.28.0-rc.1+d2cd873'\n        TensorFlow version used for this build: v2.2.0-0-2b96f3662b\n        CXX11_ABI flag used for this build: 1\n        nGraph bridge built with Grappler: False\n\n\nNote: The version of the ngraph-tensorflow-bridge is not going to be exactly \nthe same as when you build from source. This is due to delay in the source \nrelease and publishing the corresponding Python wheel.\n\nTest the installation:\n\n        python3 test_ngtf.py\n\nThis command runs all C++ and Python unit tests from the `ngraph-bridge` source tree. It also runs various TensorFlow Python tests using nGraph.\n\n### Build and run nGraph in Docker\n\nA shell script and dockerfiles are provided in the [`tools`](/tools) directory for easy setup in a Docker container. \nSee [this README](/tools) if you want to use Docker.\n\n## Classify an image\n\nOnce you have installed nGraph bridge, you can use TensorFlow to train a neural network or run inference using a trained model.\nThe only change required to a script is adding\n\n    import ngraph_bridge\n\nUse `infer_image.py` in the [examples] directory to classify an image.\n\nNote: The script downloads the inceptionV3 model and sample image.\n\n    python examples/infer_image.py\n\nThis will print the following results:\n\n    military uniform 0.8343056\n    mortarboard 0.021869544\n    academic gown 0.010358088\n    pickelhaube 0.008008157\n    bulletproof vest 0.005350913\n\nTo classify your own images, modify the `infer_image.py` file.\n\n#### Measure the time\nnGraph is a Just In Time (JIT) compiler meaning that the TensorFlow computation graph is compiled to nGraph during the first instance of the execution. From the second time onwards, the execution speeds up significantly. \n\nAdd the following Python code to measure the computation time:\n\n```python\n# Warmup\nsess.run(output_operation.outputs[0], {\n        input_operation.outputs[0]: t})\n# Run\nimport time\nstart = time.time()\nresults = sess.run(output_operation.outputs[0], {\n        input_operation.outputs[0]: t\n        })      \nelapsed = time.time() - start\nprint('Time elapsed: %f seconds' % elapsed)\n```\nObserve that the output time runs faster than TensorFlow native (i.e., without nGraph).\n\n#### Add additional backends\n\nYou can substitute the default CPU backend with a different backend. \nUse the following API:\n\n    ngraph_bridge.set_backend('backend_name')\n\nTo determine what backends are available on your system, use the following API:\n\n    ngraph_bridge.list_backends()\n\nMore detailed examples on how to use ngraph_bridge are located in the [examples] directory.\n\n## Debugging \n\nDuring the build, often there are missing configuration steps for building TensorFlow. If you run into build issues, first ensure that you can build TensorFlow. For debugging run time issues, see the instructions provided in the [diagnostics] directory.\n\n## Support\n\nPlease submit your questions, feature requests and bug reports via [GitHub issues].\n\n## How to Contribute\n\nWe welcome community contributions to nGraph. If you have an idea for how to \nimprove it:\n\n* Share your proposal via [GitHub issues].\n* Ensure you can build the product and run all the examples with your patch.\n* In the case of a larger feature, create a test.\n* Submit a [pull request].\n* We will review your contribution and, if any additional fixes or\n  modifications are necessary, may provide feedback to guide you. When\n  accepted, your pull request will be merged to the repository.\n\n\n## About Intel® nGraph™\n\nSee the [full documentation] here.\n\n[TensorFlow]:https://github.com/tensorflow/tensorflow.git\n[Github issues]: https://github.com/tensorflow/ngraph-bridge/issues\n[pull request]: https://github.com/tensorflow/ngraph-bridge/pulls\n[bazel version]: https://github.com/bazelbuild/bazel/releases/tag/0.25.2\n[TensorFlow configuration]: https://www.tensorflow.org/install/source\n[diagnostics]:diagnostics/README.md\n[examples]:examples/README.md\n[nGraph]:https://docs.openvinotoolkit.org/latest/openvino_docs_nGraph_DG_Introduction.html\n[full documentation]:https://docs.openvinotoolkit.org/latest/openvino_docs_nGraph_DG_Introduction.html\n[frozen model]: https://www.tensorflow.org/guide/extend/model_files#freezing\n[TensorFlow C++ and Python Image Recognition Demo]: https://github.com/tensorflow/tensorflow/tree/master/tensorflow/examples/label_image\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftensorflow%2Fngraph-bridge","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftensorflow%2Fngraph-bridge","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftensorflow%2Fngraph-bridge/lists"}