MCPcopy Create free account
hub / github.com/pytorch/pytorch / extract_df

Method extract_df

benchmarks/dynamo/runner.py:719–778  ·  view source on GitHub ↗
(self, metric, testing)

Source from the content-addressed store, hash-verified

717 return frames
718
719 def extract_df(self, metric, testing):
720 for iter in itertools.product(self.suites, self.devices, self.dtypes):
721 suite, device, dtype = iter
722 frames = []
723 for compiler in self.compilers:
724 output_filename = f"{self.output_dir}/{compiler}_{suite}_{dtype}_{self.mode}_{device}_{testing}.csv"
725 df = self.read_csv(output_filename)
726 if metric not in df:
727 df.insert(len(df.columns), metric, np.nan)
728 df = df[["dev", "name", "batch_size", metric]]
729 df.rename(columns={metric: compiler}, inplace=True)
730 df["batch_size"] = df["batch_size"].astype(int)
731 frames.append(df)
732
733 # Merge the results
734 frames = self.clean_batch_sizes(frames)
735 if len(self.compilers) == 1:
736 df = frames[0]
737 else:
738 # Merge data frames
739 df = pd.merge(frames[0], frames[1], on=["dev", "name", "batch_size"])
740 for idx in range(2, len(frames)):
741 df = pd.merge(df, frames[idx], on=["dev", "name", "batch_size"])
742
743 if testing == "performance":
744 for compiler in self.compilers:
745 df[compiler] = pd.to_numeric(df[compiler], errors="coerce").fillna(
746 0
747 )
748
749 df_copy = df.copy()
750 df_copy = df_copy.sort_values(
751 by=list(reversed(self.compilers)), ascending=False
752 )
753 if "inductor" in self.compilers:
754 df_copy = df_copy.sort_values(by="inductor", ascending=False)
755 self.untouched_parsed_frames[suite][metric] = df_copy
756
757 if testing == "performance":
758 df_accuracy = self.parsed_frames[suite]["accuracy"]
759 perf_rows = []
760 for model_name in df["name"]:
761 perf_row = df[df["name"] == model_name].copy()
762 acc_row = df_accuracy[df_accuracy["name"] == model_name]
763 for compiler in self.compilers:
764 if not perf_row.empty:
765 if acc_row.empty:
766 perf_row[compiler] = 0.0
767 elif acc_row[compiler].iloc[0] not in (
768 "pass",
769 "pass_due_to_skip",
770 ):
771 perf_row[compiler] = 0.0
772 perf_rows.append(perf_row)
773 df = pd.concat(perf_rows)
774 df = df.sort_values(by=list(reversed(self.compilers)), ascending=False)
775
776 if "inductor" in self.compilers:

Callers 1

parseMethod · 0.95

Calls 12

read_csvMethod · 0.95
clean_batch_sizesMethod · 0.95
listFunction · 0.85
reversedFunction · 0.85
astypeMethod · 0.80
concatMethod · 0.80
rangeFunction · 0.50
insertMethod · 0.45
renameMethod · 0.45
appendMethod · 0.45
mergeMethod · 0.45
copyMethod · 0.45

Tested by

no test coverage detected