Use radio
Browse files
app.py
CHANGED
|
@@ -140,12 +140,13 @@ BENCHMARK_DATA = {
|
|
| 140 |
}
|
| 141 |
|
| 142 |
|
| 143 |
-
def get_plot(model_name, generate_type):
|
| 144 |
df = pd.DataFrame(BENCHMARK_DATA[generate_type][model_name])
|
| 145 |
df["framework"] = ["PyTorch", "TF (Eager Execition)", "TF (XLA)"]
|
| 146 |
df = pd.melt(df, id_vars=["framework"], value_vars=["T4", "3090", "A100"])
|
|
|
|
|
|
|
| 147 |
|
| 148 |
-
# fig = plt.figure(figsize=(100, 6), dpi=200)
|
| 149 |
g = sns.catplot(
|
| 150 |
data=df, kind="bar",
|
| 151 |
x="variable", y="value", hue="framework",
|
|
@@ -171,9 +172,9 @@ with demo:
|
|
| 171 |
with gr.TabItem("Greedy Search"):
|
| 172 |
gr.Markdown(
|
| 173 |
"""
|
| 174 |
-
### Greedy Search parameters
|
| 175 |
- `max_new_tokens = 64`;
|
| 176 |
-
- `
|
| 177 |
"""
|
| 178 |
)
|
| 179 |
with gr.Row():
|
|
@@ -183,10 +184,15 @@ with demo:
|
|
| 183 |
label="Model",
|
| 184 |
interactive=True,
|
| 185 |
)
|
| 186 |
-
eager_enabler = gr.Radio(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 187 |
plot_fn = functools.partial(get_plot, generate_type="Greedy Search")
|
| 188 |
plot = gr.Plot(value=plot_fn("T5 Small")) # Show plot when the gradio app is initialized
|
| 189 |
-
model_selector.change(fn=plot_fn, inputs=model_selector, outputs=plot)
|
| 190 |
with gr.TabItem("Sample"):
|
| 191 |
gr.Button("New Tiger")
|
| 192 |
with gr.TabItem("Beam Search"):
|
|
|
|
| 140 |
}
|
| 141 |
|
| 142 |
|
| 143 |
+
def get_plot(model_name, plot_eager, generate_type):
|
| 144 |
df = pd.DataFrame(BENCHMARK_DATA[generate_type][model_name])
|
| 145 |
df["framework"] = ["PyTorch", "TF (Eager Execition)", "TF (XLA)"]
|
| 146 |
df = pd.melt(df, id_vars=["framework"], value_vars=["T4", "3090", "A100"])
|
| 147 |
+
if plot_eager == "No":
|
| 148 |
+
df = df[df["framework"] != "TF (Eager Execition)"]
|
| 149 |
|
|
|
|
| 150 |
g = sns.catplot(
|
| 151 |
data=df, kind="bar",
|
| 152 |
x="variable", y="value", hue="framework",
|
|
|
|
| 172 |
with gr.TabItem("Greedy Search"):
|
| 173 |
gr.Markdown(
|
| 174 |
"""
|
| 175 |
+
### Greedy Search benchmark parameters
|
| 176 |
- `max_new_tokens = 64`;
|
| 177 |
+
- `pad_to_multiple_of = 64` for Tensorflow XLA models. Others do not pad (input prompts between 2 and 33 tokens).
|
| 178 |
"""
|
| 179 |
)
|
| 180 |
with gr.Row():
|
|
|
|
| 184 |
label="Model",
|
| 185 |
interactive=True,
|
| 186 |
)
|
| 187 |
+
eager_enabler = gr.Radio(
|
| 188 |
+
["Yes", "No"],
|
| 189 |
+
value="Yes",
|
| 190 |
+
label="Plot TF Eager Execution?",
|
| 191 |
+
interactive=True
|
| 192 |
+
)
|
| 193 |
plot_fn = functools.partial(get_plot, generate_type="Greedy Search")
|
| 194 |
plot = gr.Plot(value=plot_fn("T5 Small")) # Show plot when the gradio app is initialized
|
| 195 |
+
model_selector.change(fn=plot_fn, inputs=[model_selector, eager_enabler], outputs=plot)
|
| 196 |
with gr.TabItem("Sample"):
|
| 197 |
gr.Button("New Tiger")
|
| 198 |
with gr.TabItem("Beam Search"):
|