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.import_tensor(tf.constant([[3, 4]]))
# perform computation as usual
z = x * y
# export result back into a TensorFlow tensor
tf_res = tf_big.export_tensor(z)
print(tf_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 (see setup.py for version requirements for your TF Big version)
Using Homebrew we first make sure that both Bazel and GMP are installed. We recommend using a Bazel version earlier than 1.0.0, e.g.:
brew tap bazelbuild/tap
brew extract bazel bazelbuild/tap --version 0.26.1
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:build .
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
Just run:
make build && make bundle
For linux, doing it inside the tensorflow/tensorflow:custom-op container is recommended. Note that CircleCI is currently used to build the official pip packages.
Circle CI
We use Circle CI for integration testing and deployment of TF Big.
Releasing
- update version number in setup.py and push to master; this will build and tests wheels
- iterate 1. until happy with the release, having potentially tested the wheel manually
- when happy, tag a commit with semver label and push; this will build, test, and deploy wheels
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 Distribution
File details
Details for the file tf_big-0.2.1-cp37-cp37m-macosx_10_15_x86_64.whl
.
File metadata
- Download URL: tf_big-0.2.1-cp37-cp37m-macosx_10_15_x86_64.whl
- Upload date:
- Size: 196.0 kB
- Tags: CPython 3.7m, macOS 10.15+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.7.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 262e40cea091a59a17efe0cf6a48cff5a0304d0d27c5f72202f9faf996e7b09f |
|
MD5 | f21db4de60db41062a43fad9365f87a6 |
|
BLAKE2b-256 | 941ce104d187d80a2de942eb97e0124c32a09ca3ed0becd3cac8a44177547573 |