STT-tensorflow/tensorflow/go
A. Unique TensorFlower 072acdaafe Go: Update generated wrapper functions for TensorFlow ops.
PiperOrigin-RevId: 338389609
Change-Id: Icbc47e777e2b99f5f6ee5bcbe82572da288f589e
2020-10-21 20:18:42 -07:00
..
genop Fix syntax error in bash script. 2020-09-21 15:18:18 -07:00
op Go: Update generated wrapper functions for TensorFlow ops. 2020-10-21 20:18:42 -07:00
android.go
attrs_test.go
attrs.go
BUILD
context_test.go
context.go
doc.go
example_inception_inference_test.go
graph_test.go go: Add input mapping option when importing Graph 2020-05-01 11:12:54 -05:00
graph.go Merge pull request #42413 from bioothod:export_golang_functions_master 2020-08-21 19:53:18 -07:00
lib.go
operation_test.go
operation.go
README.md
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 Avoid memory 'leak' in Go with multple inputs 2020-06-24 15:52:58 +01:00
session.go Avoid memory 'leak' in Go with multple inputs 2020-06-24 15:52:58 +01:00
shape_test.go
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
tensor_handle.go
tensor_test.go PR #39117: trying again: Big performance gains for Go NewTensor and Value 2020-06-24 10:08:51 -07:00
tensor.go Fixed spelling 2020-08-17 11:21:52 +01:00
test.sh
util_test.go
version.go

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.