-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit a28bb02
Showing
106 changed files
with
83,990 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Tensorflow Go Bindings | ||
This is a fork of tensorflow's repository (at version 2.3.1) with pre-generated protobuf definitions. | ||
|
||
Specificially, this uses protobufs generated with protoc-gen-go v1.3.5 (before the api refactor) | ||
|
||
# Matching libs | ||
| TensorFlow | C library | URL | | ||
| ---------- | --------- | --- | | ||
| Linux || | | ||
| Linux | CPU only | https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-cpu-linux-x86_64-2.3.1.tar.gz | | ||
| Linux | GPU support | https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-gpu-linux-x86_64-2.3.1.tar.gz | | ||
| macOS || | | ||
| macOS | CPU only | https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-cpu-darwin-x86_64-2.3.1.tar.gz | | ||
| Windows || | | ||
| Windows | CPU only | https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-cpu-windows-x86_64-2.3.1.zip | | ||
| Windows | GPU only | https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-gpu-windows-x86_64-2.3.1.zip | | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module github.com/tensorflow/tensorflow | ||
|
||
go 1.14 | ||
|
||
require github.com/golang/protobuf v1.3.3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
github.com/golang/protobuf v1.3.3 h1:gyjaxf+svBWX08ZjK86iN9geUJF0H6gp2IRKX6Nf6/I= | ||
github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Description: | ||
# Go API for TensorFlow. | ||
|
||
package( | ||
default_visibility = ["//visibility:private"], | ||
) | ||
|
||
licenses(["notice"]) # Apache 2.0 | ||
|
||
exports_files(["LICENSE"]) | ||
|
||
load( | ||
"//tensorflow:tensorflow.bzl", | ||
"tf_shared_library_deps", | ||
) | ||
|
||
sh_test( | ||
name = "test", | ||
size = "small", | ||
srcs = ["test.sh"], | ||
data = [ | ||
":all_files", # Go sources | ||
"//tensorflow/c:headers", # C library header | ||
"//tensorflow/c/eager:headers", # Eager C library header | ||
"//tensorflow/cc/saved_model:saved_model_half_plus_two", # Testdata for LoadSavedModel | ||
] + tf_shared_library_deps(), | ||
# TODO: Enable this test again once protos are supported by bazel. | ||
tags = ["manual"], | ||
) | ||
|
||
filegroup( | ||
name = "all_files", | ||
srcs = glob( | ||
["**/*"], | ||
exclude = [ | ||
"**/METADATA", | ||
"**/OWNERS", | ||
], | ||
), | ||
visibility = ["//tensorflow:__subpackages__"], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
# TensorFlow in Go | ||
|
||
Construct and execute TensorFlow graphs in Go. | ||
|
||
[![GoDoc](https://godoc.org/github.com/tensorflow/tensorflow/tensorflow/go?status.svg)](https://godoc.org/github.com/tensorflow/tensorflow/tensorflow/go) | ||
|
||
> *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](https://www.tensorflow.org/install/lang_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 | ||
|
||
- [bazel](https://www.bazel.build/versions/master/docs/install.html) | ||
- Environment to build TensorFlow from source code | ||
([Linux or macOS](https://www.tensorflow.org/install/source)). If you don't | ||
need GPU support, then try the following: | ||
|
||
```sh | ||
sudo apt-get install python swig python-numpy # Linux | ||
brew install swig # OS X with homebrew | ||
``` | ||
- [Protocol buffer compiler (protoc) 3.x](https://github.com/google/protobuf/releases/) | ||
|
||
### Build | ||
|
||
1. Download the source code | ||
|
||
```sh | ||
go get -d github.com/tensorflow/tensorflow/tensorflow/go | ||
``` | ||
|
||
2. Build the TensorFlow C library: | ||
|
||
```sh | ||
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., | ||
|
||
```sh | ||
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: | ||
|
||
```sh | ||
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: | ||
|
||
```sh | ||
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: | ||
- [Protocol buffer compiler (protoc) 3.x](https://github.com/google/protobuf/releases/) | ||
- The TensorFlow repository under GOPATH | ||
|
||
```sh | ||
go generate github.com/tensorflow/tensorflow/tensorflow/go/op | ||
``` | ||
|
||
## Support | ||
|
||
Use [stackoverflow](http://stackoverflow.com/questions/tagged/tensorflow) and/or | ||
[Github issues](https://github.com/tensorflow/tensorflow/issues). | ||
|
||
## Contributions | ||
|
||
Contributions are welcome. If making any signification changes, probably best to | ||
discuss on a [Github issue](https://github.com/tensorflow/tensorflow/issues) | ||
before investing too much time. Github pull requests are used for contributions. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// Copyright 2016 The TensorFlow Authors. All Rights Reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
// +build android | ||
|
||
package tensorflow | ||
|
||
// #cgo LDFLAGS: -landroid -llog -lm -lz -ldl | ||
import "C" |
Oops, something went wrong.