(self, method_name='runTest')
| 81 | """XLA test cases are parameterized test cases.""" |
| 82 | |
| 83 | def __init__(self, method_name='runTest'): |
| 84 | super(XLATestCase, self).__init__(method_name) |
| 85 | self.device = FLAGS.test_device |
| 86 | self.has_custom_call = (self.device == 'XLA_CPU') |
| 87 | self._all_tf_types = set([ |
| 88 | dtypes.as_dtype(types_pb2.DataType.Value(name)) |
| 89 | for name in FLAGS.types.split(',') |
| 90 | ]) |
| 91 | self.int_tf_types = set([ |
| 92 | dtype for dtype in self._all_tf_types if dtype.is_integer |
| 93 | ]) |
| 94 | self._float_tf_types = set([ |
| 95 | dtype for dtype in self._all_tf_types if dtype.is_floating |
| 96 | ]) |
| 97 | self.complex_tf_types = set([ |
| 98 | dtype for dtype in self._all_tf_types if dtype.is_complex |
| 99 | ]) |
| 100 | self._numeric_tf_types = set( |
| 101 | self.int_tf_types | self._float_tf_types | self.complex_tf_types) |
| 102 | self.quantized_tf_types = set( |
| 103 | dtype for dtype in self._all_tf_types if dtype.is_quantized) |
| 104 | |
| 105 | # Quantized types don't have a numpy equivalent, include them in |
| 106 | # all_tf_types but not in all_types. |
| 107 | # TODO(b/115960798): Parametrize tests on TF types instead of numpy types |
| 108 | # and remove all_types. |
| 109 | self._all_types = set(dtype.as_numpy_dtype |
| 110 | for dtype in self._all_tf_types |
| 111 | if not dtype.is_quantized) |
| 112 | self._int_types = set([dtype.as_numpy_dtype for dtype in self.int_tf_types]) |
| 113 | self.signed_int_types = set(dtype.as_numpy_dtype |
| 114 | for dtype in self.int_tf_types |
| 115 | if not dtype.is_unsigned) |
| 116 | self.unsigned_int_types = set(dtype.as_numpy_dtype |
| 117 | for dtype in self.int_tf_types |
| 118 | if dtype.is_unsigned) |
| 119 | self._float_types = set( |
| 120 | [dtype.as_numpy_dtype for dtype in self._float_tf_types]) |
| 121 | self.complex_types = set([ |
| 122 | dtype.as_numpy_dtype for dtype in self.complex_tf_types |
| 123 | ]) |
| 124 | self._numeric_types = set(self._int_types | self._float_types |
| 125 | | self.complex_types) |
| 126 | |
| 127 | # Parse the manifest file, if any, into a regex identifying tests to |
| 128 | # disable |
| 129 | # TODO(xpan): Make it text proto if it doesn't scale. |
| 130 | # Each line of the manifest file specifies an entry. The entry can be |
| 131 | # 1) TestNameRegex // E.g. CumprodTest.* Or |
| 132 | # 2) TestName TypeName // E.g. AdamOptimizerTest.testSharing DT_BFLOAT16 |
| 133 | # The 1) disables the entire test. While 2) only filter some numeric types |
| 134 | # so that they are not used in those tests. |
| 135 | self.disabled_regex = None |
| 136 | self._method_types_filter = {} |
| 137 | |
| 138 | if FLAGS.disabled_manifest is not None: |
| 139 | with open(FLAGS.disabled_manifest, 'r') as manifest_file: |
| 140 | disabled_regex, self._method_types_filter = ( |
nothing calls this directly
no test coverage detected