STT-tensorflow/tensorflow/go
A. Unique TensorFlower 23fc134a17 Go: Update generated wrapper functions for TensorFlow ops.
PiperOrigin-RevId: 317755766
Change-Id: I105b220b0760792d9f4fa7c1390c1477cdb1c627
2020-06-22 17:12:33 -07:00
..
genop Use CompactTextString instead of String for generating ops. 2020-05-14 19:48:45 -07:00
op Go: Update generated wrapper functions for TensorFlow ops. 2020-06-22 17:12:33 -07:00
android.go
attrs_test.go Merge changes from github. 2018-06-28 19:16:41 -07:00
attrs.go use smaller slice length for 32-bit arch 2019-01-10 14:49:47 -08:00
BUILD Add SignatureDefs to Go SavedModel API. 2019-11-22 11:52:37 -08:00
context_test.go Add Go wrapper around Eager C API's Context. 2018-12-17 10:49:30 -08:00
context.go Add Go wrapper around Eager C API's Context. 2018-12-17 10:49:30 -08:00
doc.go Update doc.go 2019-05-22 14:46:47 -07:00
example_inception_inference_test.go Fix several issues with go fmt and go lint 2017-09-24 15:32:45 +00:00
graph_test.go Fix gradients test in golang 2018-09-12 11:40:15 +08:00
graph.go Check nil returned 2019-10-24 13:06:50 +09:00
lib.go
operation_test.go [Go]: Support device annotations when constructing graphs. 2018-07-11 18:21:08 -07:00
operation.go [Go]: Support device annotations when constructing graphs. 2018-07-11 18:21:08 -07:00
README.md Add SignatureDefs to Go SavedModel API. 2019-11-22 11:52:37 -08:00
saved_model_test.go Go: fix handling empty tags-set for loading saved model 2020-03-10 01:07:31 +00:00
saved_model.go [BUILD] Create a separate BUILD file for "tensorflow/core/protobuf"`. 2020-05-12 13:51:52 -07:00
session_test.go Automated rollback of commit 0bc46a1602. Revert #26682. 2019-03-18 18:13:21 -07:00
session.go Automated rollback of commit 0bc46a1602. Revert #26682. 2019-03-18 18:13:21 -07:00
shape_test.go differentiate package description and license 2017-03-27 14:17:22 +08:00
shape.go
signature_test.go [BUILD] Create a separate BUILD file for "tensorflow/core/protobuf"`. 2020-05-12 13:51:52 -07:00
signature.go [BUILD] Create a separate BUILD file for "tensorflow/core/protobuf"`. 2020-05-12 13:51:52 -07:00
status.go
tensor_handle_test.go Add Go wrapper around Eager C API's TensorHandle. 2018-12-17 11:00:00 -08:00
tensor_handle.go [Go]: Allow code in the "master" branch to work against the latest C library 2019-01-11 03:09:13 -08:00
tensor_test.go Rollback due to internal failure. 2020-03-12 13:12:14 -07:00
tensor.go Rollback due to internal failure. 2020-03-12 13:12:14 -07:00
test.sh Force overriding a symbolic link for Go testing, 2019-05-22 14:46:39 -07:00
util_test.go
version.go differentiate package description and license 2017-03-27 14:17:22 +08:00

TensorFlow in Go

Construct and execute TensorFlow graphs in Go.

GoDoc

Warning

: The API defined in this package is not stable and can change without notice. The same goes for the package path: (github.com/tensorflow/tensorflow/tensorflow/go).

Quickstart

Refer to Installing TensorFlow for Go

Building the TensorFlow C library from source

If the "Quickstart" instructions above do not work (perhaps the release archives are not available for your operating system or architecture, or you're using a different version of CUDA/cuDNN), then the TensorFlow C library must be built from source.

Prerequisites

Build

  1. Download the source code

    go get -d github.com/tensorflow/tensorflow/tensorflow/go
    
  2. Build the TensorFlow C library:

    cd ${GOPATH}/src/github.com/tensorflow/tensorflow
    ./configure
    bazel build -c opt //tensorflow:libtensorflow.so
    

    This can take a while (tens of minutes, more if also building for GPU).

  3. Make libtensorflow.so and libtensorflow_framework.so available to the linker. This can be done by either:

    a. Copying it to a system location, e.g.,

    sudo cp ${GOPATH}/src/github.com/tensorflow/tensorflow/bazel-bin/tensorflow/libtensorflow.so /usr/local/lib
    sudo cp ${GOPATH}/src/github.com/tensorflow/tensorflow/bazel-bin/tensorflow/libtensorflow_framework.so /usr/local/lib
    

    OR

    b. Setting environment variables:

    export LIBRARY_PATH=${GOPATH}/src/github.com/tensorflow/tensorflow/bazel-bin/tensorflow
    # Linux
    export LD_LIBRARY_PATH=${GOPATH}/src/github.com/tensorflow/tensorflow/bazel-bin/tensorflow
    # OS X
    export DYLD_LIBRARY_PATH=${GOPATH}/src/github.com/tensorflow/tensorflow/bazel-bin/tensorflow
    
  4. Build and test:

    go generate github.com/tensorflow/tensorflow/tensorflow/go/op
    go test github.com/tensorflow/tensorflow/tensorflow/go
    

Generate wrapper functions for ops

Go functions corresponding to TensorFlow operations are generated in op/wrappers.go. To regenerate them:

Prerequisites:

go generate github.com/tensorflow/tensorflow/tensorflow/go/op

Support

Use stackoverflow and/or Github issues.

Contributions

Contributions are welcome. If making any signification changes, probably best to discuss on a Github issue before investing too much time. Github pull requests are used for contributions.