convert.Query(
torch_trace="",
gpu_trace="",
gpu_trace_count=1
)
The main component of this library.
You can initialize an empty instance by not providing any argument, but it has to be initialized later by calling Query.init()
.
torch_trace
: str, path to the PyTorch trace file.gpu_trace
: str, path to the GPU trace file.gpu_trace_count
: int, number of iterations included in the GPU trace file.
An empty instance of the Query
class.
convert.Query.init(
torch_trace,
gpu_trace,
gpu_trace_count=1
)
Loads and analyzes the traces.
torch_trace
: str, path to the PyTorch trace file.gpu_trace
: str, path to the GPU trace file.gpu_trace_count
: int, number of iterations included in the GPU trace file.
An loaded instance of the Query
class.
convert.Query.loaded()
If the Query
class is loaded or not.
convert.Query.query(
func_name,
usage_query_type="KernelUsage",
time_query_type="RangeTime",
name_query_type="PreciseName"
)
Queries the specifies function, with selected usage calculation method and name matching method.
func_name
: str, the function name to query.usage_query_type
: str, method used to calculate the GPU usage sum. Can be"KernelUsage"
or"RangeUsage"
.time_query_type
: str, method used to calculate the time sum. Can be"KernelTime"
or"RangeTime"
.name_query_type
: str, name matching mathod. Can be"FuzzyName"
or"PreciseName"
.
The average GPU usage of matching functions, in float.
convert.Query.query_forward(
usage_query_type="KernelUsage",
time_query_type="RangeTime"
)
Queries the forward layer, with selected usage calculation method.
usage_query_type
: str, method used to calculate the GPU usage sum. Can be"KernelUsage"
or"RangeUsage"
.time_query_type
: str, method used to calculate the time sum. Can be"KernelTime"
or"RangeTime"
.
The average GPU usage of forward layer, in float.
convert.Query.query_backward(
usage_query_type="KernelUsage",
time_query_type="RangeTime"
)
Queries the backward layer, with selected usage calculation method.
usage_query_type
: str, method used to calculate the GPU usage sum. Can be"KernelUsage"
or"RangeUsage"
.time_query_type
: str, method used to calculate the time sum. Can be"KernelTime"
or"RangeTime"
.
The average GPU usage of backward layer, in float.
convert.Query.query_optimizer(
usage_query_type="KernelUsage",
time_query_type="RangeTime"
)
Queries the optimizer, with selected usage calculation method.
usage_query_type
: str, method used to calculate the GPU usage sum. Can be"KernelUsage"
or"RangeUsage"
.time_query_type
: str, method used to calculate the time sum. Can be"KernelTime"
or"RangeTime"
.
The average GPU usage of optimizer, in float.
convert.Query.query_modules(
module_name,
usage_query_type="KernelUsage",
time_query_type="RangeTime"
)
Queries the specified module, with selected usage calculation method.
modules_name
: str, the module name to query.usage_query_type
: str, method used to calculate the GPU usage sum. Can be"KernelUsage"
or"RangeUsage"
.time_query_type
: str, method used to calculate the time sum. Can be"KernelTime"
or"RangeTime"
.
The average GPU usage of the specified module, in float.
- Compile
CMakeLists.txt
mkdir build
cd build
cmake ..
make
cd ..
- Build Python package
python3 -m build --wheel