使用 bazel 运行选定的 TensorFlow 测试

seb*_*123 5 googletest bazel tensorflow

我想使用 bazel 运行 Tensor Flow 单元测试中选定的测试,但我无法获得足够好的粒度。

例如我有兴趣运行SessionClusterSpecPropagationTest.testFullDeviceNames测试//tensorflow/tools/graph_transforms:transform_graph_py_test

我发现到目前为止我可以运行bazel test -c opt //tensorflow/tools/graph_transforms:transform_graph_py_test,但不幸的是,这正在运行此 gtest 中的所有测试。

常规--gtest_filter不起作用。我也尝试过--test_filter=SessionClusterSpecPropagationTest.testFullDeviceNames,但我也无法运行单个测试。

有人可以建议如何正确运行它吗?

小智 0

您可以参考Tensorflow测试用例。这是最佳做法。您应该尝试运行bazel test来执行测试用例。

# All tests (for C++ changes).
$ bazel test //tensorflow/...

# All Python tests (for Python front-end changes).
$ bazel test //tensorflow/python/...

# All tests (with GPU support).
$ bazel test -c opt --config=cuda //tensorflow/...
$ bazel test -c opt --config=cuda //tensorflow/python/...
Run Code Online (Sandbox Code Playgroud)

更多参考:运行 Tensorflow 单元测试