diff options
author | A. Unique TensorFlower <gardener@tensorflow.org> | 2018-07-30 02:41:59 -0700 |
---|---|---|
committer | TensorFlower Gardener <gardener@tensorflow.org> | 2018-07-30 02:45:14 -0700 |
commit | 333f9c03950a1b6afb8a902b2dc3d883be490b86 (patch) | |
tree | 1c759f72f699df5078f085a517334ce8da8f1fec /tensorflow/contrib/lite/testing | |
parent | 9e0b05bbc4bb88d1b34fb2147429dc4ad7bd25cd (diff) |
Implementation of logical_or.
PiperOrigin-RevId: 206549781
Diffstat (limited to 'tensorflow/contrib/lite/testing')
-rw-r--r-- | tensorflow/contrib/lite/testing/generate_examples.py | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/tensorflow/contrib/lite/testing/generate_examples.py b/tensorflow/contrib/lite/testing/generate_examples.py index 4234d0b811..a95b26220d 100644 --- a/tensorflow/contrib/lite/testing/generate_examples.py +++ b/tensorflow/contrib/lite/testing/generate_examples.py @@ -231,6 +231,7 @@ _TF_TYPE_INFO = { tf.int32: (np.int32, "INT32"), tf.uint8: (np.uint8, "QUANTIZED_UINT8"), tf.int64: (np.int64, "INT64"), + tf.bool: (np.bool, "BOOL"), } @@ -244,7 +245,8 @@ def create_tensor_data(dtype, shape, min_value=-100, max_value=100): value = (max_value-min_value)*np.random.random_sample(shape)+min_value elif dtype in (tf.int32, tf.uint8, tf.int64): value = np.random.randint(min_value, max_value+1, shape) - + elif dtype == tf.bool: + value = np.random.choice([True, False], size=shape) return np.dtype(dtype).type(value) if np.isscalar(value) else value.astype( dtype) @@ -2982,6 +2984,35 @@ def make_pack_tests(zip_path): make_zip_of_tests(zip_path, test_parameters, build_graph, build_inputs) +def make_logical_or_tests(zip_path): + """Make a set of tests to do logical_or.""" + + 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 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) + + # Toco binary path provided by the generate rule. bin_path = None |