(test_case, op, test_dtype, orig, decomp, args, kwargs)
| 214 | |
| 215 | |
| 216 | def op_assert_equal(test_case, op, test_dtype, orig, decomp, args, kwargs): |
| 217 | test_case.assertEqual( |
| 218 | orig.dtype, decomp.dtype, f"Operation: {op}, orig.dtype: {orig.dtype}, decomp.dtype: {decomp.dtype}, {args}, {kwargs}") |
| 219 | # Before adding an entry to this table, make sure your decomposition is right :) |
| 220 | tol_table = { |
| 221 | # Due to strange epsilon behaviors, see https://github.com/pytorch/pytorch/issues/73161 |
| 222 | (torch.float32, torch.ops.aten.native_layer_norm.default): (1e-3, 1e-3), |
| 223 | (torch.float32, torch.ops.aten.native_layer_norm_backward.default): ( |
| 224 | 1e-3, |
| 225 | 1e-3, |
| 226 | ), |
| 227 | (torch.float64, torch.ops.aten.native_layer_norm.default): (1e-6, 1e-6), |
| 228 | # This exceeds default tolerances only on CPU, on CUDA it's fine |
| 229 | (torch.float32, torch.ops.aten.grid_sampler_2d.default) : (7e-6, 3e-5), |
| 230 | # Exceeds tolerances on CUDA, likely due to fma |
| 231 | (torch.float32, torch.ops.aten.mv.default) : (1e-5, 3e-5), |
| 232 | (torch.complex64, torch.ops.aten.mv.default): (5e-5, 5e-5), |
| 233 | (torch.float64, torch.ops.aten.upsample_bicubic2d.vec) : (1e-5, 5e-4), |
| 234 | (torch.float64, torch.ops.aten.upsample_bicubic2d.default) : (1e-5, 5e-4), |
| 235 | # The decomposition is TOO correct. It computes everything in int64, so sometimes |
| 236 | # there's an off-by-one error. See |
| 237 | # https://github.com/pytorch/pytorch/issues/81996 |
| 238 | # https://github.com/pytorch/pytorch/issues/82230 |
| 239 | (torch.int8, torch.ops.aten.linspace.default) : (0, 1), |
| 240 | (torch.uint8, torch.ops.aten.linspace.default) : (0, 1), |
| 241 | (torch.int16, torch.ops.aten.linspace.default) : (0, 1), |
| 242 | (torch.int32, torch.ops.aten.linspace.default) : (0, 1), |
| 243 | (torch.int64, torch.ops.aten.linspace.default) : (0, 1), |
| 244 | (torch.int8, torch.ops.aten.linspace.Tensor_Tensor) : (0, 1), |
| 245 | (torch.uint8, torch.ops.aten.linspace.Tensor_Tensor) : (0, 1), |
| 246 | (torch.int16, torch.ops.aten.linspace.Tensor_Tensor) : (0, 1), |
| 247 | (torch.int32, torch.ops.aten.linspace.Tensor_Tensor) : (0, 1), |
| 248 | (torch.int64, torch.ops.aten.linspace.Tensor_Tensor) : (0, 1), |
| 249 | (torch.int8, torch.ops.aten.linspace.Tensor_Scalar) : (0, 1), |
| 250 | (torch.uint8, torch.ops.aten.linspace.Tensor_Scalar) : (0, 1), |
| 251 | (torch.int16, torch.ops.aten.linspace.Tensor_Scalar) : (0, 1), |
| 252 | (torch.int32, torch.ops.aten.linspace.Tensor_Scalar) : (0, 1), |
| 253 | (torch.int64, torch.ops.aten.linspace.Tensor_Scalar) : (0, 1), |
| 254 | (torch.int8, torch.ops.aten.linspace.Scalar_Tensor) : (0, 1), |
| 255 | (torch.uint8, torch.ops.aten.linspace.Scalar_Tensor) : (0, 1), |
| 256 | (torch.int16, torch.ops.aten.linspace.Scalar_Tensor) : (0, 1), |
| 257 | (torch.int32, torch.ops.aten.linspace.Scalar_Tensor) : (0, 1), |
| 258 | (torch.int64, torch.ops.aten.linspace.Scalar_Tensor) : (0, 1), |
| 259 | } |
| 260 | if (decomp.dtype, op) in tol_table: |
| 261 | rtol, atol = tol_table[(decomp.dtype, op)] |
| 262 | else: |
| 263 | rtol, atol = _getDefaultRtolAndAtol(orig.dtype, decomp.dtype) |
| 264 | test_case.assertEqual(orig, decomp, rtol=rtol, atol=atol, msg=f"{op.__name__}\nargs = {args}\nkwargs = {kwargs}") |
| 265 | |
| 266 | |
| 267 | # Given f, returns an f' such that: |
no test coverage detected
searching dependent graphs…