/usr/local/lib64/python3.6/site-packages/torch/utils/benchmark/utils
Edit: /usr/local/lib64/python3.6/site-packages/torch/utils/benchmark/utils/timeit_template.cpp (1017B)
/* C++ template for Timer.timeit
This template will be consumed by `cpp_jit.py`, and will replace:
`GLOBAL_SETUP_TEMPLATE_LOCATION`,
`SETUP_TEMPLATE_LOCATION`
and
`STMT_TEMPLATE_LOCATION`
sections with user provided statements.
*/
#include
#include
#include
#include
#include
// Global setup. (e.g. #includes)
// GLOBAL_SETUP_TEMPLATE_LOCATION
double timeit(int n) {
pybind11::gil_scoped_release no_gil;
// Setup
// SETUP_TEMPLATE_LOCATION
{
// Warmup
// STMT_TEMPLATE_LOCATION
}
// Main loop
auto start_time = std::chrono::high_resolution_clock::now();
for(const auto loop_idx : c10::irange(n)) {
// STMT_TEMPLATE_LOCATION
}
auto end_time = std::chrono::high_resolution_clock::now();
return std::chrono::duration(end_time - start_time).count();
}
PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) {
m.def("timeit", &timeit);
}