MCPcopy Create free account
hub / github.com/pytorch/executorch / setUpClass

Method setUpClass

profiler/test/test_profiler_e2e.py:48–69  ·  view source on GitHub ↗
(cls)

Source from the content-addressed store, hash-verified

46class TestCustomOps(unittest.TestCase):
47 @classmethod
48 def setUpClass(cls) -> None:
49 model = Module()
50 inputs = (torch.ones(2, 2, dtype=torch.float),)
51
52 # The serialized program file. This must live longer than cls.module,
53 # because the C++ pybindings will have a pointer to it. But none of the
54 # tests should need to touch it.
55 cls.__buffer: bytes = (
56 to_edge(export(model, inputs, strict=True)).to_executorch().buffer
57 )
58
59 cls.module = _load_for_executorch_from_buffer(cls.__buffer)
60
61 # pyre-fixme[16]: Module `pytree` has no attribute `tree_flatten`.
62 cls.inputs_flattened, _ = tree_flatten(inputs)
63 cls.module.run_method("forward", tuple(cls.inputs_flattened))
64 prof_dump = _dump_profile_results()
65 assert (
66 len(prof_dump) > 0
67 ), "prof_dump is empty; may need to build with `-c executorch.prof_enabled=true`"
68 cls.prof_results, cls.mem_results = deserialize_profile_results(prof_dump)
69 cls.expect_ops = ["native_call_add.out", "native_call_mul.out"]
70
71 def test_profiler_new_block(self) -> None:
72 block_names = ["block_1", "block_2"]

Callers

nothing calls this directly

Calls 7

to_edgeFunction · 0.90
exportFunction · 0.90
onesMethod · 0.80
run_methodMethod · 0.80
ModuleClass · 0.70
to_executorchMethod · 0.45

Tested by

no test coverage detected