【发布时间】:2017-03-17 02:13:59
【问题描述】:
我想测量每个函数所花费的时间。 所以我修改了 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”结果。)。
如何显示计时结果?
【问题讨论】:
-
你有
#include <iostream>吗? -
我已经测试了一个用户定义的操作(hear)但是在这段代码中,我只添加了'#include
'并且效果很好。 -
你可能需要重新编译 tensorflow?
-
我可以在同一个目录中使用'cc -c conv_ops.cc'吗...?
-
编译 conv_ops.cc 不会将其链接到库。尝试重新编译 tensorflow,看看发生了什么
标签: c++ tensorflow