aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/core/api_def
diff options
context:
space:
mode:
authorGravatar Mingsheng Hong <hongm@google.com>2018-08-08 18:00:05 -0700
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2018-08-08 18:06:53 -0700
commit8453e23a8b65423a4f2bfb2a98a928954771498f (patch)
treede12dd18c507eea466fb495fc8f58774a74e204a /tensorflow/core/api_def
parentf2ff7b160794f2fd8ea5bafb1e910f1c14966202 (diff)
Added forked versions of stateless If and While ops. They should only be used,
when the if then/else body of If or the While body funcs do not have stateful ops. The are lowered to the same XLA ops. One use case is in the S4TF compiler: https://github.com/apple/swift/pull/18509 PiperOrigin-RevId: 207977126
Diffstat (limited to 'tensorflow/core/api_def')
-rw-r--r--tensorflow/core/api_def/base_api/api_def_StatelessIf.pbtxt43
-rw-r--r--tensorflow/core/api_def/base_api/api_def_StatelessWhile.pbtxt36
-rw-r--r--tensorflow/core/api_def/python_api/api_def_StatelessIf.pbtxt1
-rw-r--r--tensorflow/core/api_def/python_api/api_def_StatelessWhile.pbtxt1
4 files changed, 81 insertions, 0 deletions
diff --git a/tensorflow/core/api_def/base_api/api_def_StatelessIf.pbtxt b/tensorflow/core/api_def/base_api/api_def_StatelessIf.pbtxt
new file mode 100644
index 0000000000..c0a6ba15e6
--- /dev/null
+++ b/tensorflow/core/api_def/base_api/api_def_StatelessIf.pbtxt
@@ -0,0 +1,43 @@
+op {
+ graph_op_name: "StatelessIf"
+ in_arg { name: "cond" description: "The predicate." }
+ in_arg {
+ name: "cond"
+ description: <<END
+ A Tensor. If the tensor is a scalar of non-boolean type, the
+ scalar is converted to a boolean according to the
+ following rule: if the scalar is a numerical value, non-zero means
+ `True` and zero means False; if the scalar is a string, non-empty
+ means `True` and empty means `False`. If the tensor is not a scalar,
+ being empty means False and being non-empty means True.
+
+ This should only be used when the if then/else body functions do not
+ have stateful ops.
+END
+ }
+ in_arg {
+ name: "input"
+ description: "A list of input tensors."
+ }
+ out_arg {
+ name: "output"
+ description: "A list of return values."
+ }
+ attr { name: "Tin" description: "A list of input types." }
+ attr { name: "Tout" description: "A list of output types." }
+ attr {
+ name: "then_branch"
+ description: <<END
+ A function that takes 'inputs' and returns a list of tensors, whose
+ types are the same as what else_branch returns.
+END
+ }
+ attr {
+ name: "else_branch"
+ description: <<END
+ A function that takes 'inputs' and returns a list of tensors, whose
+ types are the same as what then_branch returns.
+END
+ }
+ summary: "output = cond ? then_branch(input) : else_branch(input)"
+}
diff --git a/tensorflow/core/api_def/base_api/api_def_StatelessWhile.pbtxt b/tensorflow/core/api_def/base_api/api_def_StatelessWhile.pbtxt
new file mode 100644
index 0000000000..87c0e09673
--- /dev/null
+++ b/tensorflow/core/api_def/base_api/api_def_StatelessWhile.pbtxt
@@ -0,0 +1,36 @@
+op {
+ graph_op_name: "StatelessWhile"
+ in_arg {
+ name: "input"
+ description: "A list of input tensors whose types are T."
+ }
+ out_arg {
+ name: "output"
+ description: "A list of output tensors whose types are T."
+ }
+ attr { name: "T" description: "dtype in use." }
+ attr {
+ name: "cond"
+ description: <<END
+ A function takes 'input' and returns a tensor. If the tensor is
+ a scalar of non-boolean, the scalar is converted to a boolean
+ according to the following rule: if the scalar is a numerical
+ value, non-zero means True and zero means False; if the scalar is
+ a string, non-empty means True and empty means False. If the
+ tensor is not a scalar, non-emptiness means True and False
+ otherwise.
+
+ This should only be used when the while condition and body functions
+ do not have stateful ops.
+END
+ }
+ attr {
+ name: "body"
+ description: <<END
+ A function that takes a list of tensors and returns another
+ list of tensors. Both lists have the same types as specified
+ by T.
+END
+ }
+ summary: "output = input; While (Cond(output)) { output = Body(output) }"
+}
diff --git a/tensorflow/core/api_def/python_api/api_def_StatelessIf.pbtxt b/tensorflow/core/api_def/python_api/api_def_StatelessIf.pbtxt
new file mode 100644
index 0000000000..0298c4852c
--- /dev/null
+++ b/tensorflow/core/api_def/python_api/api_def_StatelessIf.pbtxt
@@ -0,0 +1 @@
+op { graph_op_name: "StatelessIf" visibility: HIDDEN }
diff --git a/tensorflow/core/api_def/python_api/api_def_StatelessWhile.pbtxt b/tensorflow/core/api_def/python_api/api_def_StatelessWhile.pbtxt
new file mode 100644
index 0000000000..c138a71087
--- /dev/null
+++ b/tensorflow/core/api_def/python_api/api_def_StatelessWhile.pbtxt
@@ -0,0 +1 @@
+op { graph_op_name: "StatelessWhile" visibility: HIDDEN }