Skip to content

Commit

Permalink
Tree2 (#103)
Browse files Browse the repository at this point in the history
* fix

* fix

* add tensorflow

* fix

* make op build optional
  • Loading branch information
piiswrong authored May 15, 2020
1 parent 566f722 commit 6442758
Show file tree
Hide file tree
Showing 29 changed files with 1,702 additions and 7 deletions.
4 changes: 0 additions & 4 deletions .gitmodules

This file was deleted.

2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ ci:
bash ci/ci_test.sh

op:
bash cc/build.sh
bash cc/build.sh || echo "WARN: make custom tf op failed!"

protobuf:
python -m grpc_tools.protoc -I protocols -I$(TF_PATH) \
Expand Down
3 changes: 3 additions & 0 deletions cc/build.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#!/bin/bash
set -ex

TF_CFLAGS=$(python -c 'import tensorflow as tf; print(" ".join(tf.sysconfig.get_compile_flags()))')
TF_LFLAGS=$(python -c 'import tensorflow as tf; print(" ".join(tf.sysconfig.get_link_flags()))')

Expand Down
2 changes: 1 addition & 1 deletion fedlearner/trainer/operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class custom_fedlearner_operators_failed_to_load(object):
lagrange_lite_ops = tf.load_op_library(path)


if lagrange_lite_ops is None:
if lagrange_lite_ops is custom_fedlearner_operators_failed_to_load:
logging.warning("Failed to load fedlearner operators from %s", path)


Expand Down
1 change: 0 additions & 1 deletion thirdparty/tensorflow
Submodule tensorflow deleted from 590d6e
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
syntax = "proto3";

package tensorflow;
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";

message AllocationDescription {
// Total number of bytes requested
int64 requested_bytes = 1;

// Total number of bytes allocated if known
int64 allocated_bytes = 2;

// Name of the allocator used
string allocator_name = 3;

// Identifier of the allocated buffer if known
int64 allocation_id = 4;

// Set if this tensor only has one remaining reference
bool has_single_reference = 5;

// Address of the allocation.
uint64 ptr = 6;
};
136 changes: 136 additions & 0 deletions thirdparty/tensorflow/tensorflow/core/framework/api_def.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
// Defines the text format for including per-op API definition and
// overrides for client language op code generators.

syntax = "proto3";

package tensorflow;
option cc_enable_arenas = true;
option java_outer_classname = "ApiDefProtos";
option java_multiple_files = true;
option java_package = "org.tensorflow.framework";
option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/framework";
import "tensorflow/core/framework/attr_value.proto";

// Used to specify and override the default API & behavior in the
// generated code for client languages, from what you would get from
// the OpDef alone. There will be a set of ApiDefs that are common
// to all client languages, and another set per client language.
// The per-client-language ApiDefs will inherit values from the
// common ApiDefs which it can either replace or modify.
//
// We separate the API definition from the OpDef so we can evolve the
// API while remaining backwards compatible when interpretting old
// graphs. Overrides go in an "api_def.pbtxt" file with a text-format
// ApiDefs message.
//
// WARNING: Be *very* careful changing the API for any existing op --
// you can change the semantics of existing code. These changes may
// need to wait until a major release of TensorFlow to avoid breaking
// our compatibility promises.
message ApiDef {
// Name of the op (in the OpDef) to specify the API for.
string graph_op_name = 1;
// If this op is deprecated, set deprecation message to the message
// that should be logged when this op is used.
// The message should indicate alternative op to use, if any.
string deprecation_message = 12;
// Major version when the op will be deleted. For e.g. set this
// value to 2 if op API should be removed in TensorFlow 2.0 and
// deprecated in versions before that.
int32 deprecation_version = 13;

enum Visibility {
// Normally this is "VISIBLE" unless you are inheriting a
// different value from another ApiDef.
DEFAULT_VISIBILITY = 0;
// Publicly visible in the API.
VISIBLE = 1;
// Do not include this op in the generated API. If visibility is
// set to 'SKIP', other fields are ignored for this op.
SKIP = 2;
// Hide this op by putting it into an internal namespace (or whatever
// is appropriate in the target language).
HIDDEN = 3;
}
Visibility visibility = 2;

// If you specify any endpoint, this will replace all of the
// inherited endpoints. The first endpoint should be the
// "canonical" endpoint, and should not be deprecated (unless all
// endpoints are deprecated).
message Endpoint {
// Name should be either like "CamelCaseName" or
// "Package.CamelCaseName". Client-language-specific ApiDefs may
// use a snake_case convention instead of CamelCase.
string name = 1;

// Set if this endpoint is deprecated. If set to true, a message suggesting
// to use a non-deprecated endpoint instead will be printed. If all
// endpoints are deprecated, set deprecation_message in ApiDef instead.
bool deprecated = 3;

// Major version when an endpoint will be deleted. For e.g. set this
// value to 2 if endpoint should be removed in TensorFlow 2.0 and
// deprecated in versions before that.
int32 deprecation_version = 4;
}
repeated Endpoint endpoint = 3;

message Arg {
string name = 1;

// Change the name used to access this arg in the API from what
// is used in the GraphDef. Note that these names in `backticks`
// will also be replaced in the summary & description fields.
string rename_to = 2;

// Note: this will replace any inherited arg doc. There is no
// current way of modifying arg descriptions (other than replacing
// them entirely) as can be done with op descriptions.
string description = 3;
}
repeated Arg in_arg = 4;
repeated Arg out_arg = 5;
// List of original in_arg names to specify new argument order.
// Length of arg_order should be either empty to keep current order
// or match size of in_arg.
repeated string arg_order = 11;

// Description of the graph-construction-time configuration of this
// Op. That is to say, this describes the attr fields that will
// be specified in the NodeDef.
message Attr {
string name = 1;

// Change the name used to access this attr in the API from what
// is used in the GraphDef. Note that these names in `backticks`
// will also be replaced in the summary & description fields.
string rename_to = 2;

// Specify a new default value to use for this attr. This default
// will be used when creating new graphs, as opposed to the
// default in the OpDef, which will be used when interpreting old
// GraphDefs.
AttrValue default_value = 3;

// Note: this will replace any inherited attr doc, there is no current
// way of modifying attr descriptions as can be done with op descriptions.
string description = 4;
}
repeated Attr attr = 6;

// One-line human-readable description of what the Op does.
string summary = 7;

// Additional, longer human-readable description of what the Op does.
string description = 8;

// Modify an existing/inherited description by adding text to the beginning
// or end.
string description_prefix = 9;
string description_suffix = 10;
}

message ApiDefs {
repeated ApiDef op = 1;
}
62 changes: 62 additions & 0 deletions thirdparty/tensorflow/tensorflow/core/framework/attr_value.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
syntax = "proto3";

package tensorflow;
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";
import "tensorflow/core/framework/tensor.proto";
import "tensorflow/core/framework/tensor_shape.proto";
import "tensorflow/core/framework/types.proto";

// Protocol buffer representing the value for an attr used to configure an Op.
// Comment indicates the corresponding attr type. Only the field matching the
// attr type may be filled.
message AttrValue {
// LINT.IfChange
message ListValue {
repeated bytes s = 2; // "list(string)"
repeated int64 i = 3 [packed = true]; // "list(int)"
repeated float f = 4 [packed = true]; // "list(float)"
repeated bool b = 5 [packed = true]; // "list(bool)"
repeated DataType type = 6 [packed = true]; // "list(type)"
repeated TensorShapeProto shape = 7; // "list(shape)"
repeated TensorProto tensor = 8; // "list(tensor)"
repeated NameAttrList func = 9; // "list(attr)"
}
// LINT.ThenChange(https://www.tensorflow.org/code/tensorflow/c/c_api.cc)

oneof value {
bytes s = 2; // "string"
int64 i = 3; // "int"
float f = 4; // "float"
bool b = 5; // "bool"
DataType type = 6; // "type"
TensorShapeProto shape = 7; // "shape"
TensorProto tensor = 8; // "tensor"
ListValue list = 1; // any "list(...)"

// "func" represents a function. func.name is a function's name or
// a primitive op's name. func.attr.first is the name of an attr
// defined for that function. func.attr.second is the value for
// that attr in the instantiation.
NameAttrList func = 10;

// This is a placeholder only used in nodes defined inside a
// function. It indicates the attr value will be supplied when
// the function is instantiated. For example, let us suppose a
// node "N" in function "FN". "N" has an attr "A" with value
// placeholder = "foo". When FN is instantiated with attr "foo"
// set to "bar", the instantiated node N's attr A will have been
// given the value "bar".
string placeholder = 9;
}
}

// A list of attr names and their values. The whole list is attached
// with a string name. E.g., MatMul[T=float].
message NameAttrList {
string name = 1;
map<string, AttrValue> attr = 2;
}
77 changes: 77 additions & 0 deletions thirdparty/tensorflow/tensorflow/core/framework/cost_graph.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
syntax = "proto3";

package tensorflow;
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";
import "tensorflow/core/framework/tensor_shape.proto";
import "tensorflow/core/framework/types.proto";

message CostGraphDef {
message Node {
// The name of the node. Names are globally unique.
string name = 1;

// The device of the node. Can be empty if the node is mapped to the
// default partition or partitioning hasn't been run yet.
string device = 2;

// The id of the node. Node ids are only unique inside a partition.
int32 id = 3;

// Inputs of this node. They must be executed before this node can be
// executed. An input is a particular output of another node, specified
// by the node id and the output index.
message InputInfo {
int32 preceding_node = 1;
int32 preceding_port = 2;
}
repeated InputInfo input_info = 4;

// Outputs of this node.
message OutputInfo {
int64 size = 1;
// If >= 0, the output is an alias of an input. Note that an alias input
// may itself be an alias. The algorithm will therefore need to follow
// those pointers.
int64 alias_input_port = 2;
TensorShapeProto shape = 3;
DataType dtype = 4;
}
repeated OutputInfo output_info = 5;

// Temporary memory used by this node.
int64 temporary_memory_size = 6;

// Persistent memory used by this node.
int64 persistent_memory_size = 12;

int64 host_temp_memory_size = 10 [deprecated = true];
int64 device_temp_memory_size = 11 [deprecated = true];
int64 device_persistent_memory_size = 16 [deprecated = true];

// Estimate of the computational cost of this node, in microseconds.
int64 compute_cost = 9;

// Analytical estimate of the computational cost of this node, in
// microseconds.
int64 compute_time = 14;

// Analytical estimate of the memory access cost of this node, in
// microseconds.
int64 memory_time = 15;

// If true, the output is permanent: it can't be discarded, because this
// node is part of the "final output". Nodes may depend on final nodes.
bool is_final = 7;

// Ids of the control inputs for this node.
repeated int32 control_input = 8;

// Are the costs inaccurate?
bool inaccurate = 17;
}
repeated Node node = 1;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
syntax = "proto3";

package tensorflow;
option cc_enable_arenas = true;
option java_outer_classname = "DeviceAttributesProtos";
option java_multiple_files = true;
option java_package = "org.tensorflow.framework";
option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/framework";

message InterconnectLink {
int32 device_id = 1;
string type = 2;
int32 strength = 3;
};

message LocalLinks {
repeated InterconnectLink link = 1;
};

message DeviceLocality {
// Optional bus locality of device. Default value of 0 means
// no specific locality. Specific localities are indexed from 1.
int32 bus_id = 1;

// Optional NUMA locality of device.
int32 numa_node = 2;

// Optional local interconnect links to other devices.
LocalLinks links = 3;
};

message DeviceAttributes {
// Fully specified name of the device within a cluster.
string name = 1;

// String representation of device_type.
string device_type = 2;

// Memory capacity of device in bytes.
int64 memory_limit = 4;

// Platform-specific data about device that may be useful
// for supporting efficient data transfers.
DeviceLocality locality = 5;

// A device is assigned a global unique number each time it is
// initialized. "incarnation" should never be 0.
fixed64 incarnation = 6;

// String representation of the physical device that this device maps to.
string physical_device_desc = 7;
}
Loading

0 comments on commit 6442758

Please sign in to comment.