Arbitrary precision integers in TensorFlow.
Project description
TF Big
TF Big adds big number support to TensorFlow, allowing computations to be performed on arbitrary precision integers. Internally these are represented as variant tensors of GMP values, and exposed in Python through the tf_big.Tensor
wrapper for convenience. For importing and exporting, numbers are typically expressed as strings.
Usage
import tensorflow as tf
import tf_big
# load large values as strings
x = tf_big.constant(["100000000000000000000", "200000000000000000000"])
# load ordinary TensorFlow tensors
y = tf_big.convert_to_tensor(tf.constant([3, 4]))
# perform computation as usual
z = x * y
# use TensorFlow sessions to evalutate the results
with tf.Session() as sess:
res = sess.run(z)
print(res)
Installation
Python 3 packages are available from PyPI:
pip install tf-big
See below for further instructions for setting up a development environment.
Development
Requirements
We recommend using Miniconda or Anaconda to set up and use a Python 3.5 or 3.6 environment for all instructions below:
conda create -n tfbig-dev python=3.6
source activate tfbig-dev
Ubuntu
The only requirement for Ubuntu is to have docker installed. This is the recommended way to build custom operations for TensorFlow. We provide a custom development container for TF Big with all dependencies already installed.
macOS
Setting up a development environment on macOS is a little more involved since we cannot use a docker container. We need four things:
- Python (>= 3.5)
- Bazel (>= 0.15.0)
- GMP (>= 6.1.2)
- TensorFlow (== 1.13.1)
Using Homebrew we first make sure that both Bazel and GMP are installed:
brew tap bazelbuild/tap
brew install bazelbuild/tap/bazel
brew install gmp
brew install mmv
The remaining PyPI packages can then be installed using:
pip install -r requirements-dev.txt
Testing
Ubuntu
Run the tests on Ubuntu by running the make test
command inside of a docker container. Right now, the docker container doesn't exist on docker hub yet so we must first build it:
docker build -t tf-encrypted/tf-big:0.1.0 .
Then we can run make test
:
sudo docker run -it \
-v `pwd`:/opt/my-project -w /opt/my-project \
tf-encrypted/tf-big:0.1.0 /bin/bash -c "make test"
macOS
Once the development environment is set up we can simply run:
make test
This will install TensorFlow if not previously installed and build and run the tests.
Building pip package
CircleCI currently builds the pip packages for us. If you have a need to do it on your own you can just run make build
. For linux, doing it inside the tensorflow/tensorflow:custom-op container is recommended.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Hashes for tf_big-0.1.3-cp36-cp36m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e6e57e362565b4b0a2798a7f2bd650426e98b01c4220faa5c04b0112e147a338 |
|
MD5 | 376e6474434db423196cf86122dfa062 |
|
BLAKE2b-256 | 23e551b3120b356c4a9a85128b688fef0499c20dea108b09f8ea816686d3cc0e |
Hashes for tf_big-0.1.3-cp36-cp36m-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2192054a4b147a9dbc1a4ad28901c9a4f2227b28e96507c4e6fa672bc464c2d9 |
|
MD5 | 8b5357c5377e17f8b658d205da83779a |
|
BLAKE2b-256 | f4003214fdf02eebd634642efd7105226d64a9c6a4a2fac3238a78e5a5c762ba |
Hashes for tf_big-0.1.3-cp35-cp35m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0751b0f24dafab5eb95c61b607b8d20ab8e15e069082f36de7ce10a6324f1059 |
|
MD5 | 3d12442ae60a2a285f3162afa163fb73 |
|
BLAKE2b-256 | 9d22b8730dcba48b336438a6456cef3f2faba250247842045707640b7fb40da3 |