mirror of
https://github.com/pytorch/pytorch.git
synced 2025-11-05 08:24:57 +08:00
net benchmark code
This commit is contained in:
@ -87,17 +87,31 @@ void SimpleNet::TEST_Benchmark(const int warmup_runs, const int main_runs,
|
|||||||
CAFFE_LOG_INFO << "Main run finished. Milliseconds per iter: "
|
CAFFE_LOG_INFO << "Main run finished. Milliseconds per iter: "
|
||||||
<< timer.MilliSeconds() / main_runs;
|
<< timer.MilliSeconds() / main_runs;
|
||||||
int idx = 0;
|
int idx = 0;
|
||||||
|
float total = 0.;
|
||||||
|
CaffeMap<string, float> time_per_op_type;
|
||||||
if (run_individual) {
|
if (run_individual) {
|
||||||
for (auto& op : operators_) {
|
for (auto& op : operators_) {
|
||||||
|
const string& op_type = op->def().type();
|
||||||
CAFFE_LOG_INFO << "Running operator #" << idx << " ("
|
CAFFE_LOG_INFO << "Running operator #" << idx << " ("
|
||||||
<< op->def().name() << ", " << op->def().type()
|
<< op->def().name() << ", " << op_type << ")";
|
||||||
<< ")";
|
|
||||||
timer.Start();
|
timer.Start();
|
||||||
for (int i = 0; i < main_runs; ++i) {
|
for (int i = 0; i < main_runs; ++i) {
|
||||||
CAFFE_CHECK(op->Run());
|
CAFFE_CHECK(op->Run());
|
||||||
}
|
}
|
||||||
|
float spent = timer.MilliSeconds() / main_runs;
|
||||||
|
total += spent;
|
||||||
CAFFE_LOG_INFO << " Finished. Milliseconds per iter: "
|
CAFFE_LOG_INFO << " Finished. Milliseconds per iter: "
|
||||||
<< timer.MilliSeconds() / main_runs;
|
<< spent;
|
||||||
|
//if (time_per_op_type.count(op_type) == 0) {
|
||||||
|
// time_per_op_type[op_type] = 0.;
|
||||||
|
//}
|
||||||
|
time_per_op_type[op_type] += spent;
|
||||||
|
++idx;
|
||||||
|
}
|
||||||
|
CAFFE_LOG_INFO << "Per-op run total: " << total;
|
||||||
|
CAFFE_LOG_INFO << "Time per operator type:";
|
||||||
|
for (const auto& item : time_per_op_type) {
|
||||||
|
CAFFE_LOG_INFO << "\t" << item.second << "\t" << item.first;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user