Merge pull request #126 from feizheng10/simplify_show_all
Simplify interface of tty show
Этот коммит содержится в:
@@ -202,18 +202,9 @@ def run_cli(args, runs):
|
||||
runs[d[0]], d[0], is_gui, args.g, args.verbose
|
||||
) # create the loaded table
|
||||
if args.list_kernels:
|
||||
tty.show_kernels(runs, archConfigs["gfx90a"], output, args.decimal)
|
||||
tty.show_kernels(args, runs, archConfigs["gfx90a"], output)
|
||||
else:
|
||||
tty.show_all(
|
||||
runs,
|
||||
archConfigs["gfx90a"],
|
||||
output,
|
||||
args.df_file_dir,
|
||||
args.decimal,
|
||||
args.time_unit,
|
||||
args.cols,
|
||||
args.verbose,
|
||||
)
|
||||
tty.show_all(args, runs, archConfigs["gfx90a"], output)
|
||||
|
||||
|
||||
def roofline_only(path_to_dir, dev_id, sort_type, mem_level, kernel_names, verbose):
|
||||
|
||||
@@ -48,13 +48,11 @@ def string_multiple_lines(source, width, max_rows):
|
||||
return "\n".join(lines)
|
||||
|
||||
|
||||
def show_all(
|
||||
runs, archConfigs, output, df_file_dir, decimal, time_unit, selected_cols, verbose
|
||||
):
|
||||
def show_all(args, runs, archConfigs, output):
|
||||
"""
|
||||
Show all panels with their data in plain text mode.
|
||||
"""
|
||||
comparable_columns = parser.build_comparable_columns(time_unit)
|
||||
comparable_columns = parser.build_comparable_columns(args.time_unit)
|
||||
|
||||
for panel_id, panel in archConfigs.panel_configs.items():
|
||||
# Skip panels that don't support baseline comparison
|
||||
@@ -72,11 +70,8 @@ def show_all(
|
||||
|
||||
for header in list(base_df.keys()):
|
||||
if (
|
||||
(not selected_cols)
|
||||
or (
|
||||
selected_cols
|
||||
and base_df.columns.get_loc(header) in selected_cols
|
||||
)
|
||||
(not args.cols)
|
||||
or (args.cols and base_df.columns.get_loc(header) in args.cols)
|
||||
or (type == "raw_csv_table")
|
||||
):
|
||||
if header in hidden_columns:
|
||||
@@ -126,7 +121,7 @@ def show_all(
|
||||
.pct_change(axis="columns")
|
||||
.iloc[:, 1]
|
||||
)
|
||||
if verbose >= 2:
|
||||
if args.verbose >= 2:
|
||||
print("---------", header, t_df)
|
||||
|
||||
# show value + percentage
|
||||
@@ -134,12 +129,12 @@ def show_all(
|
||||
t_df = (
|
||||
cur_df[header]
|
||||
.astype(float)
|
||||
.round(decimal)
|
||||
.round(args.decimal)
|
||||
.map(str)
|
||||
+ " ("
|
||||
+ t_df.astype(float)
|
||||
.mul(100)
|
||||
.round(decimal)
|
||||
.round(args.decimal)
|
||||
.map(str)
|
||||
+ "%)"
|
||||
)
|
||||
@@ -147,7 +142,9 @@ def show_all(
|
||||
df = pd.concat([df, t_df], axis=1)
|
||||
else:
|
||||
cur_df[header] = [
|
||||
round(float(x), decimal) if x != "" else x
|
||||
round(float(x), args.decimal)
|
||||
if x != ""
|
||||
else x
|
||||
for x in base_df[header]
|
||||
]
|
||||
|
||||
@@ -164,8 +161,8 @@ def show_all(
|
||||
if "title" in table_config and table_config["title"]:
|
||||
ss += table_id_str + " " + table_config["title"] + "\n"
|
||||
|
||||
if df_file_dir:
|
||||
p = Path(df_file_dir)
|
||||
if args.df_file_dir:
|
||||
p = Path(args.df_file_dir)
|
||||
if not p.exists():
|
||||
p.mkdir()
|
||||
if p.is_dir():
|
||||
@@ -191,7 +188,7 @@ def show_all(
|
||||
else df,
|
||||
headers="keys",
|
||||
tablefmt="fancy_grid",
|
||||
floatfmt="." + str(decimal) + "f",
|
||||
floatfmt="." + str(args.decimal) + "f",
|
||||
)
|
||||
+ "\n"
|
||||
)
|
||||
@@ -202,7 +199,7 @@ def show_all(
|
||||
print(ss, file=output)
|
||||
|
||||
|
||||
def show_kernels(runs, archConfigs, output, decimal):
|
||||
def show_kernels(args, runs, archConfigs, output):
|
||||
"""
|
||||
Show the kernels from top stats.
|
||||
"""
|
||||
@@ -222,7 +219,10 @@ def show_kernels(runs, archConfigs, output, decimal):
|
||||
|
||||
print(
|
||||
tabulate(
|
||||
df, headers="keys", tablefmt="fancy_grid", floatfmt="." + str(decimal) + "f"
|
||||
df,
|
||||
headers="keys",
|
||||
tablefmt="fancy_grid",
|
||||
floatfmt="." + str(args.decimal) + "f",
|
||||
),
|
||||
file=output,
|
||||
)
|
||||
|
||||
Ссылка в новой задаче
Block a user