(self)
| 318 | |
| 319 | class TestGenNativeFunctionDeclaration(unittest.TestCase): |
| 320 | def setUp(self) -> None: |
| 321 | self.op_1_native_function, op_1_backend_index = NativeFunction.from_yaml( |
| 322 | {"func": "op_1() -> bool", "dispatch": {"CPU": "kernel_1"}}, |
| 323 | loc=torchgen.model.Location(__file__, 1), |
| 324 | valid_tags=set(), |
| 325 | ) |
| 326 | self.op_2_native_function, op_2_backend_index = NativeFunction.from_yaml( |
| 327 | { |
| 328 | "func": "op_2() -> bool", |
| 329 | "dispatch": {"CPU": "kernel_2", "QuantizedCPU": "custom::kernel_3"}, |
| 330 | }, |
| 331 | loc=torchgen.model.Location(__file__, 1), |
| 332 | valid_tags=set(), |
| 333 | ) |
| 334 | |
| 335 | backend_indices: Dict[DispatchKey, Dict[OperatorName, BackendMetadata]] = { |
| 336 | DispatchKey.CPU: {}, |
| 337 | DispatchKey.QuantizedCPU: {}, |
| 338 | } |
| 339 | BackendIndex.grow_index(backend_indices, op_1_backend_index) |
| 340 | BackendIndex.grow_index(backend_indices, op_2_backend_index) |
| 341 | self.backend_indices = { |
| 342 | k: BackendIndex( |
| 343 | dispatch_key=k, |
| 344 | use_out_as_primary=True, |
| 345 | external=False, |
| 346 | device_guard=False, |
| 347 | index=backend_indices[k], |
| 348 | ) |
| 349 | for k in backend_indices |
| 350 | } |
| 351 | |
| 352 | def test_native_function_declaration_1_op_2_ns_error(self) -> None: |
| 353 | with self.assertRaises(AssertionError): |
nothing calls this directly
no test coverage detected