Skip to main content

TensorFlow Coder (TF-Coder): A Program Synthesis Tool for TensorFlow

Project description

TensorFlow Coder (TF-Coder)

TF-Coder is a program synthesis tool that helps you write TensorFlow code. First, the tool asks for an input-output example of the desired tensor transformation. Then, it runs a combinatorial search to find TensorFlow expressions that perform that transformation. TF-Coder’s output is real TensorFlow code that you can include in your projects.

Quick Links

Try TF-Coder!

The TF-Coder tool is ready-to-use at this link. Everything is already packaged together in a Colab notebook, so no installation or download is needed.

For more information about TF-Coder, see the following documents:

  • TF-Coder Tutorial: walks you through using TF-Coder to solve tensor manipulation tasks, and provides tips on getting the most out of TF-Coder.
  • User Journeys: illustrates several realistic scenarios where TF-Coder can help accelerate your TensorFlow development in different ways.

Contents

What is TF-Coder?

When manipulating tensors, one must keep track of multiple dimensions, tensor shape and DType compatibility, and of course mathematical correctness. Additionally, there are hundreds of TensorFlow operations, and finding the right ones to use can be a challenge.

TensorFlow Coder, or TF-Coder, can help you write tricky tensor manipulations in TensorFlow. Instead of coding your tensor manipulation directly, you can just demonstrate it through an illustrative input-output example, and TF-Coder can produce the corresponding code automatically. TF-Coder performs an efficient combinatorial search over compositions of TensorFlow operations, until it finds a TensorFlow expression that matches the given input-output example.

TF-Coder allows you to:

  • Program in TensorFlow by example
  • Find the right function to use
  • Automatically combine functions in clever ways
  • Spend less time debugging

TF-Coder is primarily a development tool for TensorFlow users. If you just want to use TF-Coder as a tool, you don’t need to install anything, as the tool is ready-to-use in this Colab notebook.

Caveats

There are limitations to TF-Coder. It can currently find solutions involving 3-4 operations within a minute of searching, but solutions involving 6 or more operations are too complex to find in a reasonable amount of time. Furthermore, TF-Coder currently does not support complex or string tensors, or RaggedTensors. The full list of supported operations can be found in the Colab notebook.

In addition, TF-Coder only guarantees that its solutions work for the given input-output example. The tool searches for a simple TensorFlow expression that matches the provided input-output example, but sometimes this solution is too simple and doesn’t generalize in the intended way. It can be helpful to make the example as unambiguous as possible, which can often be achieved by adding more numbers to the input and output tensors. Please review TF-Coder’s solutions to ensure that they correctly implement the intended behavior.

In the Colab tool, we would like to log the problems given to TF-Coder and the resulting solutions, so that we can improve the tool and build a dataset that will accelerate program synthesis research in general, but this data collection is completely optional.

Tutorial and Further Reading

For more information about TF-Coder, see the following documents:

  • TF-Coder Tutorial: walks you through using TF-Coder to solve tensor manipulation tasks, and provides tips on getting the most out of TF-Coder.
  • User Journeys: illustrates several realistic scenarios where TF-Coder can help accelerate your TensorFlow development in different ways.
  • Our research paper: describes the technology behind TF-Coder.

Optional: Using TF-Coder Outside Colab

Because TF-Coder is primarily a development tool and not a library that you use in your code, we hope that the provided Colab notebook is sufficient for your use cases.

However, if you would rather not use the Colab notebook, you can still install TF-Coder as a Python package yourself:

pip install --user tf-coder

To run the TF-Coder search as a library, follow the code example in tf_coder_main.py.

To run TF-Coder on our benchmarks, run:

python3 tf_coder/value_search/value_search_main.py

To run tests, clone the repository and run pytest.

Citation

If you find TF-Coder helpful for a research project, you may cite our research paper as follows:

@article{TFCoder,
    title={{TF-Coder}: Program Synthesis for Tensor Manipulations},
    author={Kensen Shi and David Bieber and Rishabh Singh},
    year={2020},
    url={https://arxiv.org/abs/2003.09040},
    archivePrefix={arXiv},
    eprint={2003.09040}
}

Disclaimer

This is a research project, not an official Google product.

To report a bug or make a feature request, please raise a GitHub issue.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tensorflow-coder-0.0.5.tar.gz (121.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tensorflow_coder-0.0.5-py3-none-any.whl (32.3 MB view details)

Uploaded Python 3

File details

Details for the file tensorflow-coder-0.0.5.tar.gz.

File metadata

  • Download URL: tensorflow-coder-0.0.5.tar.gz
  • Upload date:
  • Size: 121.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.9

File hashes

Hashes for tensorflow-coder-0.0.5.tar.gz
Algorithm Hash digest
SHA256 2f34f3bcee4dcd52076fc74b0fa5ae0ca5c0b5c824e86b20634b47e75df73eff
MD5 66eb924a15f13b986142c37ae7f215b9
BLAKE2b-256 039bde699b4800ec6b796ec28111756613099c76f28b7764ba29d56bd7b46365

See more details on using hashes here.

File details

Details for the file tensorflow_coder-0.0.5-py3-none-any.whl.

File metadata

  • Download URL: tensorflow_coder-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 32.3 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.9

File hashes

Hashes for tensorflow_coder-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 97c29d29ad7cbabd7a1089c94a1653c3e383f2f833d8494e835b2e358fb6e7e0
MD5 be9872f2310f85f29f4a2629e3498455
BLAKE2b-256 8550a27451057b776b433107d7355c11568d6f9ab1d35ba8bbe00926edec661e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page