我如何 create/run 在 tensorflow 中对自定义内核进行基准测试?

How can I create/run benchmarks for custom kernels in tensorflow?

tensorflow 中已经有一些功能可以创建基准,例如可以在实际中看到这些基准 in the adjust contrast op benchmark。但是,如果我在我的机器上 运行 这个,我只会得到一个空输出:

panmari@dingle:~/tensorflow$ bazel run //tensorflow/core:kernels_adjust_contrast_op_benchmark_test --test_output=all --cache_test_results=no -- --benchmarks=1000
INFO: Found 1 target...
Target //tensorflow/core:kernels_adjust_contrast_op_benchmark_test up-to-date:
  bazel-bin/tensorflow/core/kernels_adjust_contrast_op_benchmark_test
INFO: Elapsed time: 10.736s, Critical Path: 8.71s.

INFO: Running command line: bazel-bin/tensorflow/core/kernels_adjust_contrast_op_benchmark_test '--benchmarks=1000'.
Running main() from test_main.cc
Benchmark    Time(ns) Iterations
--------------------------------

我的调用错了吗?

要调用基准测试,运行 以下命令(将 --benchmarks=all 作为最后一个参数传递):

$ bazel run -c opt //tensorflow/core:kernels_adjust_contrast_op_benchmark_test \
      --test_output=all --cache_test_results=no -- --benchmarks=all

要运行 GPU 基准测试,您必须将--config=cuda 传递给bazel 并将_gpu 附加到测试目标的名称。例如:

$ bazel run -c opt --config=cuda \ 
     //tensorflow/core:kernels_adjust_contrast_op_benchmark_test_gpu \
     --test_output=all --cache_test_results=no -- --benchmarks=all