我想测量每个函数所花费的时间。所以我修改了tensorflow/core/kernel/conv_ops.cc,如下所示。
....
#include <ctime>
....
void Compute(OpKernelContext* context) override {
// Input tensor is of the following dimensions:
// [ batch, in_rows, in_cols, in_depth ]
std::clock_t start;
double duration;
....
....
....
duration = (std::clock() - start) / (double) CLOCKS_PER_SEC;
std::cout<<"============== conv time : "<<duration<<std::endl;
}
....
....保存了这段代码(:wq)后,我运行了一个简单的cnn tensorflow代码。但是我添加的代码不起作用(它不显示'cout‘结果。)
如何显示计时结果?
发布于 2018-10-03 21:57:03
使用conv_ops.cc.It从源代码重新编译整个tensorflow项目,从bazel生成的gen_nn_ops.py文件可能会起作用。
https://stackoverflow.com/questions/42848041
复制相似问题