AI: Build libtensorflow with --copt=-O2 instead of --copt=-O3 #222 #4922

This should optimize for fast execution as much as possible without
significantly increasing the binary size.

Signed-off-by: Michael Mayer <michael@photoprism.app>
This commit is contained in:
Michael Mayer
2025-04-06 09:25:20 +02:00
parent 5a9e3a8645
commit 0b9233f44b
2 changed files with 5 additions and 5 deletions

View File

@@ -7,14 +7,14 @@ download:
# Clang command line argument reference:
# https://clang.llvm.org/docs/ClangCommandLineReference.html#x86
libtensorflow:
bazel build -c opt //tensorflow:libtensorflow.so --copt=-O3 --copt=-mno-avx2 --copt=-mno-avx --copt=-march=core2
bazel build -c opt //tensorflow:libtensorflow.so --copt=-O2 --copt=-mno-avx2 --copt=-mno-avx --copt=-march=core2
./create_archive.sh amd64 $(TF_VERSION)
libtensorflow-avx:
bazel build -c opt //tensorflow:libtensorflow.so --copt=-O3 --copt=-mavx
bazel build -c opt //tensorflow:libtensorflow.so --copt=-O2 --copt=-mavx
./create_archive.sh amd64-avx $(TF_VERSION)
libtensorflow-avx2:
bazel build -c opt //tensorflow:libtensorflow.so --copt=-O3 --copt=-mavx2 --copt=-mfma --copt=-mfpmath=both --copt=-msse4.2
bazel build -c opt //tensorflow:libtensorflow.so --copt=-O2 --copt=-mavx2 --copt=-mfma --copt=-mfpmath=both --copt=-msse4.2
./create_archive.sh amd64-avx2 $(TF_VERSION)
libtensorflow-vnni:
bazel build -c opt //tensorflow:libtensorflow.so --copt=-O3 --copt=-mavx2 --copt=-mavxvnni --copt=-mfma --copt=-mfpmath=both --copt=-msse4.2
bazel build -c opt //tensorflow:libtensorflow.so --copt=-O2 --copt=-mavx2 --copt=-mavxvnni --copt=-mfma --copt=-mfpmath=both --copt=-msse4.2
./create_archive.sh amd64-vnni $(TF_VERSION)

View File

@@ -7,5 +7,5 @@ download:
# Clang command line argument reference:
# https://clang.llvm.org/docs/ClangCommandLineReference.html#aarch64
libtensorflow:
bazel build -c opt //tensorflow:libtensorflow.so --copt=-march=armv8-a
bazel build -c opt //tensorflow:libtensorflow.so --copt=-O2 --copt=-march=armv8-a
./create_archive.sh arm64 $(TF_VERSION)