2525from executorch .devtools import generate_etrecord , parse_etrecord
2626from executorch .devtools .debug_format .et_schema import OperatorNode
2727from executorch .devtools .etdump .schema_flatcc import ProfileEvent
28- from executorch .devtools .etrecord ._etrecord import ETRecord
2928from executorch .devtools .etrecord .tests .etrecord_test import TestETRecord
3029
3130from executorch .devtools .inspector import (
@@ -480,7 +479,7 @@ def test_populate_debugging_related_fields_passes_for_consistent_events(self):
480479 events = events ,
481480 )
482481
483- def test_etrecord_populates_correct_aot_intermediate_outputs (self ):
482+ def test_etrecord_populates_correct_edge_dialect_aot_intermediate_outputs (self ):
484483 with tempfile .NamedTemporaryFile (suffix = ".bin" ) as tmp_file :
485484 etrecord_path = tmp_file .name
486485 mod = model_registry ["ConvLinearModel" ]()
@@ -513,15 +512,11 @@ def test_etrecord_populates_correct_aot_intermediate_outputs(self):
513512 etdump_path = ETDUMP_PATH ,
514513 etrecord = etrecord_path ,
515514 )
516- etrecord = ETRecord (
517- edge_dialect_program = inspector_instance ._etrecord .edge_dialect_program ,
518- graph_map = inspector_instance ._etrecord .graph_map ,
519- _debug_handle_map = inspector_instance ._etrecord ._debug_handle_map ,
520- _delegate_map = inspector_instance ._etrecord ._delegate_map ,
521- _reference_outputs = inspector_instance ._etrecord ._reference_outputs ,
522- _representative_inputs = aten_model .example_inputs [0 ],
515+
516+ inspector_instance ._etrecord ._representative_inputs = (
517+ aten_model .example_inputs [0 ]
523518 )
524- inspector_instance . _etrecord = etrecord
519+
525520 aot_intermediate_outputs , aot_debug_handle_to_op_names = (
526521 inspector_instance ._get_aot_intermediate_outputs_and_op_names ()
527522 )
@@ -534,7 +529,61 @@ def test_etrecord_populates_correct_aot_intermediate_outputs(self):
534529
535530 self .assertTrue (
536531 check_if_debug_handle_to_op_names_match (
537- "ConvLinearModel" , aot_debug_handle_to_op_names
532+ aot_debug_handle_to_op_names ,
533+ mod .get_edge_dialect_expected_debug_handle_to_op_names (),
534+ )
535+ )
536+
537+ def test_etrecord_populates_correct_export_program_aot_intermediate_outputs (self ):
538+ with tempfile .NamedTemporaryFile (suffix = ".bin" ) as tmp_file :
539+ etrecord_path = tmp_file .name
540+ mod = model_registry ["ConvLinearModel" ]()
541+ input_tensor = mod .get_input ()
542+ aten_model : ExportedProgram = export (mod , (input_tensor ,), strict = True )
543+ edge_program_manager : EdgeProgramManager = to_edge (aten_model )
544+ edge_program_manager_copy = copy .deepcopy (edge_program_manager )
545+ et_program_manager : ExecutorchProgramManager = (
546+ edge_program_manager .to_executorch ()
547+ )
548+ # Generate ETRecord with the exported program
549+ generate_etrecord (
550+ etrecord_path ,
551+ edge_program_manager_copy ,
552+ et_program_manager ,
553+ exported_program = aten_model ,
554+ )
555+ with patch .object (
556+ Inspector , "_consume_etrecord" , return_value = None
557+ ), patch .object (
558+ _inspector , "gen_etdump_object" , return_value = None
559+ ), patch .object (
560+ EventBlock , "_gen_from_etdump"
561+ ), patch .object (
562+ _inspector , "gen_graphs_from_etrecord"
563+ ):
564+ # Call the constructor of Inspector
565+ inspector_instance = Inspector (
566+ etdump_path = ETDUMP_PATH ,
567+ etrecord = etrecord_path ,
568+ )
569+
570+ inspector_instance ._etrecord ._representative_inputs = (
571+ aten_model .example_inputs [0 ]
572+ )
573+
574+ aot_intermediate_outputs , aot_debug_handle_to_op_names = (
575+ inspector_instance ._get_aot_intermediate_outputs_and_op_names ()
576+ )
577+ self .assertTrue (
578+ check_if_intermediate_outputs_match (
579+ aot_intermediate_outputs ,
580+ mod .get_exported_program_expected_intermediate_outputs (),
581+ )
582+ )
583+ self .assertTrue (
584+ check_if_debug_handle_to_op_names_match (
585+ aot_debug_handle_to_op_names ,
586+ mod .get_exported_program_expected_debug_handle_to_op_names (),
538587 )
539588 )
540589
0 commit comments