• Home
Name Date Size #Lines LOC

..--

genop/03-May-2024-1,4421,070

op/03-May-2024-40,08819,202

BUILDD03-May-2024782 3630

README.mdD03-May-20243.2 KiB10269

android.goD03-May-2024715 212

attrs.goD03-May-20246.9 KiB247195

attrs_test.goD03-May-20244 KiB194129

context.goD03-May-20243 KiB11062

context_test.goD03-May-20241.3 KiB5838

doc.goD03-May-20241 KiB271

example_inception_inference_test.goD03-May-20249 KiB292196

graph.goD03-May-202413.2 KiB475320

graph_test.goD03-May-20247.5 KiB341292

lib.goD03-May-2024688 222

operation.goD03-May-20246.3 KiB217118

operation_test.goD03-May-20246.2 KiB270223

saved_model.goD03-May-20242.4 KiB7535

saved_model_test.goD03-May-20241 KiB3211

session.goD03-May-202411.8 KiB409267

session_test.goD03-May-20247.9 KiB320244

shape.goD03-May-20242.5 KiB10559

shape_test.goD03-May-20242.1 KiB8664

status.goD03-May-20241.7 KiB6831

tensor.goD03-May-202416 KiB506383

tensor_handle.goD03-May-20245.6 KiB17185

tensor_handle_test.goD03-May-20242.8 KiB12899

tensor_test.goD03-May-20248.3 KiB315260

test.shD03-May-20242.3 KiB7640

util_test.goD03-May-20241.6 KiB6645

version.goD03-May-2024834 263

README.md

1# TensorFlow in Go
2
3Construct and execute TensorFlow graphs in Go.
4
5[![GoDoc](https://godoc.org/github.com/tensorflow/tensorflow/tensorflow/go?status.svg)](https://godoc.org/github.com/tensorflow/tensorflow/tensorflow/go)
6
7> *WARNING*: The API defined in this package is not stable and can change
8> without notice. The same goes for the package path:
9> (`github.com/tensorflow/tensorflow/tensorflow/go`).
10
11## Quickstart
12
13Refer to [Installing TensorFlow for Go](https://www.tensorflow.org/install/lang_go)
14
15## Building the TensorFlow C library from source
16
17If the "Quickstart" instructions above do not work (perhaps the release archives
18are not available for your operating system or architecture, or you're using a
19different version of CUDA/cuDNN), then the TensorFlow C library must be built
20from source.
21
22### Prerequisites
23
24-   [bazel](https://www.bazel.build/versions/master/docs/install.html)
25-   Environment to build TensorFlow from source code
26    ([Linux or macOS](https://www.tensorflow.org/install/source)). If you don't
27    need GPU support, then try the following:
28
29    ```sh
30    sudo apt-get install python swig python-numpy # Linux
31    brew install swig                             # OS X with homebrew
32    ```
33
34### Build
35
361.  Download the source code
37
38    ```sh
39    go get -d github.com/tensorflow/tensorflow/tensorflow/go
40    ```
41
422.  Build the TensorFlow C library:
43
44    ```sh
45    cd ${GOPATH}/src/github.com/tensorflow/tensorflow
46    ./configure
47    bazel build -c opt //tensorflow:libtensorflow.so
48    ```
49
50    This can take a while (tens of minutes, more if also building for GPU).
51
523.  Make `libtensorflow.so` and `libtensorflow_framework.so` available to the
53    linker. This can be done by either:
54
55    a. Copying it to a system location, e.g.,
56
57    ```sh
58    sudo cp ${GOPATH}/src/github.com/tensorflow/tensorflow/bazel-bin/tensorflow/libtensorflow.so /usr/local/lib
59    sudo cp ${GOPATH}/src/github.com/tensorflow/tensorflow/bazel-bin/tensorflow/libtensorflow_framework.so /usr/local/lib
60    ```
61
62    OR
63
64    b. Setting environment variables:
65
66    ```sh
67    export LIBRARY_PATH=${GOPATH}/src/github.com/tensorflow/tensorflow/bazel-bin/tensorflow
68    # Linux
69    export LD_LIBRARY_PATH=${GOPATH}/src/github.com/tensorflow/tensorflow/bazel-bin/tensorflow
70    # OS X
71    export DYLD_LIBRARY_PATH=${GOPATH}/src/github.com/tensorflow/tensorflow/bazel-bin/tensorflow
72    ```
73
744.  Build and test:
75
76    ```sh
77    go test github.com/tensorflow/tensorflow/tensorflow/go
78    ```
79
80### Generate wrapper functions for ops
81
82Go functions corresponding to TensorFlow operations are generated in `op/wrappers.go`. To regenerate them:
83
84Prerequisites:
85- [Protocol buffer compiler (protoc) 3.x](https://github.com/google/protobuf/releases/)
86- The TensorFlow repository under GOPATH
87
88```sh
89go generate github.com/tensorflow/tensorflow/tensorflow/go/op
90```
91
92## Support
93
94Use [stackoverflow](http://stackoverflow.com/questions/tagged/tensorflow) and/or
95[Github issues](https://github.com/tensorflow/tensorflow/issues).
96
97## Contributions
98
99Contributions are welcome. If making any signification changes, probably best to
100discuss on a [Github issue](https://github.com/tensorflow/tensorflow/issues)
101before investing too much time. Github pull requests are used for contributions.
102