[arch-commits] Commit in flatbuffers/trunk (PKGBUILD)
Chih-Hsuan Yen
yan12125 at gemini.archlinux.org
Mon Jun 6 16:22:31 UTC 2022
Date: Monday, June 6, 2022 @ 16:22:31
Author: yan12125
Revision: 1226803
upgpkg: flatbuffers 2.0.6-2; backport a fix for tensorflow lite compatibility
Apparently, tensorflow uses flatbuffers 1.x to generate Python codes
from flatbuffers schemes, and it's broken with flatbuffers 2.0.6. For
example, a code snippet from a tensorflow lite tutorial [1] fails with:
Traceback (most recent call last):
File "/home/yen/tmp/t.py", line 15, in <module>
tflite_model = converter.convert()
File "/usr/lib/python3.10/site-packages/tensorflow/lite/python/lite.py", line 929, in wrapper
return self._convert_and_export_metrics(convert_func, *args, **kwargs)
File "/usr/lib/python3.10/site-packages/tensorflow/lite/python/lite.py", line 921, in _convert_and_export_metrics
return flatbuffer_utils.convert_object_to_bytearray(model_object)
File "/usr/lib/python3.10/site-packages/tensorflow/lite/tools/flatbuffer_utils.py", line 84, in convert_object_to_bytearray
model_offset = model_object.Pack(builder)
File "/usr/lib/python3.10/site-packages/tensorflow/lite/python/schema_py_generated.py", line 5951, in Pack
operatorCodes = builder.EndVector(len(self.operatorCodes))
TypeError: Builder.EndVector() takes 1 positional argument but 2 were given
(There is another RuntimeError "Mismatching ReplicaContext", which
seems unrelated and harmless.)
As a side note, flatbuffers 2.x compatibility for tensorflow is tracked
in [2].
I've also re-enabled Python tests, which were disabled when switching
to out-of-source builds [3], as well as added a comment for broken C++
tests.
[1] https://www.tensorflow.org/lite/convert#convert_a_keras_model_
[2] https://github.com/tensorflow/tensorflow/issues/51487
[3] https://github.com/archlinux/svntogit-community/commit/b401e47cae6f0f9fb3fa0e75cabd5f55dca6b3b5
Modified:
flatbuffers/trunk/PKGBUILD
----------+
PKGBUILD | 21 +++++++++++++++++----
1 file changed, 17 insertions(+), 4 deletions(-)
Modified: PKGBUILD
===================================================================
--- PKGBUILD 2022-06-06 16:03:48 UTC (rev 1226802)
+++ PKGBUILD 2022-06-06 16:22:31 UTC (rev 1226803)
@@ -4,7 +4,7 @@
pkgbase=flatbuffers
pkgname=(flatbuffers python-flatbuffers)
pkgver=2.0.6
-pkgrel=1
+pkgrel=2
pkgdesc='An efficient cross platform serialization library for C++, with support for Java, C# and Go'
arch=(x86_64)
url='https://google.github.io/flatbuffers/'
@@ -11,11 +11,20 @@
license=(Apache)
depends=(gcc-libs)
makedepends=(cmake python-setuptools)
-source=(https://github.com/google/$pkgbase/archive/v$pkgver/$pkgbase-$pkgver.tar.gz)
-sha256sums=('e2dc24985a85b278dd06313481a9ca051d048f9474e0f199e372fea3ea4248c9')
+source=(https://github.com/google/$pkgbase/archive/v$pkgver/$pkgbase-$pkgver.tar.gz
+ $pkgbase-7426.patch::https://github.com/google/flatbuffers/commit/9d1ce9a10039416d98d3d88e029cb7b1931d1eed.patch)
+sha256sums=('e2dc24985a85b278dd06313481a9ca051d048f9474e0f199e372fea3ea4248c9'
+ 'e99a56fc20abf228651462063387e799628ee789afe7437a57706e574aff1da3')
prepare() {
sed -i 's/-Werror=/-W/g;s/-Werror//g' $pkgname-$pkgver/CMakeLists.txt
+
+ # Backport https://github.com/google/flatbuffers/pull/7246 (merged upstream)
+ cd $pkgbase-$pkgver
+ patch -Np1 -i ../$pkgbase-7426.patch
+
+ # Work-around missing out-of-source build support in Python tests
+ sed -i 's#${test_dir}/../flatc#${test_dir}/../../build/flatc#' tests/PythonTest.sh
}
build() {
@@ -31,7 +40,11 @@
}
check() {
- cmake --build build --target test || true # tests are broken
+ # tests are broken with out-of-source builds
+ # https://github.com/google/flatbuffers/issues/7282
+ cmake --build build --target test || true
+
+ ./$pkgbase-$pkgver/tests/PythonTest.sh
}
package_flatbuffers() {
More information about the arch-commits
mailing list