(self)
| 382 | # Test for native_function_generation |
| 383 | class TestNativeFunctionGeneratrion(unittest.TestCase): |
| 384 | def setUp(self) -> None: |
| 385 | self.native_functions: List[NativeFunction] = [] |
| 386 | self.backend_indices: Dict[ |
| 387 | DispatchKey, Dict[OperatorName, BackendMetadata] |
| 388 | ] = defaultdict(dict) |
| 389 | yaml_entry = """ |
| 390 | - func: op(Tensor self) -> Tensor |
| 391 | dispatch: |
| 392 | CompositeExplicitAutograd: op |
| 393 | autogen: op.out |
| 394 | """ |
| 395 | es = yaml.load(yaml_entry, Loader=LineLoader) |
| 396 | self.one_return_func, m = NativeFunction.from_yaml( |
| 397 | es[0], loc=Location(__file__, 1), valid_tags=set() |
| 398 | ) |
| 399 | |
| 400 | BackendIndex.grow_index(self.backend_indices, m) |
| 401 | |
| 402 | self.two_returns_func, two_returns_backend_index = NativeFunction.from_yaml( |
| 403 | { |
| 404 | "func": "op_2() -> (Tensor, Tensor)", |
| 405 | "dispatch": {"CPU": "kernel_1"}, |
| 406 | "autogen": "op_2.out", |
| 407 | }, |
| 408 | loc=torchgen.model.Location(__file__, 1), |
| 409 | valid_tags=set(), |
| 410 | ) |
| 411 | BackendIndex.grow_index(self.backend_indices, two_returns_backend_index) |
| 412 | |
| 413 | def test_functional_variant_autogen_out_variant(self) -> None: |
| 414 | native_functions = [self.one_return_func] |
nothing calls this directly
no test coverage detected