|
15 | 15 | import executorch.exir.tests.models as models
|
16 | 16 | import torch
|
17 | 17 | from executorch import exir
|
| 18 | +from executorch.backends.xnnpack.partition.xnnpack_partitioner import XnnpackPartitioner |
18 | 19 | from executorch.devtools.bundled_program.config import MethodTestCase, MethodTestSuite
|
19 | 20 | from executorch.devtools.bundled_program.core import BundledProgram
|
20 | 21 | from executorch.devtools.etrecord import generate_etrecord, parse_etrecord
|
@@ -369,6 +370,41 @@ def test_get_etrecord_from_executorch_program_manager(self):
|
369 | 370 | self.assertEqual(etrecord._debug_handle_map, et_manager.debug_handle_map)
|
370 | 371 | self.assertEqual(etrecord._delegate_map, et_manager.delegate_map)
|
371 | 372 |
|
| 373 | + def test_get_etrecord_from_executorch_program_manager_with_partitioner(self): |
| 374 | + """Test getting ETRecord from ExecutorchProgramManager using get_etrecord() method.""" |
| 375 | + f = models.BasicSinMax() |
| 376 | + aten_program = export(f, f.get_random_inputs(), strict=True) |
| 377 | + |
| 378 | + # Generate edge manager with ETRecord |
| 379 | + edge_manager = to_edge_transform_and_lower( |
| 380 | + aten_program, |
| 381 | + partitioner=[XnnpackPartitioner()], |
| 382 | + generate_etrecord=True, |
| 383 | + ) |
| 384 | + |
| 385 | + # Convert to executorch |
| 386 | + et_manager = edge_manager.to_executorch() |
| 387 | + |
| 388 | + # Test get_etrecord method |
| 389 | + etrecord = et_manager.get_etrecord() |
| 390 | + self.assertIsNotNone(etrecord) |
| 391 | + self.assert_etrecord_saveable(etrecord) |
| 392 | + |
| 393 | + # Verify the data matches the original input |
| 394 | + self.check_graph_closeness( |
| 395 | + etrecord.exported_program, |
| 396 | + aten_program.graph_module, |
| 397 | + ) |
| 398 | + self.assertEqual( |
| 399 | + etrecord.export_graph_id, |
| 400 | + id(aten_program.graph), |
| 401 | + ) |
| 402 | + |
| 403 | + # Verify the executorch program data matches |
| 404 | + # ETRecord stores data directly (not JSON serialized), so compare with original data |
| 405 | + self.assertEqual(etrecord._debug_handle_map, et_manager.debug_handle_map) |
| 406 | + self.assertEqual(etrecord._delegate_map, et_manager.delegate_map) |
| 407 | + |
372 | 408 | def test_get_etrecord_from_executorch_program_manager_without_generation(self):
|
373 | 409 | """Test getting ETRecord from ExecutorchProgramManager when ETRecord was not generated."""
|
374 | 410 | f = models.BasicSinMax()
|
@@ -400,6 +436,7 @@ def test_to_edge_transform_and_lower_etrecord_save_and_parse(self):
|
400 | 436 | # Generate edge manager with ETRecord
|
401 | 437 | edge_manager = to_edge_transform_and_lower(
|
402 | 438 | aten_program,
|
| 439 | + partitioner=[XnnpackPartitioner()], |
403 | 440 | generate_etrecord=True,
|
404 | 441 | )
|
405 | 442 |
|
|
0 commit comments