aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/contrib/lite/testing
diff options
context:
space:
mode:
authorGravatar A. Unique TensorFlower <gardener@tensorflow.org>2018-08-06 18:12:42 -0700
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2018-08-06 18:16:44 -0700
commit0fc1de719ba0ad6d953f618475c73d35dd27767d (patch)
tree303aecb6c46c5888d9c155c7676aa4a384755133 /tensorflow/contrib/lite/testing
parent56a82b00f461dc8bc2b3e8e63fa768144795a7b2 (diff)
Implementation of logical_and logical_not
PiperOrigin-RevId: 207642985
Diffstat (limited to 'tensorflow/contrib/lite/testing')
-rw-r--r--tensorflow/contrib/lite/testing/generate_examples.py64
1 files changed, 43 insertions, 21 deletions
diff --git a/tensorflow/contrib/lite/testing/generate_examples.py b/tensorflow/contrib/lite/testing/generate_examples.py
index 1bbf918fd7..3d1f8c07d2 100644
--- a/tensorflow/contrib/lite/testing/generate_examples.py
+++ b/tensorflow/contrib/lite/testing/generate_examples.py
@@ -2997,33 +2997,55 @@ def make_pack_tests(zip_path):
make_zip_of_tests(zip_path, test_parameters, build_graph, build_inputs)
+def _make_logical_tests(op):
+ """Make a set of tests to do logical operations."""
+
+ def logical(zip_path):
+ """Generate examples."""
+ test_parameters = [{
+ "input_shape_pair": [([], []), ([1, 1, 1, 3], [1, 1, 1, 3]),
+ ([2, 3, 4, 5], [2, 3, 4, 5]), ([2, 3, 3], [2, 3]),
+ ([5, 5], [1]), ([10], [2, 4, 10])],
+ }]
+
+ def build_graph(parameters):
+ """Build the logical testing graph."""
+ input_value1 = tf.placeholder(
+ dtype=tf.bool, name="input1", shape=parameters["input_shape_pair"][0])
+ input_value2 = tf.placeholder(
+ dtype=tf.bool, name="input2", shape=parameters["input_shape_pair"][1])
+ out = op(input_value1, input_value2)
+ return [input_value1, input_value2], [out]
+
+ def build_inputs(parameters, sess, inputs, outputs):
+ input_value1 = create_tensor_data(tf.bool,
+ parameters["input_shape_pair"][0])
+ input_value2 = create_tensor_data(tf.bool,
+ parameters["input_shape_pair"][1])
+ return [input_value1, input_value2], sess.run(
+ outputs, feed_dict=dict(zip(inputs, [input_value1, input_value2])))
+
+ make_zip_of_tests(zip_path, test_parameters, build_graph, build_inputs)
+
+ return logical
+
+
def make_logical_or_tests(zip_path):
"""Make a set of tests to do logical_or."""
+ return _make_logical_tests(tf.logical_or)(zip_path)
- test_parameters = [{
- "input_shape_pair": [([], []), ([1, 1, 1, 3], [1, 1, 1, 3]),
- ([2, 3, 4, 5], [2, 3, 4, 5]), ([2, 3, 3], [2, 3]),
- ([5, 5], [1]), ([10], [2, 4, 10])],
- }]
- def build_graph(parameters):
- """Build the logical_or op testing graph."""
- input_value1 = tf.placeholder(
- dtype=tf.bool, name="input1", shape=parameters["input_shape_pair"][0])
- input_value2 = tf.placeholder(
- dtype=tf.bool, name="input2", shape=parameters["input_shape_pair"][1])
- out = tf.logical_or(input_value1, input_value2)
- return [input_value1, input_value2], [out]
+def make_logical_and_tests(zip_path):
+ """Make a set of tests to do logical_and."""
+ return _make_logical_tests(tf.logical_and)(zip_path)
- def build_inputs(parameters, sess, inputs, outputs):
- input_value1 = create_tensor_data(tf.bool,
- parameters["input_shape_pair"][0])
- input_value2 = create_tensor_data(tf.bool,
- parameters["input_shape_pair"][1])
- return [input_value1, input_value2], sess.run(
- outputs, feed_dict=dict(zip(inputs, [input_value1, input_value2])))
- make_zip_of_tests(zip_path, test_parameters, build_graph, build_inputs)
+def make_logical_xor_tests(zip_path):
+ """Make a set of tests to do logical_xor.
+
+ Test logical_not as well.
+ """
+ return _make_logical_tests(tf.logical_xor)(zip_path)
# Toco binary path provided by the generate rule.