(self)
| 442 | # Test for static_dispatch |
| 443 | class TestStaticDispatchGeneratrion(unittest.TestCase): |
| 444 | def setUp(self) -> None: |
| 445 | self.backend_indices: Dict[ |
| 446 | DispatchKey, Dict[OperatorName, BackendMetadata] |
| 447 | ] = defaultdict(dict) |
| 448 | yaml_entry = """ |
| 449 | - func: op.out(Tensor self, *, Tensor(a!) out) -> Tensor(a!) |
| 450 | dispatch: |
| 451 | CompositeExplicitAutograd: op |
| 452 | """ |
| 453 | es = yaml.load(yaml_entry, Loader=LineLoader) |
| 454 | self.one_return_func, m = NativeFunction.from_yaml( |
| 455 | es[0], loc=Location(__file__, 1), valid_tags=set() |
| 456 | ) |
| 457 | |
| 458 | BackendIndex.grow_index(self.backend_indices, m) |
| 459 | dispatch_key = DispatchKey.CompositeExplicitAutograd |
| 460 | self.assertTrue(dispatch_key in self.backend_indices) |
| 461 | self.indices = [ |
| 462 | BackendIndex( |
| 463 | dispatch_key=dispatch_key, |
| 464 | use_out_as_primary=True, |
| 465 | external=False, |
| 466 | device_guard=False, |
| 467 | index=self.backend_indices[dispatch_key], |
| 468 | ) |
| 469 | ] |
| 470 | |
| 471 | def test_op_with_1_backend_generates_static_dispatch(self) -> None: |
| 472 | disp_sig = DispatcherSignature.from_schema(self.one_return_func.func) |
nothing calls this directly
no test coverage detected