Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Branch 167401527 #12780

Merged
merged 69 commits into from
Sep 3, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
db4afe5
Make convolutional, pooling and normalization layers to work with EAGER.
tensorflower-gardener Aug 30, 2017
7453a0f
Fix conversion of string constants with nulls to EagerTensors.
tensorflower-gardener Aug 30, 2017
bd64cdd
Fix bias_add size calculation for half.
zheng-xq Aug 30, 2017
2ce226d
Only add reduce-precision ops inside FusionKind::kLoop fusion nodes.
tensorflower-gardener Aug 30, 2017
394214d
Set the GPU execution context inside the callback wrapper in CudaSolv…
tensorflower-gardener Aug 30, 2017
f63078d
Fixed a bug that the job was calculated based on wrong master for eva…
Aug 30, 2017
af20b42
Add make_best_model_export_strategy which exports the best model acco…
tensorflower-gardener Aug 30, 2017
6ee8614
Updates the docstring and model examples to use new style to specify …
Aug 30, 2017
2e3d2f9
[TF:XLA] Don't pass opcode separately in two HLO visitor functions.
tensorflower-gardener Aug 30, 2017
a4faf51
GroupByDynamicWindowDataset: A new Dataset where the window size is a…
tensorflower-gardener Aug 30, 2017
66ed3d8
Move most of checkpoint_ops and tests from contrib to core (private i…
tensorflower-gardener Aug 30, 2017
4aa8376
Don't try to evaluate a Tensor as a boolean.
tensorflower-gardener Aug 30, 2017
d22ed61
Adds tape.watch_variable(v) where v is any ResourceVariable.
Aug 31, 2017
4807158
Add functional cudnn_rnn_ops
protoget Aug 31, 2017
62742c1
Add code to extract feature importance.
tensorflower-gardener Aug 31, 2017
87c7e2c
TFE: Simplify tfe.Tensor.__str__() output
caisq Aug 31, 2017
5c3977c
Don't use std::pair on GPU since it's not supported by nvcc
benoitsteiner Aug 31, 2017
114e129
Fix TSAN flakes in Keras io_utils test.
fchollet Aug 31, 2017
9acea81
Annotate the graph properties with input values if they're known stat…
benoitsteiner Aug 31, 2017
424aa9a
Eager-graph mode should work with gradient computation.
alextp Aug 31, 2017
9624d16
Add function support to Tensorflow C API
iganichev Aug 31, 2017
6523d83
Make SummaryEntry a msan-resistant plain-old-data (something that can…
tensorflower-gardener Aug 31, 2017
9514a70
Update profiler doc.
tensorflower-gardener Aug 31, 2017
7862d3c
Fixed errors in GPU crosstool in cuda_clang mode.
tensorflower-gardener Aug 31, 2017
8b20ddf
[XLA] Sanity check the list of called computations for fusion nodes
majnemer Aug 31, 2017
059c684
[TF:XLA] Implement SoftSign, SoftSignGrad, ReciprocalGrad, Approximat…
hawkinsp Aug 31, 2017
8dbd2b9
Update ops-related pbtxt files.
tensorflower-gardener Aug 31, 2017
8631630
Introducing tf.contrib.receptive_field
tensorflower-gardener Aug 31, 2017
9b7e05a
Go: Update generated wrapper functions for TensorFlow ops.
tensorflower-gardener Aug 31, 2017
cf3e3d1
Change node name index in InstantiateFunction from an unordered map t…
hawkinsp Aug 31, 2017
6cdc01c
Automatically fill in num_classes, growing_mode, pruning_mode, learni…
tensorflower-gardener Aug 31, 2017
569af01
Fixing small issues introduced with tf.contrib.receptive_field
tensorflower-gardener Aug 31, 2017
91617d2
[XLA] Dump nested fusion nodes without crashing
majnemer Aug 31, 2017
19680e6
Initial submit for TFGAN.
tensorflower-gardener Aug 31, 2017
842f3b2
Remove unused BUILD dependencies
tensorflower-gardener Aug 31, 2017
6e8d0c6
Improve the error messaging in the case of label dimension mismatch.
tensorflower-gardener Sep 1, 2017
73d7964
Rollback update-ability of dataflow and alias analysis added in cl/16…
meheffernan Sep 1, 2017
829962b
Update feature_util to support SequenceExample proto.
tensorflower-gardener Sep 1, 2017
8b05d12
Shard some tests to prevent timeouts.
tensorflower-gardener Sep 1, 2017
bfb6e8e
Add `gan` import to cmake.
tensorflower-gardener Sep 1, 2017
046533f
Automated g4 rollback of changelist 167286643
tensorflower-gardener Sep 1, 2017
9fe71e0
Adding back contrib.receptive_field test to oss.
tensorflower-gardener Sep 1, 2017
1196fbc
Use boolean literals where appropriate instead of narrowing ints
tensorflower-gardener Sep 1, 2017
12cf8c1
Fix broken link in Estimators.
tensorflower-gardener Sep 1, 2017
f773374
Join an unjoined checked thread in fifo_queue_test.
gunan Sep 1, 2017
0acf5bb
Added registry for variants for op ZerosLike.
ebrevdo Sep 1, 2017
6d6118f
Change global step to int64.
jpienaar Sep 1, 2017
b897ae0
Fixing typo.
tensorflower-gardener Sep 1, 2017
2e7fdf0
Fix convert_to_tensor problem for list of TensorNodes
tensorflower-gardener Sep 1, 2017
390dcd2
Change bfloat constructor to accept a float to avoid truncation in im…
tensorflower-gardener Sep 1, 2017
ef1286e
Internal change
tensorflower-gardener Sep 1, 2017
fe8905e
Fix issue where some pooling op gradients on the CPU would fail when …
tensorflower-gardener Sep 1, 2017
c75f0ff
Enable partial JPEG decompression.
mingxingtan Sep 1, 2017
6af27b1
Revert breaking change
Sep 1, 2017
42fcbb1
Automated g4 rollback of changelist 166396680
tensorflower-gardener Sep 1, 2017
a4fe925
Implement reduce_min and reduce_max gradients.
tensorflower-gardener Sep 1, 2017
25b301d
Automated g4 rollback of changelist 167318475
jpienaar Sep 1, 2017
e09619b
Increase the size of the flaky sample_stats_test.py
gunan Sep 1, 2017
b541b48
Update CUB to 1.7.3
tensorflower-gardener Sep 1, 2017
e83d8ab
Contrib ops and kernels for summary ops which write without touching …
alextp Sep 1, 2017
c54cf14
Go: Update generated wrapper functions for TensorFlow ops.
tensorflower-gardener Sep 1, 2017
88063cd
Automated g4 rollback of changelist 167320150
tensorflower-gardener Sep 2, 2017
1499e91
Typo
alextp Sep 2, 2017
2935132
Use the shared locks when reading the model.
tensorflower-gardener Sep 2, 2017
7d5cbd7
Update feature_util to support SequenceExample proto.
tensorflower-gardener Sep 2, 2017
ddba1e0
Replace CHECKs in v1 checkpoint loading codepath with returning errors.
tensorflower-gardener Sep 2, 2017
d57572e
Merge changes from github.
martinwicke Sep 3, 2017
ece2455
Resolve conflicts
martinwicke Sep 3, 2017
3e0e584
Make matrix_solve_ls_test medium
martinwicke Sep 3, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions tensorflow/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ filegroup(
"//tensorflow/contrib/ffmpeg/default:all_files",
"//tensorflow/contrib/framework:all_files",
"//tensorflow/contrib/fused_conv:all_files",
"//tensorflow/contrib/gan:all_files",
"//tensorflow/contrib/graph_editor:all_files",
"//tensorflow/contrib/grid_rnn:all_files",
"//tensorflow/contrib/hooks:all_files",
Expand Down Expand Up @@ -323,6 +324,7 @@ filegroup(
"//tensorflow/contrib/nn:all_files",
"//tensorflow/contrib/opt:all_files",
"//tensorflow/contrib/predictor:all_files",
"//tensorflow/contrib/receptive_field:all_files",
"//tensorflow/contrib/reduce_slice_ops:all_files",
"//tensorflow/contrib/remote_fused_graph/pylib:all_files",
"//tensorflow/contrib/resampler:all_files",
Expand All @@ -342,6 +344,7 @@ filegroup(
"//tensorflow/contrib/staging:all_files",
"//tensorflow/contrib/stat_summarizer:all_files",
"//tensorflow/contrib/stateless:all_files",
"//tensorflow/contrib/summary:all_files",
"//tensorflow/contrib/tensor_forest:all_files",
"//tensorflow/contrib/tensor_forest/hybrid:all_files",
"//tensorflow/contrib/tensor_forest/kernels/v4:all_files",
Expand Down
24 changes: 22 additions & 2 deletions tensorflow/c/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,13 @@ tf_cuda_library(

tf_cuda_library(
name = "c_api",
srcs = ["c_api.cc"],
hdrs = ["c_api.h"],
srcs = [
"c_api.cc",
"c_api_function.cc",
],
hdrs = [
"c_api.h",
],
copts = tf_copts(),
visibility = ["//visibility:public"],
deps = select({
Expand Down Expand Up @@ -157,6 +162,21 @@ tf_cc_test(
],
)

tf_cc_test(
name = "c_api_function_test",
size = "small",
srcs = ["c_api_function_test.cc"],
deps = [
":c_api",
":c_test_util",
"//tensorflow/core:lib",
"//tensorflow/core:lib_internal",
"//tensorflow/core:protos_all_cc",
"//tensorflow/core:test",
"//tensorflow/core:test_main",
],
)

tf_cc_test(
name = "while_loop_test",
size = "small",
Expand Down
37 changes: 21 additions & 16 deletions tensorflow/c/c_api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -165,22 +165,6 @@ void deallocate_buffer(void* data, size_t len, void* arg) {
tensorflow::cpu_allocator()->DeallocateRaw(data);
}

Status MessageToBuffer(const tensorflow::protobuf::Message& in,
TF_Buffer* out) {
if (out->data != nullptr) {
return InvalidArgument("Passing non-empty TF_Buffer is invalid.");
}
const auto proto_size = in.ByteSizeLong();
void* buf = tensorflow::port::Malloc(proto_size);
in.SerializeToArray(buf, proto_size);
out->data = buf;
out->length = proto_size;
out->data_deallocator = [](void* data, size_t length) {
tensorflow::port::Free(data);
};
return Status::OK();
}

} // namespace

TF_Tensor::~TF_Tensor() { buffer->Unref(); }
Expand Down Expand Up @@ -559,6 +543,27 @@ TF_Tensor* TF_TensorFromTensor(const tensorflow::Tensor& src,
dimvec.size(), base, size, DeleteArray, base);
}

Status MessageToBuffer(const tensorflow::protobuf::Message& in,
TF_Buffer* out) {
if (out->data != nullptr) {
return InvalidArgument("Passing non-empty TF_Buffer is invalid.");
}
const size_t proto_size = in.ByteSizeLong();
void* buf = tensorflow::port::Malloc(proto_size);
if (buf == nullptr) {
return tensorflow::errors::ResourceExhausted(
"Failed to allocate memory to serialize message of type '",
in.GetTypeName(), "' and size ", proto_size);
}
in.SerializeToArray(buf, proto_size);
out->data = buf;
out->length = proto_size;
out->data_deallocator = [](void* data, size_t length) {
tensorflow::port::Free(data);
};
return Status::OK();
}

// Helpers for loading a TensorFlow plugin (a .so file).
Status LoadLibrary(const char* library_filename, void** result,
const void** buf, size_t* len);
Expand Down
116 changes: 116 additions & 0 deletions tensorflow/c/c_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,14 @@ typedef struct TF_Output {
int index; // The index of the output within oper.
} TF_Output;

// TF_Function is a grouping of operations with defined inputs and outputs.
// Once created and added to graphs, functions can be invoked by creating an
// operation whose operation type matches the function name.
typedef struct TF_Function TF_Function;

// Function definition options. TODO(iga): Define and implement
typedef struct TF_FunctionOptions TF_FunctionOptions;

// Sets the shape of the Tensor referenced by `output` in `graph` to
// the shape described by `dims` and `num_dims`.
//
Expand Down Expand Up @@ -914,6 +922,15 @@ TF_CAPI_EXPORT extern void TF_GraphImportGraphDef(
TF_Graph* graph, const TF_Buffer* graph_def,
const TF_ImportGraphDefOptions* options, TF_Status* status);

// Add `function` to graph `g`. Once `function` is added to `g`,
// it can be called by creating an operation using the function's name.
//
// If successful, status is set to OK and function is added to g
// Otherwise, status is set to the encountered error and g is unmodified
TF_CAPI_EXPORT extern void TF_GraphAddFunction(TF_Graph* g,
const TF_Function* function,
TF_Status* status);

// Note: The following function may fail on very large protos in the future.

TF_CAPI_EXPORT extern void TF_OperationToNodeDef(TF_Operation* oper,
Expand Down Expand Up @@ -1001,6 +1018,105 @@ TF_CAPI_EXPORT void TF_AddGradients(TF_Graph* g, TF_Output* y, int ny,
TF_Output* x, int nx, TF_Output* dx,
TF_Status* status, TF_Output* dy);

// Create a TF_Function from a TF_Graph
//
// Params:
// fn_body - the graph whose operations (or subset of whose operations) will be
// converted to TF_Function.
// fn_name - the name of the new TF_Function. Should match the operation
// name (OpDef.name) regexp [A-Z][A-Za-z0-9_.\\-/]* and be distinct
// from other operation names (at least those registered in graphs
// where this function will be used).
// TODO(iga): Allow null in here and have C API come up with
// a unique name with high probability (similarly to
// _create_hash_str in function.py)
// num_opers - `num_opers` contains the number of elements in the `opers` array
// or a special value of -1 meaning that no array is given.
// The distinction between an empty array of operations and no
// array of operations is necessary to distinguish the case of
// creating a function with no body (e.g. identity or permutation)
// and the case of creating a function whose body contains all
// the nodes in the graph (except for the automatic skipping, see
// below).
// opers - Array of operations to become the body of the function or null.
// - If no array is given (`num_opers` = -1), all the
// operations in `fn_body` will become part of the function
// except operations referenced in `inputs`. These operations
// must have a single output (these operations are typically
// placeholders created for the sole purpose of representing
// an input. We can relax this constraint if there are
// compelling use cases).
// - If an array is given (`num_opers` >= 0), all operations
// in it will become part of the function. In particular, no
// automatic skipping of dummy input operations is performed.
// ninputs - number of elements in `inputs` array
// inputs - array of TF_Outputs that specify the inputs to the function.
// If `ninputs` is zero (the function takes no inputs), `inputs`
// can be null. The names used for function inputs are normalized
// names of the operations (usually placeholders) pointed to by
// `inputs`. These operation names should start with a letter.
// Normalization will convert all letters to lowercase and
// non-alphanumeric characters to '_' to make resulting names match
// the "[a-z][a-z0-9_]*" pattern for operation argument names.
// `inputs` cannot contain the same tensor twice.
// noutputs - number of elements in `outputs` array
// outputs - array of TF_Outputs that specify the outputs of the function.
// If `noutputs` is zero (the function returns no outputs), `outputs`
// can be null. `outputs` can contain the same tensor more than once.
// output_names - The names of the function's outputs. `output_names` array
// must either have the same length as `outputs`
// (i.e. `noutputs`) or be null. In the former case,
// the names should match the regular expression for ArgDef
// names - "[a-z][a-z0-9_]*". In the latter case,
// names for outputs will be generated automatically.
// opts - various options for the function, e.g. XLA's inlining control.
// status - Set to OK on success and an appropriate error on failure.
//
// Note that when the same TF_Output is listed as both an input and an output,
// the corresponding function's output will equal to this input,
// instead of the original node's output.
//
// Callers must also satisfy the following constraints:
// - `inputs` cannot refer to TF_Outputs within a control flow context. For
// example, one cannot use the output of "switch" node as input.
// - No TF_Output of a function (inside any of `inputs`, `outputs`, `fn_body`)
// is allowed to have a reference type. Reference types are not exposed
// through C API and are being deprecated.
// - Every node in the function's body must have all of its inputs (including
// control inputs). In other words, for every node in the body, each input
// must be either listed in `inputs` or must come from another node in
// the body. In particular, it is an error to have a control edge going from
// a node outside of the body into a node in the body. This applies to control
// edges going from nodes referenced in `inputs` to nodes in the body when
// the former nodes are not in the body (automatically skipped or not
// included in explicitly specified body).
//
// Returns:
// On successful, a newly created TF_Function instance. It must be deleted by
// calling TF_DeleteFunction.
//
// On failure, null.
//
// TODO(iga): Add input_names argument and get output_names working (they are
// currently ignored)
TF_CAPI_EXPORT extern TF_Function* TF_GraphToFunction(
const TF_Graph* fn_body, const char* fn_name, int num_opers,
const TF_Operation* const* opers, int ninputs, const TF_Output* inputs,
int noutputs, const TF_Output* outputs, const char* const* output_names,
const TF_FunctionOptions* opts, TF_Status* status);

// Write out a serialized representation of `func` (as a FunctionDef protocol
// message) to `output_func_def` (allocated by TF_NewBuffer()).
// `output_func_def`'s underlying buffer will be freed when TF_DeleteBuffer()
// is called.
//
// May fail on very large graphs in the future.
TF_CAPI_EXPORT extern void TF_FunctionToFunctionDef(TF_Function* func,
TF_Buffer* output_func_def,
TF_Status* status);

TF_CAPI_EXPORT extern void TF_DeleteFunction(TF_Function*);

// TODO(josh11b): Register OpDef, available to all operations added
// to this graph.

Expand Down