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

Method __init__

exir/tests/models.py:161–184  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

159
160class CompositeDelegateModule(torch.nn.Module):
161 def __init__(self) -> None:
162 super().__init__()
163
164 class DelegateAdd(nn.Module):
165 def __init__(self) -> None:
166 super().__init__()
167
168 def forward(self, x: Tensor, y: Tensor) -> Tensor:
169 return [x + y]
170
171 def get_random_inputs(self) -> Tuple[Tensor, Tensor]:
172 return (torch.randn(1, 3), torch.randn(1, 3))
173
174 delegated_m = DelegateAdd()
175 edge_ir_m = to_edge(
176 export(delegated_m, delegated_m.get_random_inputs(), strict=True)
177 )
178 lowered_module = LoweredBackendModule(
179 edge_program=edge_ir_m.exported_program(),
180 backend_id="backend_demo",
181 processed_bytes=bytes("basic_module_add", encoding="utf8"),
182 compile_specs=[],
183 )
184 self.lowered_module: LoweredBackendModule = lowered_module
185
186 def forward(self, a: exir.Value, b: exir.Value, s: Tensor) -> Tensor:
187 res = self.lowered_module(a, b)

Callers

nothing calls this directly

Calls 7

get_random_inputsMethod · 0.95
to_edgeFunction · 0.90
exportFunction · 0.90
DelegateAddClass · 0.85
__init__Method · 0.45
exported_programMethod · 0.45

Tested by

no test coverage detected