Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ Invoke `./gradle.sh` instead of `gradle` to build artifacts using the docker.

## known issues

* *Java, Node, Mono, Rust, Go* are excluded from `./gradle.sh buildAll`
* *Rust* is excluded from `./gradle.sh buildAll`
8 changes: 4 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ task buildAll {
dependsOn "cmake"
dependsOn "wheel"
// dependsOn "rust"
// dependsOn "java"
// dependsOn "node"
// dependsOn "mono"
// dependsOn "golang"
dependsOn "java"
dependsOn "node"
dependsOn "mono"
dependsOn "golang"
}

apply from: "gradle/ossrh.gradle"
Expand Down
120 changes: 17 additions & 103 deletions gradle/golang.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ task installProtocGenGo(type: Exec) {

task generateProtoGo {
dependsOn "installProtocGenGo"
finalizedBy "finalizeProtoGo"
ext {
source = "${protoGenMainDir}/go"
}
Expand All @@ -34,121 +33,36 @@ task generateProtoGo {
standardOutput file("${source}/go.mod").newOutputStream()
commandLine "envsubst"
}
}
}

static def commonsOfPath(global, String... dirs) {
def commons = null
dirs.each { dir ->
def path = [].toSet()
global.fileTree(dir){ include "**" }.visit { fd ->
if (fd.file.file) return
path.add(fd.path)
}
if (commons == null) {
commons = path
} else {
commons.retainAll(path)
file(source).eachDir { fd ->
file("${source}/go.mod").append("\nreplace ${fd.name} => ./${fd.name}")
var mod = file("${fd.path}/go.mod")
if (!mod.exists()) {
println("generate mod: ${fd.name}/go.mod")
mod.write("module ${fd.name}\n\ngo 1.12")
}
}
}
if (commons == null) commons = [].toSet()
return commons
}

task finalizeProtoGo {
task golang {
dependsOn "generateProto"
dependsOn "generateProtoGo"
ext {
source = generateProtoGo.source
rot = "github.com"
sat = "${rot}/tensorflow/tensorflow/tensorflow/go"
ome = "tensorflow"
output = "${buildDir}/go"
}
onlyIf {
file("${source}/${rot}").exists()
}
inputs.dir generateProtoGo.source
outputs.dir generateProtoGo.source
doLast {
def gnu = new ByteArrayOutputStream()
exec {
ignoreExitValue = true
standardOutput gnu
errorOutput gnu
commandLine "sed", "--version"
}
gnu = gnu.toString().contains("GNU")
def lwb = gnu ? "\\b" : "[[:<:]]"
def rwb = gnu ? "\\b" : "[[:>:]]"
fileTree(source){ include "**/*.go" }.visit { fd ->
if (fd.file.directory) return
exec {
commandLine "sed", "-i.sed", "s@${lwb}${sat}${rwb}@${ome}@g", "${source}/${fd.path}"
}
}
fileTree(source){ include "${sat}/**/*.go" }.visit { fd ->
if (fd.file.directory) return
exec {
commandLine "sed", "-i.sed", "s@^package .*@package ${ome}@g", "${source}/${fd.path}"
}
}
commonsOfPath(project, "${source}/${sat}", "${source}/${ome}").each { dir ->
def pattern = "\"${ome}/${dir}\""
fileTree(source){ include "${sat}/${dir}/*.go", "${ome}/${dir}/*.go" }.visit { fd ->
if (fd.file.directory) return
def name = new ByteArrayOutputStream()
exec {
ignoreExitValue = true
standardOutput name
commandLine "grep", "-o", "\\w* ${pattern}", "${source}/${fd.path}"
}
name = name.toString().trim().tokenize(" ")
if (name[0] == null) return
name = name.size() == 1 ? name[0].tokenize("/")[-1] : name[0]
println("adjust ${name} in ${fd.path}")
exec {
commandLine "sed", "-i.sed", "\\@${pattern}@d", "${source}/${fd.path}"
}
exec {
commandLine "sed", "-i.sed", "s@${lwb}${name}\\.@@g", "${source}/${fd.path}"
}
}
}
copy {
from "${source}/${sat}"
include "**/*.go"
into "${source}/${ome}"
}
delete {
delete "${source}/${rot}"
delete fileTree(source){ include "**/*.sed" }
}
fileTree(source){ include "*" }.visit { fd ->
if (fd.file.file) return
copy {
from "${source}/go.mod"
into "${source}/${fd.path}"
filter { line ->
line.startsWith("module") ? "module ${fd.path}" : line
}
}
println("generate mod: ${fd.path}/go.mod")
file("${source}/go.mod").append("\nreplace ${fd.path} => ./${fd.path}\n")
workingDir generateProtoGo.source
commandLine "go", "mod", "tidy"
}
exec {
commandLine "ln", "-nfs", buildDir.relativePath(new File(source)), output
workingDir generateProtoGo.source
commandLine "go", "build", "-v", "-pkgdir", generateProtoGo.source
args(dist.build == "release" ? ["-ldflags", "-s -w"] : [])
args("./...")
}
}
}

task golang(type: Exec) {
dependsOn "generateProtoGo"
inputs.dir generateProtoGo.source
outputs.dir generateProtoGo.source
workingDir generateProtoGo.source
commandLine "go", "build", "-v"
args(dist.build == "release" ? ["-ldflags", "-s -w"] : [])
args("./...")
}

task __golang__ {
dependsOn "golang"
ext {
Expand Down
20 changes: 0 additions & 20 deletions gradle/grpc.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ protobuf {
outputSubDir = "csharp"
}
}
all()["generateProto"].finalizedBy "finalizeProtoGrpc"
}
}

Expand All @@ -60,22 +59,3 @@ ext {
protoGenMainRel = file(projectDir).toPath().relativize(file(protoGenMainDir).toPath())
protoGenMainSub = file(protoGenBaseDir).toPath().relativize(file(protoGenMainDir).toPath())
}

task finalizeProtoGrpc {
dependsOn "generateProto"
inputs.dir protoGenMainDir
doLast {
delete {
delete fileTree("${protoGenMainDir}/cpp") {
include "**/*.grpc.pb.*"
exclude "**/*_service.grpc.pb.*"
}
}
delete {
delete fileTree("${protoGenMainDir}/python") {
include "**/*_pb2_grpc.py"
exclude "**/*_service_pb2_grpc.py"
}
}
}
}
4 changes: 0 additions & 4 deletions gradle/node.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ task node {
workingDir source
commandLine "npm", "install"
}
exec {
workingDir source
commandLine "npm", "build"
}
exec {
workingDir source
commandLine "npm", "pack"
Expand Down
2 changes: 1 addition & 1 deletion gradle/wheel.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ task __python__ {
doLast {
copy {
from wheel.distEnv.source
include "tensorflow/**", "tensorflow_serving/**"
include "tensorflow/**", "tensorflow_serving/**", "tsl/**"
into src
}
exec {
Expand Down
2 changes: 1 addition & 1 deletion proto/tensorflow/core/example/example.proto
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ option cc_enable_arenas = true;
option java_outer_classname = "ExampleProtos";
option java_multiple_files = true;
option java_package = "org.tensorflow.example";
option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/example";
option go_package = "tensorflow/core/example";

// An Example is a mostly-normalized data format for storing data for
// training and inference. It contains a key-value store (features); where
Expand Down
2 changes: 1 addition & 1 deletion proto/tensorflow/core/example/feature.proto
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ option cc_enable_arenas = true;
option java_outer_classname = "FeatureProtos";
option java_multiple_files = true;
option java_package = "org.tensorflow.example";
option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/example";
option go_package = "tensorflow/core/example";

// LINT.IfChange
// Containers to hold repeated fundamental values.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ option cc_enable_arenas = true;
option java_outer_classname = "AllocationDescriptionProtos";
option java_multiple_files = true;
option java_package = "org.tensorflow.framework";
option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/framework";
option go_package = "tensorflow/core/framework";

message AllocationDescription {
// Total number of bytes requested
Expand Down
2 changes: 1 addition & 1 deletion proto/tensorflow/core/framework/attr_value.proto
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ option cc_enable_arenas = true;
option java_outer_classname = "AttrValueProtos";
option java_multiple_files = true;
option java_package = "org.tensorflow.framework";
option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/framework";
option go_package = "tensorflow/core/framework";

// Protocol buffer representing the value for an attr used to configure an Op.
// Comment indicates the corresponding attr type. Only the field matching the
Expand Down
2 changes: 1 addition & 1 deletion proto/tensorflow/core/framework/cost_graph.proto
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ option cc_enable_arenas = true;
option java_outer_classname = "CostGraphProtos";
option java_multiple_files = true;
option java_package = "org.tensorflow.framework";
option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/framework";
option go_package = "tensorflow/core/framework";

message CostGraphDef {
message Node {
Expand Down
2 changes: 1 addition & 1 deletion proto/tensorflow/core/framework/full_type.proto
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ option cc_enable_arenas = true;
option java_outer_classname = "FullTypeProtos";
option java_multiple_files = true;
option java_package = "org.tensorflow.framework";
option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/framework";
option go_package = "tensorflow/core/framework";

// LINT.IfChange
// Experimental. Represents the complete type information of a TensorFlow value.
Expand Down
2 changes: 1 addition & 1 deletion proto/tensorflow/core/framework/function.proto
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ option cc_enable_arenas = true;
option java_outer_classname = "FunctionProtos";
option java_multiple_files = true;
option java_package = "org.tensorflow.framework";
option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/framework";
option go_package = "tensorflow/core/framework";

// A library is a set of named functions.
message FunctionDefLibrary {
Expand Down
2 changes: 1 addition & 1 deletion proto/tensorflow/core/framework/graph.proto
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ option cc_enable_arenas = true;
option java_outer_classname = "GraphProtos";
option java_multiple_files = true;
option java_package = "org.tensorflow.framework";
option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/framework";
option go_package = "tensorflow/core/framework";

// Represents the graph of operations
message GraphDef {
Expand Down
2 changes: 1 addition & 1 deletion proto/tensorflow/core/framework/graph_debug_info.proto
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ option cc_enable_arenas = true;
option java_outer_classname = "GraphDebugInfoProtos";
option java_multiple_files = true;
option java_package = "org.tensorflow.framework";
option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/protobuf";
option go_package = "tensorflow/core/framework";

message GraphDebugInfo {
// This represents a file/line location in the source code.
Expand Down
2 changes: 1 addition & 1 deletion proto/tensorflow/core/framework/node_def.proto
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ option cc_enable_arenas = true;
option java_outer_classname = "NodeProto";
option java_multiple_files = true;
option java_package = "org.tensorflow.framework";
option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/framework";
option go_package = "tensorflow/core/framework";

message NodeDef {
// The name given to this operator. Used for naming inputs,
Expand Down
2 changes: 1 addition & 1 deletion proto/tensorflow/core/framework/op_def.proto
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ option cc_enable_arenas = true;
option java_outer_classname = "OpDefProtos";
option java_multiple_files = true;
option java_package = "org.tensorflow.framework";
option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/framework";
option go_package = "tensorflow/core/framework";

// Defines an operation. A NodeDef in a GraphDef specifies an Op by
// using the "op" field which should match the name of a OpDef.
Expand Down
2 changes: 1 addition & 1 deletion proto/tensorflow/core/framework/resource_handle.proto
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ option cc_enable_arenas = true;
option java_outer_classname = "ResourceHandle";
option java_multiple_files = true;
option java_package = "org.tensorflow.framework";
option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/framework";
option go_package = "tensorflow/core/framework";

// Protocol buffer representing a handle to a tensorflow resource. Handles are
// not valid across executions, but can be serialized back and forth from within
Expand Down
2 changes: 1 addition & 1 deletion proto/tensorflow/core/framework/step_stats.proto
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ option cc_enable_arenas = true;
option java_outer_classname = "StepStatsProtos";
option java_multiple_files = true;
option java_package = "org.tensorflow.framework";
option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/framework";
option go_package = "tensorflow/core/framework";

// An allocation/de-allocation operation performed by the allocator.
message AllocationRecord {
Expand Down
2 changes: 1 addition & 1 deletion proto/tensorflow/core/framework/tensor.proto
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ option cc_enable_arenas = true;
option java_outer_classname = "TensorProtos";
option java_multiple_files = true;
option java_package = "org.tensorflow.framework";
option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/framework";
option go_package = "tensorflow/core/framework";

// Protocol buffer representing a tensor.
message TensorProto {
Expand Down
2 changes: 1 addition & 1 deletion proto/tensorflow/core/framework/tensor_description.proto
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ option cc_enable_arenas = true;
option java_outer_classname = "TensorDescriptionProtos";
option java_multiple_files = true;
option java_package = "org.tensorflow.framework";
option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/framework";
option go_package = "tensorflow/core/framework";

message TensorDescription {
// Data type of tensor elements
Expand Down
2 changes: 1 addition & 1 deletion proto/tensorflow/core/framework/tensor_shape.proto
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ option cc_enable_arenas = true;
option java_outer_classname = "TensorShapeProtos";
option java_multiple_files = true;
option java_package = "org.tensorflow.framework";
option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/framework";
option go_package = "tensorflow/core/framework";

package tensorflow;

Expand Down
2 changes: 1 addition & 1 deletion proto/tensorflow/core/framework/types.proto
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ option cc_enable_arenas = true;
option java_outer_classname = "TypesProtos";
option java_multiple_files = true;
option java_package = "org.tensorflow.framework";
option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/framework";
option go_package = "tensorflow/core/framework";

// (== suppress_warning documentation-presence ==)
// LINT.IfChange
Expand Down
2 changes: 1 addition & 1 deletion proto/tensorflow/core/framework/variable.proto
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ option cc_enable_arenas = true;
option java_outer_classname = "VariableProtos";
option java_multiple_files = true;
option java_package = "org.tensorflow.framework";
option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/framework";
option go_package = "tensorflow/core/framework";

// Indicates when a distributed variable will be synced.
enum VariableSynchronization {
Expand Down
2 changes: 1 addition & 1 deletion proto/tensorflow/core/framework/versions.proto
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ option cc_enable_arenas = true;
option java_outer_classname = "VersionsProtos";
option java_multiple_files = true;
option java_package = "org.tensorflow.framework";
option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/framework";
option go_package = "tensorflow/core/framework";

// Version information for a piece of serialized data
//
Expand Down
2 changes: 1 addition & 1 deletion proto/tensorflow/core/protobuf/cluster.proto
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ option cc_enable_arenas = true;
option java_outer_classname = "ClusterProtos";
option java_multiple_files = true;
option java_package = "org.tensorflow.distruntime";
option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/protobuf";
option go_package = "tensorflow/core/framework";

// This file contains protos to be used when defining a TensorFlow
// cluster.
Expand Down
Loading