MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / make_identity_tests

Function make_identity_tests

tensorflow/lite/testing/generate_examples_lib.py:829–864  ·  view source on GitHub ↗

Make a set of tests to do identity.

(options)

Source from the content-addressed store, hash-verified

827
828@register_make_test_function()
829def make_identity_tests(options):
830 """Make a set of tests to do identity."""
831
832 # Chose a set of parameters
833 test_parameters = [{
834 "input_shape": [[], [1], [3, 3]],
835 "op_to_use": ["identity", "identity_n", "snapshot"],
836 }]
837
838 def build_graph(parameters):
839 input_tensor = tf.placeholder(
840 dtype=tf.float32, name="input", shape=parameters["input_shape"])
841 # We add the Multiply before Identity just as a walk-around to make the test
842 # pass when input_shape is scalar.
843 # During graph transformation, TOCO will replace the Identity op with
844 # Reshape when input has shape. However, currently TOCO can't distinguish
845 # between missing shape and scalar shape. As a result, when input has scalar
846 # shape, this conversion still fails.
847 # TODO(b/129197312), remove the walk-around code once the bug is fixed.
848 input_doubled = input_tensor * 2.0
849 if parameters["op_to_use"] == "identity":
850 identity_output = tf.identity(input_doubled)
851 elif parameters["op_to_use"] == "identity_n":
852 # Testing `IdentityN` with a single tensor.
853 identity_output = tf.identity_n([input_doubled])[0]
854 elif parameters["op_to_use"] == "snapshot":
855 identity_output = array_ops.snapshot(input_doubled)
856 return [input_tensor], [identity_output]
857
858 def build_inputs(parameters, sess, inputs, outputs):
859 input_values = create_tensor_data(
860 np.float32, parameters["input_shape"], min_value=-4, max_value=10)
861 return [input_values], sess.run(
862 outputs, feed_dict=dict(zip(inputs, [input_values])))
863
864 make_zip_of_tests(options, test_parameters, build_graph, build_inputs)
865
866
867@register_make_test_function()

Callers

nothing calls this directly

Calls 1

make_zip_of_testsFunction · 0.85

Tested by

no test coverage detected