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

Method setUp

codegen/test/test_executorch_gen.py:322–371  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

320
321class TestGenFunctionsDeclarations(unittest.TestCase):
322 def setUp(self) -> None:
323 (
324 self.custom_1_native_function,
325 custom_1_backend_index,
326 ) = NativeFunction.from_yaml(
327 {"func": "custom_1::op_1() -> bool", "dispatch": {"CPU": "kernel_1"}},
328 loc=Location(__file__, 1),
329 valid_tags=set(),
330 )
331 (
332 self.custom_2_native_function,
333 custom_2_backend_index,
334 ) = NativeFunction.from_yaml(
335 {
336 "func": "custom_2::op_2() -> bool",
337 "dispatch": {"CPU": "kernel_2"},
338 },
339 loc=Location(__file__, 1),
340 valid_tags=set(),
341 )
342 (
343 self.custom_3_native_function,
344 custom_3_backend_index,
345 ) = NativeFunction.from_yaml(
346 {
347 "func": "custom_3::op_3(Tensor(a!) self, Tensor x) -> Tensor(a!)",
348 "dispatch": {"CPU": "kernel_3"},
349 "variants": "method",
350 },
351 loc=Location(__file__, 1),
352 valid_tags=set(),
353 )
354
355 backend_indices: dict[DispatchKey, dict[OperatorName, BackendMetadata]] = {
356 DispatchKey.CPU: {},
357 DispatchKey.QuantizedCPU: {},
358 }
359 BackendIndex.grow_index(backend_indices, custom_1_backend_index)
360 BackendIndex.grow_index(backend_indices, custom_2_backend_index)
361 self.static_dispatch_idx = [
362 BackendIndex(
363 dispatch_key=k,
364 use_out_as_primary=True,
365 external=False,
366 device_guard=False,
367 index=backend_indices[k],
368 )
369 for k in backend_indices
370 ]
371 self.kernel_index = ETKernelIndex.from_backend_indices(backend_indices)
372
373 def test_operators_with_different_namespaces_are_grouped_correctly(self) -> None:
374 declarations = gen_functions_declarations(

Callers

nothing calls this directly

Calls 1

from_backend_indicesMethod · 0.80

Tested by

no test coverage detected