You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We are considering reusing the TensorProto message defined in TensorFlow. This requires us to be able to build TensorFlow's .proto files into Go source code. This guide explains how to do this.
Install Protobuf Tools
To convert .proto files into .go and .py files, we need protoc, the protobuf compilers, and its Go code generator.
The generated Go source files are in the directory $GOPATH/src/github.com/tensorflow/tensorflow/tensorflow/go/core/framework/, because of in all these .proto files, TensorFlow authors put lines like the following:
Let us create an example project in $GOPATH/src/github.com/wangkuiyi/aaa or anywhere in the $GOPATH/src directory, and put in there the following Go source file a.go.
package main
import (
"fmt""github.com/tensorflow/tensorflow/tensorflow/go/core/framework/tensor_shape_go_proto"
)
funcmain() {
vara tensor_shape_go_proto.TensorShapeProtofmt.Println(a.GetDim())
}
We can now install dependencies and build this program.
cd$GOPATH/src/github.com/wangkuiyi/aaa
go get ./...
go install
$GOPATH/bin/aaa
The text was updated successfully, but these errors were encountered:
We are considering reusing the TensorProto message defined in TensorFlow. This requires us to be able to build TensorFlow's .proto files into Go source code. This guide explains how to do this.
Install Protobuf Tools
To convert .proto files into .go and .py files, we need protoc, the protobuf compilers, and its Go code generator.
To install protoc, we can use this shell script https://github.com/sql-machine-learning/sqlflow/blob/develop/scripts/docker/install-protobuf.bash.
To install Go plugin, we can take this script as a reference and run the following command:
Compile Protobuf Messages
We can check out the TensorFlow source tree to any local directory, say,
/tmp/tensorflow
, by running the following command:Make sure that we set the environment variable
$GOPATH
, say,~/go
.To compiler all .proto files, which reside in
tensorflow/core/framework
, please type the following command.The generated Go source files are in the directory
$GOPATH/src/github.com/tensorflow/tensorflow/tensorflow/go/core/framework/
, because of in all these .proto files, TensorFlow authors put lines like the following:Use the Protobuf Messages in Go Code
Let us create an example project in
$GOPATH/src/github.com/wangkuiyi/aaa
or anywhere in the$GOPATH/src
directory, and put in there the following Go source filea.go
.We can now install dependencies and build this program.
The text was updated successfully, but these errors were encountered: