File size: 4,002 Bytes
65e4811
 
 
 
 
 
 
73cf0ca
65e4811
73cf0ca
65e4811
 
 
 
 
 
73cf0ca
65e4811
 
73cf0ca
65e4811
 
 
 
 
 
 
 
 
73cf0ca
2a6282d
65e4811
 
 
 
 
 
 
 
 
 
 
 
 
2a6282d
65e4811
 
b20457b
 
 
b81d67c
b20457b
 
 
 
6e0dbd3
b20457b
 
 
 
 
 
 
6e0dbd3
572d2ff
b20457b
b81d67c
2a6282d
b20457b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import pandas as pd
import gradio as gr
import plotly.graph_objects as go
import plotly.express as px
import numpy as np

type_emoji = {
    "RTL-Specific": "🔴",
    "General": "🟢",
    "Coding": "🔵"
}

def model_hyperlink(link, model_name):
    return f'<a target="_blank" href="{link}" style="color: var(--link-text-color); text-decoration: underline;text-decoration-style: dotted;">{model_name}</a>'

def handle_special_cases(benchmark, metric):
    if metric == 'Exact Matching (EM)':
        benchmark = 'RTL-Repo'
    elif benchmark == 'RTL-Repo':
        metric = 'Exact Matching (EM)'
    return benchmark, metric

def filter_RTLRepo(subset: pd.DataFrame) -> pd.DataFrame:
    details = subset[['Model', 'Model URL', 'Model Type', 'Params']].drop_duplicates('Model')
    filtered_df = subset[['Model', 'Score']].rename(columns={'Score': 'Exact Matching (EM)'})
    filtered_df = pd.merge(filtered_df, details, on='Model', how='left')
    filtered_df['Model'] = filtered_df.apply(lambda row: model_hyperlink(row["Model URL"], row["Model"]), axis=1)
    filtered_df['Type'] = filtered_df['Model Type'].map(lambda x: type_emoji.get(x, ""))
    filtered_df = filtered_df[['Type', 'Model', 'Params', 'Exact Matching (EM)']]
    filtered_df = filtered_df.sort_values(by='Exact Matching (EM)', ascending=False).reset_index(drop=True)
    # filtered_df.insert(0, '', range(1, len(filtered_df) + 1))
    return filtered_df

def filter_bench(subset: pd.DataFrame) -> pd.DataFrame:
    details = subset[['Model', 'Model URL', 'Model Type', 'Params']].drop_duplicates('Model')
    pivot_df = subset.pivot_table(index='Model', columns='Metric', values='Score', aggfunc='mean').reset_index()
    pivot_df['Average ⬆️'] = pivot_df.mean(axis=1, numeric_only=True).round(2)
    pivot_df = pd.merge(pivot_df, details, on='Model', how='left')
    pivot_df['Model'] = pivot_df.apply(lambda row: model_hyperlink(row["Model URL"], row["Model"]), axis=1)
    pivot_df['Type'] = pivot_df['Model Type'].map(lambda x: type_emoji.get(x, ""))
    pivot_df.rename(columns={'Syntax (STX)': 'STX', 'Functionality (FNC)': 'FNC', 'Synthesis (SYN)': 'SYN', 'Performance': 'Perf'}, inplace=True)
    columns_order = ['Type', 'Model', 'Params', 'Average ⬆️', 'STX', 'FNC', 'SYN', 'Power', 'Perf', 'Area']
    pivot_df = pivot_df[[col for col in columns_order if col in pivot_df.columns]]
    pivot_df = pivot_df.sort_values(by='Average ⬆️', ascending=False).reset_index(drop=True)
    # pivot_df.insert(0, '', range(1, len(pivot_df) + 1))
    return pivot_df

def filter_bench_all(subset: pd.DataFrame) -> pd.DataFrame:
    details = subset[['Model', 'Model URL', 'Model Type', 'Params']].drop_duplicates('Model')
    pivot_df = subset.pivot_table(index='Model', columns='Metric', values='Score', aggfunc='mean').reset_index().round(2)
    pivot_df['Average ⬆️'] = pivot_df.mean(axis=1, numeric_only=True).round(2)
    pivot_df = pd.merge(pivot_df, details, on='Model', how='left')
    pivot_df['Model'] = pivot_df.apply(lambda row: model_hyperlink(row["Model URL"], row["Model"]), axis=1)
    pivot_df['Type'] = pivot_df['Model Type'].map(lambda x: type_emoji.get(x, ""))
    pivot_df.rename(columns={
        'Exact Matching (EM)': 'EM', 
        'Syntax (STX)': 'Avg STX', 
        'Functionality (FNC)': 'Avg FNC', 
        'Synthesis (SYN)': 'Avg SYN', 
        'Power': 'Avg Power',
        'Performance': 'Avg Perf',
        'Area': 'Avg Area',
    }, inplace=True)
    # columns_order = ['Type', 'Model', 'Params', 'Average ⬆️', 'Avg STX', 'Avg FNC', 'Avg SYN', 'Avg Power', 'Avg Perf', 'Avg Area']
    columns_order = ['Type', 'Model', 'Params', 'Average ⬆️', 'Avg STX', 'Avg FNC', 'Avg SYN', 'Avg Power', 'Avg Perf', 'Avg Area']
    pivot_df = pivot_df[[col for col in columns_order if col in pivot_df.columns]]
    pivot_df = pivot_df.sort_values(by='Average ⬆️', ascending=False).reset_index(drop=True)
    # pivot_df.insert(0, '', range(1, len(pivot_df) + 1))
    return pivot_df