aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/c/c_api.h
diff options
context:
space:
mode:
authorGravatar Skye Wanderman-Milne <skyewm@google.com>2018-03-06 13:38:56 -0800
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2018-03-06 13:42:58 -0800
commit1d64f9038084095bf92a8ca120d7e1f34ec24ac9 (patch)
tree0a521bc53e682b7ecec1aab5519b983d02a503c4 /tensorflow/c/c_api.h
parentad08baa5c27ab063596116a178ccff7d3796df65 (diff)
Add TF_TryEvaluateConstant to the C API and have smart_cond call it.
This effectively plumbs EvaluateConstantTensor to smart_cond. This makes smart_cond even smarter by trying to evaluate the predicate if it can't statically infer it. PiperOrigin-RevId: 188073244
Diffstat (limited to 'tensorflow/c/c_api.h')
-rw-r--r--tensorflow/c/c_api.h17
1 files changed, 13 insertions, 4 deletions
diff --git a/tensorflow/c/c_api.h b/tensorflow/c/c_api.h
index ad592ef709..b32f574628 100644
--- a/tensorflow/c/c_api.h
+++ b/tensorflow/c/c_api.h
@@ -1275,13 +1275,22 @@ TF_CAPI_EXPORT extern void TF_FunctionGetAttrValueProto(
// Deleting a function does not remove it from any graphs it was copied to.
TF_CAPI_EXPORT extern void TF_DeleteFunction(TF_Function* func);
+// Attempts to evaluate `output`. This will only be possible if `output` doesn't
+// depend on any graph inputs (this function is safe to call if this isn't the
+// case though).
+//
+// If the evaluation is successful, this function returns true and `output`s
+// value is returned in `result`. Otherwise returns false. An error status is
+// returned if something is wrong with the graph or input. Note that this may
+// return false even if no error status is set.
+TF_CAPI_EXPORT extern unsigned char TF_TryEvaluateConstant(TF_Graph* graph,
+ TF_Output output,
+ TF_Tensor** result,
+ TF_Status* status);
+
// TODO(josh11b): Register OpDef, available to all operations added
// to this graph.
-// The following two may both benefit from a subgraph-definition API
-// that re-uses most of the graph-definition API.
-// TODO(andydavis): Add functions to a graph.
-
// --------------------------------------------------------------------------
// API for driving Graph execution.