Skip to content
Snippets Groups Projects
Commit c1dd30aa authored by Yifan Zhao's avatar Yifan Zhao
Browse files

Added documentation for predtuner and hpvm-profiler

parent 01354398
No related branches found
No related tags found
No related merge requests found
HPVM Profiler API
======================
.. autofunction:: hpvm_profiler.profile_configs
.. autofunction:: hpvm_profiler.plot_hpvm_configs
......@@ -28,3 +28,5 @@ which explains their role, usage, and other details.
keras-frontend
keras-benchmarks
torch2hpvm
predtuner
hpvm-profiler
../../projects/predtuner/README.rst
\ No newline at end of file
from dataclasses import dataclass
from pathlib import Path
from subprocess import CalledProcessError, PIPE
from subprocess import PIPE, CalledProcessError
from typing import Iterable, List, Tuple, Union
from dataclasses import dataclass
import matplotlib.pyplot as plt
from tqdm import trange
PathLike = Union[Path, str]
......@@ -14,25 +16,20 @@ def profile_configs(
output_config_path: PathLike,
profile_filename: str = "profile_info.txt",
qos_filename: str = "final_accuracy",
):
) -> None:
"""
Profile an HPVM configuration file with an HPVM binary.
The configuration file must have the baseline as the first configuration.
binary_path: Union[Path, str]
Path to binary to be executed in profiling.
config_path: Union[Path, str]
Path to config file (HPVM configuration format)
binary_path: Path to binary to be executed in profiling.
config_path: Path to config file (HPVM configuration format)
with configs to enumerate for profiling.
output_config_path: Union[Path, str]
Path where the output configs are written.
output_config_path: Path where the output configs are written.
The output config file has the same configs as the input `config_path` file,
but the performance and energy readings are updated.
profile_filename: str
Name of profile file generated by the binary (in current directory).
profile_filename: Name of profile file generated by the binary (in current directory).
This defaults to "profile_info.txt" and should not be changed for HPVM binaries.
qos_filename: str
Name of QoS file generated by the binary (in current directory).
qos_filename: Name of QoS file generated by the binary (in current directory).
It contains a single float number as the QoS of this run.
This defaults to "final_accuracy" and should not be changed for HPVM binaries.
"""
......@@ -76,26 +73,21 @@ def plot_hpvm_configs(
save_to: PathLike = None,
show_qos_loss: bool = True,
**fig_kwargs,
):
) -> plt.Figure:
"""
Plot the QoS-speedup information in an HPVM configuration file.
It is recommended to profile the config file first (using `profile_configs`)
to obtain real speedup numbers.
This function creates a `matplotlib.pyplot.Figure`, plots on it, and returns it.
config_path: Union[Path, str]
Path to the config file (HPVM configuration format).
save_to: Union[Path, str]
File to save figure into. Default is None: don't save figure (just return it).
show_qos_loss: bool
Show the loss of QoS on x axis of the figure. Defaults to True.
config_path: Path to the config file (HPVM configuration format).
save_to: File to save figure into. Default is None: don't save figure (just return it).
show_qos_loss: Show the loss of QoS on x axis of the figure. Defaults to True.
If False, will use (absolute) QoS instead of QoS loss.
fig_kwargs:
Arguments to pass to `plt.subplots`.
fig_kwargs: Arguments to pass to `plt.subplots`.
"""
import numpy as np
import matplotlib.pyplot as plt
_, configs = read_hpvm_configs(config_path)
get_qos = lambda c: c.qos_loss if show_qos_loss else c.qos
......@@ -109,6 +101,7 @@ def plot_hpvm_configs(
fig.savefig(save_to, dpi=300)
return fig
@dataclass
class Config:
conf_name: str
......
Subproject commit 2fbd6f876c34bfdbcbddc71cd73646e71bde5748
Subproject commit aa28a41ca12b15af31e1d15b687367e27cde3878
PyTorch Frontend for HPVM
=========================
``torch2hpvm`` is a PyTorch frontend for HPVM. It provides a set of API that
* Generates a PyTorch ``module`` into HPVM-C code;
* Exports a PyTorch dataset to ApproxHPVM dataset format;
* Compiles the generated code into binary by invoking HPVM automatically.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment