运行 TensorFlow 测试时 Bazel 中的优化标志

Optimization flags in Bazel while running TensorFlow Tests

虽然 运行ning TensorFlow 使用 bazel test 命令进行测试,但我可以看到一些测试由于断言错误(与预期容差的轻微偏差)而失败,当 运行 时通过-c dbg如下:

bazel test -c dbg //tensorflow/python:training_ops_test

然而,这失败了:

bazel test -c opt //tensorflow/python:training_ops_test
bazel test //tensorflow/python:training_ops_test

因此,根据 Bazel,--compilation_mode [-c] 可以是 fastbuild、dbg 或 opt;默认值:"fastbuild".

opt or fastbuild 模式是否会在少数平台上出现 return 意外结果?

dbgoptfastbuild 将不同的选项传递给 C++ 编译器。您可以通过查看 CROSSTOOL 的 dbg and opt 部分来准确了解哪些选项。

我猜您看到的失败只是基于编译模式中不同级别的优化导致的代码生成差异。 This question 很好地概述了优化和非优化构建之间的一些差异。 (它特别适用于 Windows,但适用于所有系统的编译器优化。)