MCPcopy Create free account
hub / github.com/pytorch/pytorch / setUp

Method setUp

tools/test/test_codegen.py:444–469  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

442# Test for static_dispatch
443class 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)

Callers

nothing calls this directly

Calls 5

LocationClass · 0.90
BackendIndexClass · 0.90
from_yamlMethod · 0.80
grow_indexMethod · 0.80
loadMethod · 0.45

Tested by

no test coverage detected