Fix segfaults in benchmark binaries when setting num_threads > 1 #727
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What do these changes do?
The LCE benchmark binaries would often (not always though) segfault when running with more than 1 thread. This was the case both on aarch64 and on x86, and both for BNNs and for regular INT8 networks. However, this issue was only present in the Bazel versions of the binaries and not with the (recently added) CMake versions. That suggested something was wrong in the build scripts and not in the code itself.
This PR changes the Bazel linking settings for the benchmark binaries such that they are in-line with what is done inside TensorFlow itself: https://github.com/tensorflow/tensorflow/blob/master/tensorflow/lite/tools/benchmark/BUILD#L33-L40. With these changes, I could no longer reproduce the segfaults.
How Has This Been Tested?
By running the new benchmark binaries on both x86 and aarch64 a couple of times (with a large number of runs to be sure), with and without XNNPack, e.g.:
bazel-bin/larq_compute_engine/tflite/benchmark/lce_benchmark_model --graph=MobileNetV1_INT8.tflite --num_threads=4 --use_xnnpack=true --num_runs=5000
Benchmark Results
Unchanged.
Related issue number
N/A.