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

Method to_dataframe

devtools/inspector/_inspector.py:727–777  ·  view source on GitHub ↗

Converts the EventBlock into a DataFrame with each row being an event instance Note: Rows that have an event_name = OPERATOR_CALL correspond to the perf of the previous operator + framework tax of making said operator call. Args: include_units: Whet

(
        self, include_units: bool = False, include_delegate_debug_data: bool = False
    )

Source from the content-addressed store, hash-verified

725 reference_output: Optional[ProgramOutput] = None
726
727 def to_dataframe(
728 self, include_units: bool = False, include_delegate_debug_data: bool = False
729 ) -> pd.DataFrame:
730 """
731 Converts the EventBlock into a DataFrame with each row being an event instance
732
733 Note: Rows that have an event_name = OPERATOR_CALL correspond to the perf of the
734 previous operator + framework tax of making said operator call.
735
736 Args:
737 include_units: Whether headers should include units (default false)
738 include_delegate_debug_data: Whether to show the delegate debug data
739
740 Returns:
741 A pandas DataFrame containing the data of each Event instance in this EventBlock.
742 """
743
744 units = " (" + self.target_time_scale.value + ")" if include_units else ""
745
746 df = pd.concat([e.to_dataframe(units) for e in self.events], ignore_index=True)
747 df.insert(
748 0,
749 "event_block_name",
750 np.asarray([self.name for _ in range(len(self.events))]),
751 allow_duplicates=True,
752 )
753
754 # Add Delegate Debug Metadata columns
755 if include_delegate_debug_data:
756 delegate_data = []
757 for event in self.events:
758 if (metadata := event.delegate_debug_metadatas) is not None and len(
759 metadata
760 ) > 0:
761 if isinstance(metadata, list):
762 delegate_data.append(
763 pd.Series([metadata], index=["delegate_debug_metadata"])
764 )
765 elif isinstance(metadata, dict):
766 delegate_data.append(pd.Series(metadata))
767 else:
768 raise ValueError(
769 f"Unexpected type for delegate_debug_metadata: {type(metadata)}"
770 )
771 else:
772 delegate_data.append(pd.Series())
773
774 if any(not data.empty for data in delegate_data):
775 df = pd.concat([df, pd.DataFrame(delegate_data)], axis=1)
776
777 return df
778
779 @staticmethod
780 def _gen_from_etdump(

Callers 1

Calls 3

insertMethod · 0.80
to_dataframeMethod · 0.45
appendMethod · 0.45

Tested by 1