mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-06 12:20:52 +01:00
Make speed_benchmark_torch report latency in us (#37953)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/37953 Earlier it said us but reported ms. Test Plan: buck run aibench:run_bench -- -b aibench/specifications/models/pytorch/fbnet/fbnet_mobile_inference.json --devices s9u --remote --framework pytorch --logger_level info --job_queue aibench_interactive --platform android/full_jit Reviewed By: xcheng16 Differential Revision: D21349612 fbshipit-source-id: b97b6216eb0264123ff2c7852a0678b2008b0bf1
This commit is contained in:
parent
85fccba224
commit
dd64d26d74
|
|
@ -211,23 +211,23 @@ int main(int argc, char** argv) {
|
||||||
".");
|
".");
|
||||||
caffe2::Timer timer;
|
caffe2::Timer timer;
|
||||||
std::vector<float> times;
|
std::vector<float> times;
|
||||||
auto millis = timer.MilliSeconds();
|
auto micros = timer.MicroSeconds();
|
||||||
for (int i = 0; i < FLAGS_iter; ++i) {
|
for (int i = 0; i < FLAGS_iter; ++i) {
|
||||||
auto start = high_resolution_clock::now();
|
auto start = high_resolution_clock::now();
|
||||||
module.forward(inputs);
|
module.forward(inputs);
|
||||||
auto stop = high_resolution_clock::now();
|
auto stop = high_resolution_clock::now();
|
||||||
auto duration = duration_cast<milliseconds>(stop - start);
|
auto duration = duration_cast<microseconds>(stop - start);
|
||||||
times.push_back(duration.count());
|
times.push_back(duration.count());
|
||||||
}
|
}
|
||||||
millis = timer.MilliSeconds();
|
micros = timer.MicroSeconds();
|
||||||
if (FLAGS_report_pep) {
|
if (FLAGS_report_pep) {
|
||||||
for (auto t : times) {
|
for (auto t : times) {
|
||||||
std::cout << "PyTorchObserver {\"type\": \"NET\", \"unit\": \"us\", \"metric\": \"latency\", \"value\": \"" << t << "\"}" << std::endl;
|
std::cout << "PyTorchObserver {\"type\": \"NET\", \"unit\": \"us\", \"metric\": \"latency\", \"value\": \"" << t << "\"}" << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
std::cout << "Main run finished. Milliseconds per iter: "
|
std::cout << "Main run finished. Microseconds per iter: "
|
||||||
<< millis / FLAGS_iter
|
<< micros / FLAGS_iter
|
||||||
<< ". Iters per second: " << 1000.0 * FLAGS_iter / millis
|
<< ". Iters per second: " << 1000.0 * 1000 * FLAGS_iter / micros
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user