diff options
81 files changed, 2506 insertions, 1346 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c01df45 --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +*.pyc +*.pyo +/*.patch +*.swp +*.orig +*.rej +*~ @@ -17,7 +17,7 @@ $ . <ts-project>/oe-core/oe-init-build-env <build> # Build qemux86-64 which runqemu supports kvm. $ echo 'MACHINE = "qemux86-64"' >> conf/local.conf -$ echo 'IMAGE_INSTALL_append = " tensorflow"' >> conf/local.conf +$ echo 'IMAGE_INSTALL:append = " tensorflow"' >> conf/local.conf Edit conf/bblayers.conf to include other layers BBLAYERS ?= " \ @@ -41,75 +41,88 @@ $ runqemu qemux86-64 core-image-minimal slirp kvm qemuparams="-m 5120" ## 5. Verify the install ``` -root@qemux86-64:~# python3 -c "import tensorflow as tf; tf.enable_eager_execution(); print(tf.reduce_sum(tf.random_normal([1000, 1000])))" -tf.Tensor(-604.65454, shape=(), dtype=float32) +root@qemux86-64:~# python3 -c "import tensorflow as tf;print(tf.reduce_sum(tf.random.normal([1000, 1000])))" +tf.Tensor(-3304.6208, shape=(), dtype=float32) ``` ## 6. Run tutorial case ### Refer: https://www.tensorflow.org/tutorials ``` -root@qemux86-64:~# cat >code.py <<ENDOF +root@qemux86-64:~# cat >code-v2.py <<ENDOF import tensorflow as tf mnist = tf.keras.datasets.mnist -(x_train, y_train),(x_test, y_test) = mnist.load_data() +(x_train, y_train), (x_test, y_test) = mnist.load_data() x_train, x_test = x_train / 255.0, x_test / 255.0 model = tf.keras.models.Sequential([ tf.keras.layers.Flatten(input_shape=(28, 28)), - tf.keras.layers.Dense(512, activation=tf.nn.relu), + tf.keras.layers.Dense(128, activation='relu'), tf.keras.layers.Dropout(0.2), - tf.keras.layers.Dense(10, activation=tf.nn.softmax) + tf.keras.layers.Dense(10) ]) + +predictions = model(x_train[:1]).numpy() +tf.nn.softmax(predictions).numpy() +loss_fn = tf.keras.losses.SparseCategoricalCrossentropy(from_logits=True) +loss_fn(y_train[:1], predictions).numpy() + model.compile(optimizer='adam', - loss='sparse_categorical_crossentropy', + loss=loss_fn, metrics=['accuracy']) - model.fit(x_train, y_train, epochs=5) -model.evaluate(x_test, y_test) +model.evaluate(x_test, y_test, verbose=2) + +probability_model = tf.keras.Sequential([ + model, + tf.keras.layers.Softmax() +]) +probability_model(x_test[:5]) + + ENDOF -root@qemux86-64:~# python3 ./code.py -Downloading data from https://storage.googleapis.com/tensorflow/tf-keras-datasets/mnist.npz -11493376/11490434 [==============================] - 7s 1us/step -Instructions for updating: -Colocations handled automatically by placer. -Instructions for updating: -Please use `rate` instead of `keep_prob`. Rate should be set to `rate = 1 - keep_prob`. +root@qemux86-64:~# python3 ./code-v2.py +2020-12-15 08:16:44.171593: I tensorflow/compiler/mlir/mlir_graph_optimization_pass.cc:116] None of the MLIR optimization passes are enabled (registered 2) +2020-12-15 08:16:44.184464: I tensorflow/core/platform/profile_utils/cpu_utils.cc:112] CPU Frequency: 3099995000 Hz Epoch 1/5 -60000/60000 [==============================] - 27s 449us/sample - loss: 0.2211 - acc: 0.9346 +1875/1875 [==============================] - 14s 7ms/step - loss: 0.4833 - accuracy: 0.8595 Epoch 2/5 -60000/60000 [==============================] - 24s 408us/sample - loss: 0.0969 - acc: 0.9702 +1875/1875 [==============================] - 13s 7ms/step - loss: 0.1549 - accuracy: 0.9558 Epoch 3/5 -60000/60000 [==============================] - 26s 439us/sample - loss: 0.0694 - acc: 0.9780 +1875/1875 [==============================] - 13s 7ms/step - loss: 0.1135 - accuracy: 0.9651 Epoch 4/5 -60000/60000 [==============================] - 23s 390us/sample - loss: 0.0540 - acc: 0.9832 +1875/1875 [==============================] - 13s 7ms/step - loss: 0.0889 - accuracy: 0.9729 Epoch 5/5 -60000/60000 [==============================] - 24s 399us/sample - loss: 0.0447 - acc: 0.9851 -10000/10000 [==============================] - 1s 91us/sample - loss: 0.0700 - acc: 0.9782 +1875/1875 [==============================] - 13s 7ms/step - loss: 0.0741 - accuracy: 0.9777 +313/313 - 1s - loss: 0.0757 - accuracy: 0.9757 ``` ## 7. TensorFlow/TensorFlow Lite C++ Image Recognition Demo ``` root@qemux86-64:~# time label_image -2019-03-06 06:08:51.076028: I tensorflow/examples/label_image/main.cc:251] military uniform (653): 0.834306 -2019-03-06 06:08:51.078221: I tensorflow/examples/label_image/main.cc:251] mortarboard (668): 0.0218695 -2019-03-06 06:08:51.080054: I tensorflow/examples/label_image/main.cc:251] academic gown (401): 0.010358 -2019-03-06 06:08:51.081943: I tensorflow/examples/label_image/main.cc:251] pickelhaube (716): 0.00800814 -2019-03-06 06:08:51.083830: I tensorflow/examples/label_image/main.cc:251] bulletproof vest (466): 0.00535084 -real 0m 10.50s -user 0m 3.95s -sys 0m 6.46s +2020-12-15 08:18:34.853885: I tensorflow/core/platform/profile_utils/cpu_utils.cc:112] CPU Frequency: 3099995000 Hz +2020-12-15 08:18:41.565167: I tensorflow/examples/label_image/main.cc:252] military uniform (653): 0.834306 +2020-12-15 08:18:41.567874: I tensorflow/examples/label_image/main.cc:252] mortarboard (668): 0.0218696 +2020-12-15 08:18:41.568936: I tensorflow/examples/label_image/main.cc:252] academic gown (401): 0.0103581 +2020-12-15 08:18:41.569985: I tensorflow/examples/label_image/main.cc:252] pickelhaube (716): 0.00800819 +2020-12-15 08:18:41.571025: I tensorflow/examples/label_image/main.cc:252] bulletproof vest (466): 0.00535086 + +real 0m7.178s +user 0m6.101s +sys 0m0.893s + root@qemux86-64:~# time label_image.lite -Loaded model /usr/share/label_image/mobilenet_v1_1.0_224_quant.tflite -resolved reporter -invoked -average time: 1064.8 ms -0.780392: 653 military uniform -0.105882: 907 Windsor tie -0.0156863: 458 bow tie -0.0117647: 466 bulletproof vest -0.00784314: 835 suit -real 0m 1.10s -user 0m 1.07s -sys 0m 0.02s +INFO: Loaded model /usr/share/label_image/mobilenet_v1_1.0_224_quant.tflite +INFO: resolved reporter +INFO: invoked +INFO: average time: 213.584 ms +INFO: 0.780392: 653 military uniform +INFO: 0.105882: 907 Windsor tie +INFO: 0.0156863: 458 bow tie +INFO: 0.0117647: 466 bulletproof vest +INFO: 0.00784314: 835 suit + +real 0m0.233s +user 0m0.216s +sys 0m0.012s ``` diff --git a/LIMITATION.md b/LIMITATION.md index deda0ad..1638241 100644 --- a/LIMITATION.md +++ b/LIMITATION.md @@ -1,21 +1,27 @@ # Limitation ``` -* Bazel build takes lots of time, since it like bitbake which has own rules - and builds everything from scratch. Currently bazel could not reuse Yocto - DEPENDS/RDEPENDS. +* Target arch only supports 64 bit arm and 64 bit x86. BSP (MACHINE) + incluced in above archs should be supported. + +* Bazel build takes lots of time, it has own rules and builds everything + from scratch. Currently bazel could not reuse Yocto DEPENDS/RDEPENDS. * In order to run tensorflow cases in a reasonable time, although it builds - successfully on qemuarm, qemuarm64, qemumips, qemumips64, qemux86 and - qemux86-64, only qemux86-64 with kvm for runtime test. + successfully on qemuarm, qemuarm64, qemux86 and qemux86-64, only qemux86-64 + with kvm for runtime test. -* It failed to use pre-build model to do predict/inference on big-endian platform - (such as qemumips), since upstream does not support big-endian very well +* It failed to use pre-build model to do predict/inference on big-endian + platform, since upstream does not support big-endian very well https://github.com/tensorflow/tensorflow/issues/16364 -* Do not support 32-bit powerpc (qemuppc) since BoringSSL does not support it. - (BoringSSL is a fork of OpenSSL used to implement cryptography and TLS across - most of Google's products) - * If host(build system) is not x86_64, please add meta-java to BBLAYERS in conf/bblayers.conf (git://git.yoctoproject.org/meta-java) + +* Due to tensorflow build requires lots of CPU and Memory, in order to + avoid out of memory issue, explicitly set the number of local CPU + threads available to 25% of total number of local CPU cores and + the amount of local host RAM (in MB) available to 25% of total amount + of local host RAM by default. If host is powerful enough, adjust BAZEL_JOBS + and BAZEL_MEM in local.conf to override default set. If set BAZEL_JOBS = "" + and BAZEL_MEM = "", there will be no limitation on the available CPU and RAM. ``` @@ -40,17 +40,6 @@ Wind River Linux (CI/CD branch) ## Installation [Build and Run](https://github.com/Wind-River/meta-tensorflow/blob/master/BUILD.md) -## Demo 1. Facial recognition -### 1.1 Based on Yocto -[Face recognition on Yocto](https://github.com/Wind-River/meta-tensorflow/blob/master/meta-demo/README.md) - -### 1.2 Based on Wind River Linux -[Face recognition on Wind River Linux](https://github.com/Wind-River/meta-tensorflow/blob/master/meta-demo/README-wrl.md) ->![picture](https://github.com/Wind-River/meta-tensorflow/blob/master/meta-demo/files/tensorflow-demo.gif) - -## Demo 2. [Neural Machine Translation](https://github.com/Wind-River/meta-tensorflow/blob/master/meta-demo/recipes-demo/nmt/README-nmt.md) - -## Demo 3. [Minigo: A minimalist Go engine modeled after AlphaGo Zero](https://github.com/Wind-River/meta-tensorflow/blob/master/meta-demo/recipes-demo/minigo/README.md) ## Project License ``` @@ -2,5 +2,3 @@ Future plan ----------- - Introduce more machine learning cases to meta-tensorflow. -- Recipe maintenance and upgrade - diff --git a/classes/bazel-base.bbclass b/classes/bazel-base.bbclass new file mode 100644 index 0000000..8d90e9b --- /dev/null +++ b/classes/bazel-base.bbclass @@ -0,0 +1,13 @@ +export JAVA_HOME="${STAGING_LIBDIR_NATIVE}/jvm/openjdk-11-native" + +# %25 of total number of local CPU cores +BAZEL_JOBS ??= "HOST_CPUS*.25" + +# 25% of total amount of local host RAM +BAZEL_MEM ??= "HOST_RAM*.25" + +TS_DL_DIR ??= "${DL_DIR}" + +CCACHE_DISABLE = "1" + +export HOSTTOOLS_DIR diff --git a/classes/bazel.bbclass b/classes/bazel.bbclass index 7b318cb..59b78e1 100644 --- a/classes/bazel.bbclass +++ b/classes/bazel.bbclass @@ -1,102 +1,165 @@ DEPENDS += "bazel-native \ - openjdk-8-native \ + openjdk-11-native \ " -DEPENDS_append_class-target = " python3" +DEPENDS:append:class-target = " python3" + +inherit bazel-base BAZEL_DIR ?= "${WORKDIR}/bazel" BAZEL_OUTPUTBASE_DIR ?= "${BAZEL_DIR}/output_base" -export BAZEL_ARGS="--output_user_root=${BAZEL_DIR}/user_root \ +export USER="unused-bazel-user" +export BAZEL_STARTUP_OPTIONS="--output_user_root=${BAZEL_DIR}/user_root \ --output_base=${BAZEL_OUTPUTBASE_DIR} \ --bazelrc=${S}/bazelrc \ + --batch \ " -export JAVA_HOME="${STAGING_LIBDIR_NATIVE}/jvm/openjdk-8-native" - BAZEL ?= "${BAZEL_DIR}/bazel" do_prepare_recipe_sysroot[postfuncs] += "do_install_bazel" do_install_bazel() { mkdir -p ${BAZEL_DIR} install -m 0755 ${STAGING_BINDIR_NATIVE}/bazel ${BAZEL_DIR} - create_cmdline_wrapper ${BAZEL} \$BAZEL_ARGS + create_cmdline_wrapper ${BAZEL} \$BAZEL_STARTUP_OPTIONS zip -A ${BAZEL}.real } -def bazel_get_flags(d): +def bazel_get_target_flags(d): flags = "" for i in d.getVar("CC").split()[1:]: - flags += "--conlyopt=%s --cxxopt=%s --linkopt=%s " % (i, i, i) + flags += "# From CC\n" + flags += "build --conlyopt=%s --cxxopt=%s --linkopt=%s\n" % (i, i, i) for i in d.getVar("CFLAGS").split(): if i == "-g": continue - flags += "--conlyopt=%s " % i + flags += "# From CFLAGS\n" + flags += "build --conlyopt=%s\n" % i for i in d.getVar("BUILD_CFLAGS").split(): - flags += "--host_conlyopt=%s " % i + flags += "# From BUILD_CFLAGS\n" + flags += "build --host_conlyopt=%s\n" % i for i in d.getVar("CXXFLAGS").split(): if i == "-g": continue - flags += "--cxxopt=%s " % i + flags += "# From CXXFLAGS\n" + flags += "build --cxxopt=%s\n" % i for i in d.getVar("BUILD_CXXFLAGS").split(): - flags += "--host_cxxopt=%s " % i + flags += "# From BUILD_CXXFLAGS\n" + flags += "build --host_cxxopt=%s\n" % i for i in d.getVar("CPPFLAGS").split(): if i == "-g": continue - flags += "--conlyopt=%s --cxxopt=%s " % (i, i) + flags += "# From CPPFLAGS\n" + flags += "build --conlyopt=%s --cxxopt=%s\n" % (i, i) for i in d.getVar("BUILD_CPPFLAGS").split(): - flags += "--host_conlyopt=%s --host_cxxopt=%s " % (i, i) + flags += "# From BUILD_CPPFLAGS\n" + flags += "build --host_conlyopt=%s --host_cxxopt=%s\n" % (i, i) for i in d.getVar("LDFLAGS").split(): if i == "-Wl,--as-needed": continue - flags += "--linkopt=%s " % i + flags += "# From LDFLAGS\n" + flags += "build --linkopt=%s\n" % i for i in d.getVar("BUILD_LDFLAGS").split(): if i == "-Wl,--as-needed": continue - flags += "--host_linkopt=%s " % i + flags += "# From BUILD_LDFLAGS\n" + flags += "build --host_linkopt=%s\n" % i for i in d.getVar("TOOLCHAIN_OPTIONS").split(): if i == "-Wl,--as-needed": continue - flags += "--linkopt=%s " % i + flags += "# From TOOLCHAIN_OPTIONS\n" + flags += "build --linkopt=%s\n" % i + + return flags + +def bazel_get_flags(d): + flags = "" + + if d.getVar("BAZEL_JOBS"): + flags += "# From BAZEL_JOBS\n" + flags += "build --jobs=%s --local_cpu_resources=%s\n" % (d.getVar("BAZEL_JOBS"), d.getVar("BAZEL_JOBS")) + + if d.getVar("BAZEL_MEM"): + flags += "# From BAZEL_MEM\n" + flags += "build --local_ram_resources=%s\n" % (d.getVar("BAZEL_MEM")) return flags -TS_DL_DIR ??= "${DL_DIR}" bazel_do_configure () { cat > "${S}/bazelrc" <<-EOF build --verbose_failures build --spawn_strategy=standalone --genrule_strategy=standalone -build --jobs=${@oe.utils.cpu_count()} test --verbose_failures --verbose_test_summary test --spawn_strategy=standalone --genrule_strategy=standalone -build --linkopt=-Wl,-latomic build --linkopt=-Wl,--no-as-needed build --host_linkopt=-Wl,--no-as-needed +build --host_conlyopt=-D_PYTHON_INCLUDE_NATIVE --host_cxxopt=-D_PYTHON_INCLUDE_NATIVE +build --conlyopt=-D_PYTHON_INCLUDE_TARGET --cxxopt=-D_PYTHON_INCLUDE_TARGET + build --strip=never +build --python_path=python3 + fetch --distdir=${TS_DL_DIR} build --distdir=${TS_DL_DIR} +${@bazel_get_flags(d)} + EOF } -bazel_do_configure_append_class-target () { +bazel_do_configure:append:class-target () { cat >> "${S}/bazelrc" <<-EOF -# FLAGS -build ${@bazel_get_flags(d)} +# FLAGS begin +${@bazel_get_target_flags(d)} +# FLAGS end + EOF sed -i "s:${WORKDIR}:${BAZEL_OUTPUTBASE_DIR}/external/yocto_compiler:g" ${S}/bazelrc + + # Unzip bazel packages + ${BAZEL} ${BAZEL_STARTUP_OPTIONS} version + + for binary in build-runfiles daemonize linux-sandbox process-wrapper; do + # Modify interpreter for bazel built-in binaries + patchelf-uninative --set-interpreter "${UNINATIVE_LOADER}" ${BAZEL_DIR}/user_root/install/*/$binary + + # Set modification time somewhere in the future to avoid "corrupt installation: file PATH is missing or modified" + # in this case modification is required for successful build + touch -m -t 203712120101 ${BAZEL_DIR}/user_root/install/*/$binary + done } EXPORT_FUNCTIONS do_configure + +PSEUDO_IGNORE_PATHS .= ",${WORKDIR}/bazel" + +inherit unsupportarch + +export YOCTO_NATIVE_SYSROOT="${BAZEL_OUTPUTBASE_DIR}/external/yocto_compiler/recipe-sysroot-native" + +do_rm_work[prefuncs] += "clean_bazel" +do_clean[prefuncs] += "clean_bazel" +clean_bazel() { + if [ -d ${S} ]; then + cd ${S} + if [ -e ${BAZEL} ] && [ -e ${S}/bazelrc ]; then + ${BAZEL} clean + fi + fi + rm ${BAZEL_DIR} -rf +} + +do_compile[network] = "1" diff --git a/classes/tensorflow_ver.bbclass b/classes/tensorflow_ver.bbclass new file mode 100644 index 0000000..c20602a --- /dev/null +++ b/classes/tensorflow_ver.bbclass @@ -0,0 +1,5 @@ +# Build tensorflow 2.x by default +TF_ARGS_EXTRA ??= "--config=v2" + +# Uncomment the following line to build tensorflow 1.x +#TF_ARGS_EXTRA = "--config=v1" diff --git a/classes/unsupportarch.bbclass b/classes/unsupportarch.bbclass new file mode 100644 index 0000000..3b8a6b1 --- /dev/null +++ b/classes/unsupportarch.bbclass @@ -0,0 +1,11 @@ +BAZEL_TARGET_CPU ??= "" +BAZEL_TARGET_CPU:x86 = "x86" +BAZEL_TARGET_CPU:x86-64 = "k8" +BAZEL_TARGET_CPU:arm = "arm" +BAZEL_TARGET_CPU:aarch64 = "aarch64" + +python __anonymous() { + if not d.getVar("BAZEL_TARGET_CPU"): + target_arch = d.getVar("TARGET_ARCH") + raise bb.parse.SkipPackage("BAZEL_TARGET_CPU is not set\nTensorFlow does not support Target Arch '%s'" % target_arch) +} diff --git a/conf/layer.conf b/conf/layer.conf index a1ad84d..5944c41 100644 --- a/conf/layer.conf +++ b/conf/layer.conf @@ -11,7 +11,7 @@ BBFILE_PRIORITY_meta-tensorflow = "10" LAYERVERSION_meta-tensorflow = "1" -LAYERSERIES_COMPAT_meta-tensorflow = "warrior zeus" +LAYERSERIES_COMPAT_meta-tensorflow = "scarthgap" LAYERDEPENDS_meta-tensorflow = " \ core \ @@ -20,3 +20,5 @@ LAYERDEPENDS_meta-tensorflow = " \ " LAYER_PATH_meta-tensorflow = "${LAYERDIR}" + +NON_MULTILIB_RECIPES:append = " tensorflow tensorflow-lite" diff --git a/meta-demo/README-wrl.md b/meta-demo/README-wrl.md index 77f45d8..3df6f8a 100644 --- a/meta-demo/README-wrl.md +++ b/meta-demo/README-wrl.md @@ -38,11 +38,14 @@ $ . <ts-project>/oe-init-build-env <ts-build> $ sed -i "s/BB_NO_NETWORK/#BB_NO_NETWORK/" conf/local.conf # Disable whitelist mechanism -$ echo 'INHERIT_DISTRO_remove = "whitelist"' >> conf/local.conf +$ echo 'INHERIT_DISTRO:remove = "whitelist"' >> conf/local.conf + +# Build tensorflow 1.x +$ echo 'TF_ARGS_EXTRA = "--config=v1"' >> conf/local.conf # Install demo face-detection to image and enable distro feature -$ echo 'IMAGE_INSTALL_append = " face-detection"' >> conf/local.conf -$ echo 'DISTRO_FEATURES_append = " ts-demo"' >> conf/local.conf +$ echo 'IMAGE_INSTALL:append = " face-detection"' >> conf/local.conf +$ echo 'DISTRO_FEATURES:append = " ts-demo"' >> conf/local.conf # Add external layers $ bitbake-layers add-layer <ts-project>/meta-tensorflow diff --git a/meta-demo/README.md b/meta-demo/README.md index a333862..735297d 100644 --- a/meta-demo/README.md +++ b/meta-demo/README.md @@ -38,7 +38,8 @@ $ git clone git://git.openembedded.org/bitbake 2) Prepare build $ . <ts-project>/oe-core/oe-init-build-env <ts-build> $ echo 'MACHINE = "genericx86-64"' >> conf/local.conf -$ echo 'DISTRO_FEATURES_append = " ts-demo x11"' >> conf/local.conf +$ echo 'DISTRO_FEATURES:append = " ts-demo x11"' >> conf/local.conf +$ echo 'TF_ARGS_EXTRA = "--config=v1"' >> conf/local.conf $ bitbake-layers add-layer <ts-project>/meta-openembedded/meta-python $ bitbake-layers add-layer <ts-project>/meta-openembedded/meta-oe $ bitbake-layers add-layer <ts-project>/meta-yocto/meta-yocto-bsp diff --git a/meta-demo/classes/ts-demo-kernel.bbclass b/meta-demo/classes/ts-demo-kernel.bbclass index fa4ef20..0042324 100644 --- a/meta-demo/classes/ts-demo-kernel.bbclass +++ b/meta-demo/classes/ts-demo-kernel.bbclass @@ -17,4 +17,4 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -KERNEL_FEATURES_append=" features/media/media-usb-webcams.scc" +KERNEL_FEATURES:append=" features/media/media-usb-webcams.scc" diff --git a/meta-demo/classes/ts_v1.bbclass b/meta-demo/classes/ts_v1.bbclass new file mode 100644 index 0000000..0deb388 --- /dev/null +++ b/meta-demo/classes/ts_v1.bbclass @@ -0,0 +1,7 @@ +inherit unsupportarch tensorflow_ver + +python __anonymous() { + if '--config=v1' not in (d.getVar("TF_ARGS_EXTRA") or "").split(): + msg = "\nIt requires tensorflow 1.x, add 'TF_ARGS_EXTRA = \"--config=v1\"' to local.conf" + raise bb.parse.SkipPackage(msg) +} diff --git a/meta-demo/conf/layer.conf b/meta-demo/conf/layer.conf index 5090635..390ecf9 100644 --- a/meta-demo/conf/layer.conf +++ b/meta-demo/conf/layer.conf @@ -18,7 +18,7 @@ LAYERDEPENDS_tensorflow-demo = " \ meta-tensorflow \ " -LAYERSERIES_COMPAT_tensorflow-demo = "warrior zeus" +LAYERSERIES_COMPAT_tensorflow-demo = "hardknott honister" # USB webcam -KERNEL_CLASSES_append = " ${@bb.utils.contains('DISTRO_FEATURES', 'ts-demo', 'ts-demo-kernel', '', d)}" +KERNEL_CLASSES:append = " ${@bb.utils.contains('DISTRO_FEATURES', 'ts-demo', 'ts-demo-kernel', '', d)}" diff --git a/meta-demo/recipes-demo/face-detection/face-detection_0.1.bb b/meta-demo/recipes-demo/face-detection/face-detection_0.1.bb index af2c3b0..d05af46 100644 --- a/meta-demo/recipes-demo/face-detection/face-detection_0.1.bb +++ b/meta-demo/recipes-demo/face-detection/face-detection_0.1.bb @@ -7,7 +7,7 @@ SRC_URI = "file://recognize_face.py \ file://collect_face.py \ " -RDEPENDS_${PN} = " \ +RDEPENDS:${PN} = " \ tensorflow-for-poets \ python3-opencv \ opencv-apps \ @@ -21,3 +21,5 @@ do_install () { install -m 0755 ${WORKDIR}/recognize_face.py ${D}${sbindir}/recognize_face install -m 0755 ${WORKDIR}/collect_face.py ${D}${sbindir}/collect_face } + +inherit ts_v1 diff --git a/meta-demo/recipes-demo/face-detection/files/recognize_face.py b/meta-demo/recipes-demo/face-detection/files/recognize_face.py index 16657f7..59d043c 100644 --- a/meta-demo/recipes-demo/face-detection/files/recognize_face.py +++ b/meta-demo/recipes-demo/face-detection/files/recognize_face.py @@ -67,12 +67,8 @@ if __name__ == "__main__": rv, frame = camera.read() if rv: _face_detection(frame) - if args.save: - out.write(frame) cv.imshow('Video', frame) # When everything done, release the capture camera.release() - if args.save: - out.release() cv.destroyAllWindows() diff --git a/meta-demo/recipes-demo/images/core-image-x11-ts-demo.bb b/meta-demo/recipes-demo/images/core-image-x11-ts-demo.bb index ea15fc1..06d3860 100644 --- a/meta-demo/recipes-demo/images/core-image-x11-ts-demo.bb +++ b/meta-demo/recipes-demo/images/core-image-x11-ts-demo.bb @@ -9,3 +9,5 @@ IMAGE_INSTALL += " \ dhcp-client \ face-detection \ " + +inherit ts_v1 diff --git a/meta-demo/recipes-demo/minigo/README.md b/meta-demo/recipes-demo/minigo/README.md index fb115fd..5a19d7b 100644 --- a/meta-demo/recipes-demo/minigo/README.md +++ b/meta-demo/recipes-demo/minigo/README.md @@ -25,7 +25,7 @@ $ git clone git://git.openembedded.org/bitbake $ . <ts-project>/oe-core/oe-init-build-env <ts-build> $ echo 'MACHINE = "genericx86-64"' >> conf/local.conf -$ echo 'IMAGE_INSTALL_append = " minigo minigo-gui minigo-models"' >> conf/local.conf +$ echo 'IMAGE_INSTALL:append = " minigo minigo-gui minigo-models"' >> conf/local.conf $ bitbake add-layer <ts-project>/meta-openembedded/meta-python $ bitbake add-layer <ts-project>/meta-openembedded/meta-oe diff --git a/meta-demo/recipes-demo/minigo/minigo-models_git.bb b/meta-demo/recipes-demo/minigo/minigo-models_git.bb index ab809ff..ed97ff6 100644 --- a/meta-demo/recipes-demo/minigo/minigo-models_git.bb +++ b/meta-demo/recipes-demo/minigo/minigo-models_git.bb @@ -75,4 +75,4 @@ do_install() { install -m 0644 ${MODELS_DIR}/* ${D}/opt/minigo/models } -FILES_${PN} = "/opt/minigo/models" +FILES:${PN} = "/opt/minigo/models" diff --git a/meta-demo/recipes-demo/minigo/minigo.inc b/meta-demo/recipes-demo/minigo/minigo.inc index ae184cd..166e2a7 100644 --- a/meta-demo/recipes-demo/minigo/minigo.inc +++ b/meta-demo/recipes-demo/minigo/minigo.inc @@ -13,3 +13,4 @@ PV = "0.0+git${SRCPV}" S = "${WORKDIR}/git" +inherit ts_v1 diff --git a/meta-demo/recipes-demo/minigo/minigo_git.bb b/meta-demo/recipes-demo/minigo/minigo_git.bb index 2b811d1..dc38324 100644 --- a/meta-demo/recipes-demo/minigo/minigo_git.bb +++ b/meta-demo/recipes-demo/minigo/minigo_git.bb @@ -7,7 +7,7 @@ SRC_URI += "file://minigo-bootstrap.sh \ file://minigui-run.sh \ " -RDEPENDS_${PN} = "\ +RDEPENDS:${PN} = "\ python3-absl \ python3-six \ python3-protobuf \ @@ -28,7 +28,7 @@ RDEPENDS_${PN} = "\ bash \ " -RDEPENDS_${PN}-gui = "\ +RDEPENDS:${PN}-gui = "\ minigo \ python3-flask-socketio \ " @@ -43,5 +43,5 @@ do_install() { } PACKAGES =+ "${PN}-gui" -FILES_${PN}-gui = "/opt/minigo/minigui/" -FILES_${PN} = "/opt/minigo/" +FILES:${PN}-gui = "/opt/minigo/minigui/" +FILES:${PN} = "/opt/minigo/" diff --git a/meta-demo/recipes-demo/nmt/nmt.inc b/meta-demo/recipes-demo/nmt/nmt.inc index 5734c0d..ed28c7b 100644 --- a/meta-demo/recipes-demo/nmt/nmt.inc +++ b/meta-demo/recipes-demo/nmt/nmt.inc @@ -20,10 +20,10 @@ DEPENDS += " \ python3-termcolor-native \ tensorflow-estimator-native \ " -RDEPENDS_${PN} += "tensorflow \ +RDEPENDS:${PN} += "tensorflow \ python3 \ python3-numpy \ " inherit python3native -FILES_${PN} += "${libdir}/*" +FILES:${PN} += "${libdir}/*" diff --git a/meta-demo/recipes-demo/nmt/vien.bb b/meta-demo/recipes-demo/nmt/vien.bb index 2c57d8e..4c16761 100644 --- a/meta-demo/recipes-demo/nmt/vien.bb +++ b/meta-demo/recipes-demo/nmt/vien.bb @@ -1,7 +1,10 @@ require nmt.inc -SRC_URI_append = "file://download_iwslt15.sh \ +SRC_URI:append = "file://download_iwslt15.sh \ " + +inherit ts_v1 + do_compile(){ mkdir -p ${S}/vien/nmt_data mkdir -p ${S}/vien/nmt_model diff --git a/recipes-devtools/bazel/bazel-native_0.21.0.bb b/recipes-devtools/bazel/bazel-native_0.21.0.bb deleted file mode 100644 index 3395c2f..0000000 --- a/recipes-devtools/bazel/bazel-native_0.21.0.bb +++ /dev/null @@ -1,38 +0,0 @@ -DESCRIPTION = "Bazel build and test tool" -LICENSE = "Apache-2.0" -LIC_FILES_CHKSUM = "file://LICENSE;md5=3b83ef96387f14655fc854ddc3c6bd57" - -SRC_URI[md5sum] = "8c8240b178a35c0f3c1bc03017550270" -SRC_URI[sha256sum] = "6ccb831e683179e0cfb351cb11ea297b4db48f9eab987601c038aa0f83037db4" - -SRC_URI = "https://github.com/bazelbuild/bazel/releases/download/${PV}/bazel-${PV}-dist.zip \ - file://0001-HttpDownloader-save-download-tarball-to-distdir.patch \ -" - -inherit native - -INHIBIT_SYSROOT_STRIP = "1" - -DEPENDS = "coreutils-native \ - zip-native \ - openjdk-8-native \ - " - -S="${WORKDIR}" - -TS_DL_DIR ??= "${DL_DIR}" -do_compile () { - export JAVA_HOME="${STAGING_LIBDIR_NATIVE}/jvm/openjdk-8-native" - TMPDIR="${TOPDIR}/bazel" \ - VERBOSE=yes \ - EXTRA_BAZEL_ARGS="--distdir=${TS_DL_DIR}" \ - ./compile.sh -} - -do_install () { - install -d ${D}${bindir} - install -m 0755 ${S}/output/bazel ${D}${bindir} -} - -# Explicitly disable uninative -UNINATIVE_LOADER = "" diff --git a/recipes-devtools/bazel/bazel-native_6.0.0.bb b/recipes-devtools/bazel/bazel-native_6.0.0.bb new file mode 100644 index 0000000..c930054 --- /dev/null +++ b/recipes-devtools/bazel/bazel-native_6.0.0.bb @@ -0,0 +1,56 @@ +DESCRIPTION = "Bazel build and test tool" +LICENSE = "Apache-2.0" +LIC_FILES_CHKSUM = "file://LICENSE;md5=3b83ef96387f14655fc854ddc3c6bd57" + +SRC_URI[md5sum] = "f79f57d82795b591e95f9f7fa0f9a8da" +SRC_URI[sha256sum] = "7bc0c5145c19a56d82a08fce6908c5e1a0e75e4fbfb3b6f12b4deae7f4b38cbc" + +SRC_URI = "https://github.com/bazelbuild/bazel/releases/download/${PV}/bazel-${PV}-dist.zip \ + file://0001-HttpDownloader-save-download-tarball-to-distdir.patch \ + file://0001-fix-unzip-command-not-found.patch \ + file://0001-add-Yocto-native-sysroot-dir-to-the-default-Bazel-to.patch \ + file://0001-cutsomize-native-toolchains-for-Yocto.patch \ + file://0001-fix-compile-failure-on-gcc-13.patch \ +" + +inherit python3native + +INHIBIT_SYSROOT_STRIP = "1" + +CCACHE_DISABLE = "1" + +DEPENDS = "coreutils-native \ + zip-native \ + openjdk-11-native \ + " + +S="${WORKDIR}" + +inherit bazel-base + +EXTRA_BAZEL_ARGS = " \ + --host_javabase=@local_jdk//:jdk \ + --python_path=python3 \ + --distdir=${TS_DL_DIR} \ + ${@oe.utils.conditional("BAZEL_JOBS", "", "", "--jobs=${BAZEL_JOBS}", d )} \ + ${@oe.utils.conditional("BAZEL_JOBS", "", "", "--local_cpu_resources=${BAZEL_JOBS}", d )} \ + ${@oe.utils.conditional("BAZEL_MEM", "", "", "--local_ram_resources=${BAZEL_MEM}", d )} \ +" + +do_compile[network] = "1" +do_compile () { + TMPDIR="${TMPDIR}/bazel" \ + VERBOSE=yes \ + EXTRA_BAZEL_ARGS="${EXTRA_BAZEL_ARGS}" \ + ./compile.sh +} + +do_install () { + install -d ${D}${bindir} + install -m 0755 ${S}/output/bazel ${D}${bindir} +} + +# Explicitly disable uninative +UNINATIVE_LOADER = "" + +inherit native diff --git a/recipes-devtools/bazel/files/0001-HttpDownloader-save-download-tarball-to-distdir.patch b/recipes-devtools/bazel/files/0001-HttpDownloader-save-download-tarball-to-distdir.patch index 605756a..86aba40 100644 --- a/recipes-devtools/bazel/files/0001-HttpDownloader-save-download-tarball-to-distdir.patch +++ b/recipes-devtools/bazel/files/0001-HttpDownloader-save-download-tarball-to-distdir.patch @@ -1,71 +1,31 @@ -From e31a37bc9cb53de5085e885b190652f994209cf6 Mon Sep 17 00:00:00 2001 -From: Hongxu Jia <hongxu.jia@windriver.com> -Date: Tue, 23 Apr 2019 05:21:40 -0400 +From 28acb4a213938bcb7e55ef3859699091c1f434c0 Mon Sep 17 00:00:00 2001 +From: Hongxu Jia <hongxu.jia@eng.windriver.com> +Date: Thu, 1 Dec 2022 19:32:33 +0800 Subject: [PATCH] HttpDownloader: save download tarball to distdir It is helpful for collecting tarball url which supports offline build. Upstream-Status: Inappropriate [oe specific] -Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com> +Signed-off-by: Hongxu Jia <hongxu.jia@eng.windriver.com> --- - .../repository/downloader/HttpDownloader.java | 50 ++++++++++++++-------- - 1 file changed, 32 insertions(+), 18 deletions(-) + .../bazel/repository/downloader/DownloadManager.java | 12 ++++++++++++ + 1 file changed, 12 insertions(+) -diff --git a/src/main/java/com/google/devtools/build/lib/bazel/repository/downloader/HttpDownloader.java b/src/main/java/com/google/devtools/build/lib/bazel/repository/downloader/HttpDownloader.java -index 18d10d2..cf71ac4 100755 ---- a/src/main/java/com/google/devtools/build/lib/bazel/repository/downloader/HttpDownloader.java -+++ b/src/main/java/com/google/devtools/build/lib/bazel/repository/downloader/HttpDownloader.java -@@ -204,26 +204,29 @@ public class HttpDownloader { - eventHandler.handle(Event.warn("distdir " + dir + " is not a directory")); +diff --git a/src/main/java/com/google/devtools/build/lib/bazel/repository/downloader/DownloadManager.java b/src/main/java/com/google/devtools/build/lib/bazel/repository/downloader/DownloadManager.java +index bf65090..ee30dde 100755 +--- a/src/main/java/com/google/devtools/build/lib/bazel/repository/downloader/DownloadManager.java ++++ b/src/main/java/com/google/devtools/build/lib/bazel/repository/downloader/DownloadManager.java +@@ -213,6 +213,7 @@ public class DownloadManager { } else { - boolean match = false; -- Path candidate = dir.getRelative(destination.getBaseName()); -- try { -- match = RepositoryCache.getChecksum(KeyType.SHA256, candidate).equals(sha256); -- } catch (IOException e) { -- // Not finding anything in a distdir is a normal case, so handle it absolutely -- // quietly. In fact, it is not uncommon to specify a whole list of dist dirs, -- // with the asumption that only one will contain an entry. -- } -- if (match) { -- if (isCachingByProvidedSha256) { -- try { -- repositoryCache.put(sha256, candidate, KeyType.SHA256); -- } catch (IOException e) { -- eventHandler.handle( -- Event.warn("Failed to copy " + candidate + " to repository cache: " + e)); -+ String[] basenames = {destination.getBaseName(), destination.getBaseName()+"_"+sha256}; -+ for (String basename: basenames) { -+ Path candidate = dir.getRelative(basename); -+ try { -+ match = RepositoryCache.getChecksum(KeyType.SHA256, candidate).equals(sha256); -+ } catch (IOException e) { -+ // Not finding anything in a distdir is a normal case, so handle it absolutely -+ // quietly. In fact, it is not uncommon to specify a whole list of dist dirs, -+ // with the asumption that only one will contain an entry. -+ } -+ if (match) { -+ if (isCachingByProvidedSha256) { -+ try { -+ repositoryCache.put(sha256, candidate, KeyType.SHA256); -+ } catch (IOException e) { -+ eventHandler.handle( -+ Event.warn("Failed to copy " + candidate + " to repository cache: " + e)); -+ } - } -+ FileSystemUtils.createDirectoryAndParents(destination.getParentDirectory()); -+ FileSystemUtils.copyFile(candidate, destination); -+ return destination; - } -- FileSystemUtils.createDirectoryAndParents(destination.getParentDirectory()); -- FileSystemUtils.copyFile(candidate, destination); -- return destination; - } - } - } -@@ -264,6 +267,17 @@ public class HttpDownloader { - eventHandler.handle(Event.info("SHA256 (" + urls.get(0) + ") = " + newSha256)); + for (String name : candidateFileNames) { + boolean match = false; ++ name += "_"+cacheKey; + Path candidate = dir.getRelative(name); + try { + eventHandler.post( +@@ -280,6 +281,17 @@ public class DownloadManager { + repositoryCache.put(destination, KeyType.SHA256, canonicalId); } + for (Path dir : distdir) { @@ -73,7 +33,7 @@ index 18d10d2..cf71ac4 100755 + FileSystemUtils.createDirectoryAndParents(dir); + + if (dir.isDirectory()) { -+ Path dl_mirror = dir.getRelative(destination.getBaseName()+"_"+sha256); ++ Path dl_mirror = dir.getRelative(destination.getBaseName()+"_"+checksum.get().toString()); + if (!dl_mirror.exists()) + FileSystemUtils.copyFile(destination, dl_mirror); + } @@ -83,5 +43,5 @@ index 18d10d2..cf71ac4 100755 } -- -2.8.1 +2.27.0 diff --git a/recipes-devtools/bazel/files/0001-add-Yocto-native-sysroot-dir-to-the-default-Bazel-to.patch b/recipes-devtools/bazel/files/0001-add-Yocto-native-sysroot-dir-to-the-default-Bazel-to.patch new file mode 100644 index 0000000..7d73eb7 --- /dev/null +++ b/recipes-devtools/bazel/files/0001-add-Yocto-native-sysroot-dir-to-the-default-Bazel-to.patch @@ -0,0 +1,39 @@ +From 34c4dc1a10140addf75d3503d4b9f427303fe212 Mon Sep 17 00:00:00 2001 +From: Hongxu Jia <hongxu.jia@windriver.com> +Date: Mon, 14 Dec 2020 16:45:31 +0800 +Subject: [PATCH] add Yocto native sysroot dir to the default Bazel toolchain + +While using the default Bazel C++ toolchain to build Yocto native tools +(bazel build --host_crosstool_top=@bazel_tools//tools/cpp:toolchain), +it failed `bazel references a path outside of the execution root', + +Add Yocto native sysroot dir (YOCTO_NATIVE_SYSROOT) to +builtin_include_directories could fix the issue + +If not set YOCTO_NATIVE_SYSROOT, use NOT_SET_YOCTO_NATIVE_SYSROOT +to replace as a warning + +Upstream-Status: Inappropriate [oe specific] + +Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com> +--- + tools/cpp/unix_cc_configure.bzl | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/tools/cpp/unix_cc_configure.bzl b/tools/cpp/unix_cc_configure.bzl +index d48485b..0d297bf 100755 +--- a/tools/cpp/unix_cc_configure.bzl ++++ b/tools/cpp/unix_cc_configure.bzl +@@ -443,6 +443,9 @@ def configure_unix_toolchain(repository_ctx, cpu_value, overriden_tools): + paths["@bazel_tools//tools/cpp:generate_system_module_map.sh"], + )) + ++ # Customize for Yocto ++ builtin_include_directories.append(get_env_var(repository_ctx,"YOCTO_NATIVE_SYSROOT", "NOT_SET_YOCTO_NATIVE_SYSROOT")) ++ + write_builtin_include_directory_paths(repository_ctx, cc, builtin_include_directories) + repository_ctx.template( + "BUILD", +-- +2.18.2 + diff --git a/recipes-devtools/bazel/files/0001-cutsomize-native-toolchains-for-Yocto.patch b/recipes-devtools/bazel/files/0001-cutsomize-native-toolchains-for-Yocto.patch new file mode 100644 index 0000000..5758b5e --- /dev/null +++ b/recipes-devtools/bazel/files/0001-cutsomize-native-toolchains-for-Yocto.patch @@ -0,0 +1,35 @@ +From 81c9eae49a10fa8d5ede088e90632db0103e2168 Mon Sep 17 00:00:00 2001 +From: Hongxu Jia <hongxu.jia@windriver.com> +Date: Thu, 19 May 2022 01:11:05 -0700 +Subject: [PATCH] cutsomize native toolchains for Yocto + +Yocto use environment HOSTTOOLS_DIR to provide native toolchains, +explicitly set it rather than detect + +Upstream-Status: Inappropriate [Yocto specific] + +Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com> +--- + tools/cpp/unix_cc_configure.bzl | 6 ++++++ + 1 file changed, 6 insertions(+) + +diff --git a/tools/cpp/unix_cc_configure.bzl b/tools/cpp/unix_cc_configure.bzl +index 1b6aeb2..4a36685 100755 +--- a/tools/cpp/unix_cc_configure.bzl ++++ b/tools/cpp/unix_cc_configure.bzl +@@ -373,6 +373,12 @@ def configure_unix_toolchain(repository_ctx, cpu_value, overriden_tools): + if darwin: + overriden_tools["gcc"] = "cc_wrapper.sh" + overriden_tools["ar"] = "/usr/bin/libtool" ++ ++ hosttools_dir = get_env_var(repository_ctx,"HOSTTOOLS_DIR", False) ++ if hosttools_dir: ++ for k in ["ar", "ld", "cpp", "gcc", "nm", "objcopy", "objdump", "strip"]: ++ overriden_tools[k] = "%s/%s" % (hosttools_dir, k) ++ + auto_configure_warning_maybe(repository_ctx, "CC used: " + str(cc)) + tool_paths = _get_tool_paths(repository_ctx, overriden_tools) + cc_toolchain_identifier = escape_string(get_env_var( +-- +2.36.0 + diff --git a/recipes-devtools/bazel/files/0001-fix-compile-failure-on-gcc-13.patch b/recipes-devtools/bazel/files/0001-fix-compile-failure-on-gcc-13.patch new file mode 100644 index 0000000..2fce1dc --- /dev/null +++ b/recipes-devtools/bazel/files/0001-fix-compile-failure-on-gcc-13.patch @@ -0,0 +1,71 @@ +From 02fcd86787da1ebb2afad1909cb70839cdac24dc Mon Sep 17 00:00:00 2001 +From: Hongxu Jia <hongxu.jia@windriver.com> +Date: Wed, 13 Sep 2023 10:56:02 +0800 +Subject: [PATCH] fix compile failure on gcc 13 + +external/com_google_absl/absl/strings/internal/str_format/extension.h:34:33: error: found ':' in nested-name-specifier, expected '::' + 34 | enum class FormatConversionChar : uint8_t; + +Upstream-Status: Pending + +Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com> +--- + distdir_deps.bzl | 4 +++ + .../0001-fix-compile-failure-on-gcc-13.patch | 30 +++++++++++++++++++ + 2 files changed, 34 insertions(+) + create mode 100644 third_party/com_google_absl/0001-fix-compile-failure-on-gcc-13.patch + +diff --git a/distdir_deps.bzl b/distdir_deps.bzl +index 2ca988e..c460025 100755 +--- a/distdir_deps.bzl ++++ b/distdir_deps.bzl +@@ -163,6 +163,10 @@ DIST_DEPS = { + }, + "com_google_absl": { + "archive": "20211102.0.tar.gz", ++ "patch_args": ["-p1"], ++ "patches": [ ++ "//third_party:com_google_absl/0001-fix-compile-failure-on-gcc-13.patch", ++ ], + "sha256": "dcf71b9cba8dc0ca9940c4b316a0c796be8fab42b070bb6b7cab62b48f0e66c4", + "urls": [ + "https://mirror.bazel.build/github.com/abseil/abseil-cpp/archive/refs/tags/20211102.0.tar.gz", +diff --git a/third_party/com_google_absl/0001-fix-compile-failure-on-gcc-13.patch b/third_party/com_google_absl/0001-fix-compile-failure-on-gcc-13.patch +new file mode 100644 +index 0000000..257e887 +--- /dev/null ++++ b/third_party/com_google_absl/0001-fix-compile-failure-on-gcc-13.patch +@@ -0,0 +1,30 @@ ++From 4cb33b2e98fd0b2f201e765a5a0d9c1d4277041e Mon Sep 17 00:00:00 2001 ++From: Hongxu Jia <hongxu.jia@windriver.com> ++Date: Wed, 13 Sep 2023 11:17:34 +0800 ++Subject: [PATCH] fix compile failure on gcc 13 ++ ++external/com_google_absl/absl/strings/internal/str_format/extension.h:34:33: error: found ':' in nested-name-specifier, expected '::' ++ 34 | enum class FormatConversionChar : uint8_t; ++ ++Upstream-Status: Pending ++ ++Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com> ++--- ++ absl/strings/internal/str_format/extension.h | 1 + ++ 1 file changed, 1 insertion(+) ++ ++diff --git a/absl/strings/internal/str_format/extension.h b/absl/strings/internal/str_format/extension.h ++index 55cbb56..67d4cc8 100644 ++--- a/absl/strings/internal/str_format/extension.h +++++ b/absl/strings/internal/str_format/extension.h ++@@ -21,6 +21,7 @@ ++ #include <cstddef> ++ #include <cstring> ++ #include <ostream> +++#include <cstdint> ++ ++ #include "absl/base/config.h" ++ #include "absl/base/port.h" ++-- ++2.17.1 ++ +-- +2.27.0 + diff --git a/recipes-devtools/bazel/files/0001-fix-unzip-command-not-found.patch b/recipes-devtools/bazel/files/0001-fix-unzip-command-not-found.patch new file mode 100644 index 0000000..eccc34a --- /dev/null +++ b/recipes-devtools/bazel/files/0001-fix-unzip-command-not-found.patch @@ -0,0 +1,35 @@ +From 23e2aff67a03127572641c7286e306c2a20990e2 Mon Sep 17 00:00:00 2001 +From: Hongxu Jia <hongxu.jia@windriver.com> +Date: Tue, 8 Dec 2020 11:05:13 +0800 +Subject: [PATCH] fix unzip: command not found + +If host does not provide unzip, build bazel will fail even though +Yocto native sysroot does have unzip. + +The reason is var-PATH was not passed to bazel build in some cases. + +Remove hardcoded /bin and /usr/bin from PATH + +Upstream-Status: Inappropriate [wr-installer specific] + +Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com> +--- + .../devtools/build/lib/bazel/rules/BazelRuleClassProvider.java | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/BazelRuleClassProvider.java b/src/main/java/com/google/devtools/build/lib/bazel/rules/BazelRuleClassProvider.java +index 16252df..e7cd609 100755 +--- a/src/main/java/com/google/devtools/build/lib/bazel/rules/BazelRuleClassProvider.java ++++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/BazelRuleClassProvider.java +@@ -469,7 +469,7 @@ public class BazelRuleClassProvider { + // Note that --action_env does not propagate to the host config, so it is not a viable + // workaround when a genrule is itself built in the host config (e.g. nested genrules). See + // #8536. +- return "/bin:/usr/bin:/usr/local/bin"; ++ return System.getenv("PATH"); + } + + String newPath = ""; +-- +2.18.2 + diff --git a/recipes-devtools/openjdk/openjdk-11-native_11.0.15.bb b/recipes-devtools/openjdk/openjdk-11-native_11.0.15.bb new file mode 100644 index 0000000..e982af6 --- /dev/null +++ b/recipes-devtools/openjdk/openjdk-11-native_11.0.15.bb @@ -0,0 +1,32 @@ +DESCRIPTION = "Java runtime based upon the OpenJDK Project, the community \ +builds using source code from OpenJDK project" +LICENSE = "GPL-2.0-with-classpath-exception" +LIC_FILES_CHKSUM = "file://legal/java.base/LICENSE;md5=3e0b59f8fac05c3c03d4a26bbda13f8f" + +SRC_URI[md5sum] = "7a1d931c0454981d85ed0d2949a91b7f" +SRC_URI[sha256sum] = "78e4e52c31600a99bb8050e94017123e447c6683d0f9d7a6c5b0d49c0da6f29a" +SRC_URI = " \ + https://github.com/ojdkbuild/contrib_jdk11u-ci/releases/download/jdk-11.0.15%2B10/jdk-11.0.15-ojdkbuild-linux-x64.zip \ +" + +S = "${WORKDIR}/jdk-11.0.15-ojdkbuild-linux-x64" + +do_patch[noexec] = "1" +do_configure[noexec] = "1" +do_compile[noexec] = "1" + +do_install () { + install -d ${D}${libdir}/jvm/openjdk-11-native + cp -rf ${S}/* ${D}${libdir}/jvm/openjdk-11-native +} + +inherit native +INHIBIT_SYSROOT_STRIP = "1" + +python __anonymous() { + if d.getVar("BUILD_ARCH") != "x86_64": + msg = "\nThe pre-build openjdk-11-native does not support %s host," % d.getVar("BUILD_ARCH") + msg += "\nplease use the one in meta-java to replace," + msg += "\nadd meta-java to BBLAYERS in conf/bblayers.conf" + raise bb.parse.SkipPackage(msg) +} diff --git a/recipes-devtools/openjdk/openjdk-8-native_212b04.bb b/recipes-devtools/openjdk/openjdk-8-native_212b04.bb deleted file mode 100644 index 788612a..0000000 --- a/recipes-devtools/openjdk/openjdk-8-native_212b04.bb +++ /dev/null @@ -1,32 +0,0 @@ -DESCRIPTION = "Java runtime based upon the OpenJDK Project, the community \ -builds using source code from OpenJDK project" -LICENSE = "GPL-2.0-with-classpath-exception" -LIC_FILES_CHKSUM = "file://LICENSE;md5=3e0b59f8fac05c3c03d4a26bbda13f8f" - -SRC_URI[md5sum] = "8082ad8dafec378f2a4b24cbfdb4a9a4" -SRC_URI[sha256sum] = "ef6a3050a1c3477a6e13c24d10ab36decad548649a260559d466467401db15de" -SRC_URI = " \ - https://github.com/ojdkbuild/contrib_jdk8u-ci/releases/download/jdk8u212-b04/jdk-8u212-ojdkbuild-linux-x64.zip \ -" - -S = "${WORKDIR}/jdk-8u212-ojdkbuild-linux-x64" - -do_patch[noexec] = "1" -do_configure[noexec] = "1" -do_compile[noexec] = "1" - -do_install () { - install -d ${D}${libdir}/jvm/openjdk-8-native - cp -rf ${S}/* ${D}${libdir}/jvm/openjdk-8-native -} - -inherit native -INHIBIT_SYSROOT_STRIP = "1" - -python __anonymous() { - if d.getVar("BUILD_ARCH") != "x86_64": - msg = "\nThe pre-build openjdk-8-native does not support %s host," % d.getVar("BUILD_ARCH") - msg += "\nplease use the one in meta-java to replace," - msg += "\nadd meta-java to BBLAYERS in conf/bblayers.conf" - raise bb.parse.SkipPackage(msg) -} diff --git a/meta-demo/recipes-devtools/python/python-google-auth.inc b/recipes-devtools/python/python-google-auth.inc index 61e37c0..91dbb21 100644 --- a/meta-demo/recipes-devtools/python/python-google-auth.inc +++ b/recipes-devtools/python/python-google-auth.inc @@ -9,7 +9,13 @@ LIC_FILES_CHKSUM = "file://LICENSE;md5=86d3f3a95c324c9479bd8986968f4327" inherit pypi -SRC_URI[md5sum] = "0440718247cc4531422e2a8f4f012e8b" -SRC_URI[sha256sum] = "0f7c6a64927d34c1a474da92cfc59e552a5d3b940d3266606c6a28b72888b9e4" +SRC_URI[md5sum] = "2d7fb4328377b94603823e3f029a3e1d" +SRC_URI[sha256sum] = "9e00c76e1bc7b1a7fe80472f1347f3802e4caa1fa53ba1f11b7af3772b484a82" + +RDEPENDS:${PN} += " \ + python3-cachetools \ + python3-rsa \ + python3-pyasn1-modules \ +" BBCLASSEXTEND = "native" diff --git a/recipes-devtools/python/python3-astunparse_1.6.3.bb b/recipes-devtools/python/python3-astunparse_1.6.3.bb new file mode 100644 index 0000000..0cb5c5e --- /dev/null +++ b/recipes-devtools/python/python3-astunparse_1.6.3.bb @@ -0,0 +1,12 @@ +SUMMARY = "An AST unparser for Python" +HOMEPAGE = "https://github.com/simonpercivall/astunparse" +SECTION = "devel/python" +LICENSE = "PSF-2.0" +LIC_FILES_CHKSUM = "file://LICENSE;md5=7a7c771110c28a37480b73d07ad6d2a1" + +SRC_URI[md5sum] = "2cea4d8e49beba7684bac890e73d6a40" +SRC_URI[sha256sum] = "5ad93a8456f0d084c3456d059fd9a92cce667963232cbf763eac3bc5b7940872" + +inherit pypi setuptools3 + +BBCLASSEXTEND = "native" diff --git a/recipes-devtools/python/python3-gast_0.4.0.bb b/recipes-devtools/python/python3-gast_0.4.0.bb new file mode 100644 index 0000000..29a6c54 --- /dev/null +++ b/recipes-devtools/python/python3-gast_0.4.0.bb @@ -0,0 +1,12 @@ +SUMMARY = "A generic AST to represent Python3's Abstract Syntax Tree(AST)." +HOMEPAGE = "https://github.com/serge-sans-paille/gast" +SECTION = "devel/python" +LICENSE = "BSD-3-Clause" +LIC_FILES_CHKSUM = "file://LICENSE;md5=a3ad9b6802e713fc5e307e1230f1ea90" + +SRC_URI[md5sum] = "d1f258eb70bb916f8fe5535351d5ff05" +SRC_URI[sha256sum] = "40feb7b8b8434785585ab224d1568b857edb18297e5a3047f1ba012bc83b42c1" + +inherit pypi setuptools3 + +BBCLASSEXTEND = "native" diff --git a/recipes-devtools/python/python3-google-auth-oauthlib_0.4.5.bb b/recipes-devtools/python/python3-google-auth-oauthlib_0.4.5.bb new file mode 100644 index 0000000..ecc2867 --- /dev/null +++ b/recipes-devtools/python/python3-google-auth-oauthlib_0.4.5.bb @@ -0,0 +1,20 @@ +SUMMARY = "The oauthlib integration for Google Auth" +HOMEPAGE = "https://github.com/googleapis/google-auth-library-python-oauthlib" +DESCRIPTION = "This library provides oauthlib integration with google-auth." +SECTION = "devel/python" + +LICENSE = "Apache-2.0" +LIC_FILES_CHKSUM = "file://LICENSE;md5=3b83ef96387f14655fc854ddc3c6bd57" + +inherit pypi + +SRC_URI[md5sum] = "0ef7695adb47224714926a7e8331e61d" +SRC_URI[sha256sum] = "4ab58e6c3dc6ccf112f921fcced40e5426fba266768986ea502228488276eaba" + +BBCLASSEXTEND = "native" + +RDEPENDS:${PN} += " \ + python3-requests-oauthlib \ + python3-oauthlib \ +" +inherit setuptools3 diff --git a/meta-demo/recipes-devtools/python/python3-google-auth_1.6.3.bb b/recipes-devtools/python/python3-google-auth_2.0.0.bb index 0d86a65..0d86a65 100644 --- a/meta-demo/recipes-devtools/python/python3-google-auth_1.6.3.bb +++ b/recipes-devtools/python/python3-google-auth_2.0.0.bb diff --git a/recipes-devtools/python/python3-google-pasta_0.2.0.bb b/recipes-devtools/python/python3-google-pasta_0.2.0.bb new file mode 100644 index 0000000..50a363c --- /dev/null +++ b/recipes-devtools/python/python3-google-pasta_0.2.0.bb @@ -0,0 +1,12 @@ +SUMMARY = "The AST-based Python refactoring library" +HOMEPAGE = "https://github.com/google/pasta" +SECTION = "devel/python" +LICENSE = "Apache-2.0" +LIC_FILES_CHKSUM = "file://PKG-INFO;md5=a10102394a800f3fa4a3df0934d57bb1" + +SRC_URI[md5sum] = "7c218a4a0d84303b9319352040fbfce6" +SRC_URI[sha256sum] = "c9f2c8dfc8f96d0d5808299920721be30c9eec37f2389f28904f454565c8a16e" + +inherit pypi setuptools3 + +BBCLASSEXTEND = "native" diff --git a/recipes-devtools/python/python3-mldtypes_0.2.0.bb b/recipes-devtools/python/python3-mldtypes_0.2.0.bb new file mode 100644 index 0000000..a369b25 --- /dev/null +++ b/recipes-devtools/python/python3-mldtypes_0.2.0.bb @@ -0,0 +1,28 @@ +SUMMARY = "The ml_dtypes is a stand-alone implementation of several NumPy dtype extensions used in machine learning libraries" +HOMEPAGE = "https://github.com/jax-ml/ml_dtypes" +SECTION = "devel/python" +LICENSE = "Apache-2.0" +LIC_FILES_CHKSUM = "file://LICENSE;md5=3b83ef96387f14655fc854ddc3c6bd57" + +SRC_URI[md5sum] = "ed4f6491b168ff2050c4ad373e9d76df" +SRC_URI[sha256sum] = "6488eb642acaaf08d8020f6de0a38acee7ac324c1e6e92ee0c0fea42422cb797" + +inherit pypi setuptools3 + +SRCNAME ?= "ml_dtypes" +PYPI_SRC_URI = "https://files.pythonhosted.org/packages/fa/47/09ca9556bf99cfe7ddf129a3423642bd482a27a717bf115090493fa42429/${SRCNAME}-${PV}.tar.gz" + +S = "${WORKDIR}/${SRCNAME}-${PV}" + +DEPENDS = " \ + python3-pybind11-native \ + python3-numpy-native \ +" + +RDEPENDS:${PN} = " \ + python3-pybind11 \ + python3-numpy \ +" + +BBCLASSEXTEND = "native" + diff --git a/recipes-devtools/python/python3-opt-einsum/0001-Use-ConfigParser-instead-of-SafeConfigParser.patch b/recipes-devtools/python/python3-opt-einsum/0001-Use-ConfigParser-instead-of-SafeConfigParser.patch new file mode 100644 index 0000000..93e3bd8 --- /dev/null +++ b/recipes-devtools/python/python3-opt-einsum/0001-Use-ConfigParser-instead-of-SafeConfigParser.patch @@ -0,0 +1,36 @@ +From 0beacf96923bbb2dd1939a9c59398a38ce7a11b1 Mon Sep 17 00:00:00 2001 +From: Hongxu Jia <hongxu.jia@windriver.com> +Date: Thu, 17 Nov 2022 17:04:54 -0800 +Subject: [PATCH] Use ConfigParser instead of SafeConfigParser + +The SafeConfigParser class will be renamed to ConfigParser in Python +3.12 [1]. This alias will be removed in future versions.So we can use +ConfigParser directly instead. + +[1] https://github.com/python/cpython/issues/89336 + +Upstream-Status: Submitted [https://github.com/dgasmith/opt_einsum/pull/208] +Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com> +--- + versioneer.py | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/versioneer.py b/versioneer.py +index d3db643..6d732af 100644 +--- a/versioneer.py ++++ b/versioneer.py +@@ -339,9 +339,9 @@ def get_config_from_root(root): + # configparser.NoOptionError (if it lacks "VCS="). See the docstring at + # the top of versioneer.py for instructions on writing your setup.cfg . + setup_cfg = os.path.join(root, "setup.cfg") +- parser = configparser.SafeConfigParser() ++ parser = configparser.ConfigParser() + with open(setup_cfg, "r") as f: +- parser.readfp(f) ++ parser.read_file(f) + VCS = parser.get("versioneer", "VCS") # mandatory + + def get(parser, name): +-- +2.37.1 + diff --git a/recipes-devtools/python/python3-opt-einsum_3.3.0.bb b/recipes-devtools/python/python3-opt-einsum_3.3.0.bb new file mode 100644 index 0000000..ce9d220 --- /dev/null +++ b/recipes-devtools/python/python3-opt-einsum_3.3.0.bb @@ -0,0 +1,19 @@ +SUMMARY = "A tensor contraction order optimizer" +HOMEPAGE = "https://github.com/dgasmith/opt_einsum" +SECTION = "devel/python" +LICENSE = "MIT" +LIC_FILES_CHKSUM = "file://LICENSE;md5=5ab423c88cf3e69553decf93419f53ac" + +SRC_URI[md5sum] = "acf0a3997aab84b4e9a854296cc34971" +SRC_URI[sha256sum] = "59f6475f77bbc37dcf7cd748519c0ec60722e91e63ca114e68821c0c54a46549" + +inherit pypi setuptools3 + +SRCNAME = "opt_einsum" +PYPI_SRC_URI = "https://files.pythonhosted.org/packages/source/o/${PYPI_PACKAGE}/${SRCNAME}-${PV}.tar.gz" +SRC_URI += " \ + file://0001-Use-ConfigParser-instead-of-SafeConfigParser.patch \ +" +S = "${WORKDIR}/${SRCNAME}-${PV}" + +BBCLASSEXTEND = "native" diff --git a/recipes-framework/tensorflow/files/0001-CheckFeatureOrDie-use-warning-to-avoid-die.patch b/recipes-framework/tensorflow/files/0001-CheckFeatureOrDie-use-warning-to-avoid-die.patch index 6d6ba09..7bde666 100644 --- a/recipes-framework/tensorflow/files/0001-CheckFeatureOrDie-use-warning-to-avoid-die.patch +++ b/recipes-framework/tensorflow/files/0001-CheckFeatureOrDie-use-warning-to-avoid-die.patch @@ -1,6 +1,6 @@ -From 419877ee8785f6d5850cc1d3d432ab43e51f47b9 Mon Sep 17 00:00:00 2001 +From 1455cd4232f382b73cb4ff6dfa6ccc7bd5197428 Mon Sep 17 00:00:00 2001 From: Hongxu Jia <hongxu.jia@windriver.com> -Date: Mon, 29 Apr 2019 08:54:57 +0000 +Date: Mon, 16 May 2022 00:39:33 -0700 Subject: [PATCH] CheckFeatureOrDie: use warning to avoid die Run 32-bit tensorflow on qemux86-64, it broke at CheckFeatureOrDie, @@ -10,27 +10,32 @@ Upstream-Status: Inappropriate [oe specific] Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com> --- - tensorflow/core/platform/cpu_feature_guard.cc | 4 ---- - 1 file changed, 4 deletions(-) + tensorflow/core/platform/cpu_feature_guard.cc | 7 ------- + 1 file changed, 7 deletions(-) diff --git a/tensorflow/core/platform/cpu_feature_guard.cc b/tensorflow/core/platform/cpu_feature_guard.cc -index 2efe0c0876..75149177aa 100644 +index 11a438925c1..9874ed34793 100644 --- a/tensorflow/core/platform/cpu_feature_guard.cc +++ b/tensorflow/core/platform/cpu_feature_guard.cc -@@ -29,13 +29,9 @@ namespace { - // If the CPU feature isn't present, log a fatal error. - void CheckFeatureOrDie(CPUFeature feature, const string& feature_name) { - if (!TestCPUFeature(feature)) { +@@ -36,18 +36,11 @@ void CheckFeatureOrDie(CPUFeature feature, const string& feature_name) { + const auto error_msg = + "The TensorFlow library was compiled to use " + feature_name + + " instructions, but these aren't available on your machine."; -#ifdef __ANDROID__ - // Some Android emulators seem to indicate they don't support SSE, so to - // avoid crashes when testing, switch this to a warning. - LOG(WARNING) + // Some Android emulators seem to indicate they don't support SSE, so we + // only issue a warning to avoid crashes when testing. We use the logging + // framework here because std::cout and std::cerr made some Android targets + // crash. + LOG(WARNING) << error_msg; -#else -- LOG(FATAL) +- // Avoiding use of the logging framework here as that might trigger a SIGILL +- // by itself. +- std::cerr << error_msg << std::endl; +- std::abort(); -#endif - << "The TensorFlow library was compiled to use " << feature_name - << " instructions, but these aren't available on your machine."; } + } + -- -2.17.1 +2.36.0 diff --git a/recipes-framework/tensorflow/files/0001-SyntaxError-around-async-keyword-on-Python-3.7.patch b/recipes-framework/tensorflow/files/0001-SyntaxError-around-async-keyword-on-Python-3.7.patch deleted file mode 100644 index 75cb572..0000000 --- a/recipes-framework/tensorflow/files/0001-SyntaxError-around-async-keyword-on-Python-3.7.patch +++ /dev/null @@ -1,116 +0,0 @@ -From 8abbdce7a7ec7428b7f657e313ee0b6642c1de76 Mon Sep 17 00:00:00 2001 -From: Hongxu Jia <hongxu.jia@windriver.com> -Date: Thu, 14 Feb 2019 10:45:55 +0800 -Subject: [PATCH] SyntaxError around async keyword on Python 3.7 - -Backport a fix from upstream astor to fix the error - -Upstream-Status: Pending - -Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com> ---- - tensorflow/workspace.bzl | 1 + - ...-Don-t-use-async-as-a-keyword-argument-94.patch | 79 ++++++++++++++++++++++ - 2 files changed, 80 insertions(+) - create mode 100644 third_party/systemlibs/0001-Don-t-use-async-as-a-keyword-argument-94.patch - -diff --git a/tensorflow/workspace.bzl b/tensorflow/workspace.bzl -index aefab03..a281803 100755 ---- a/tensorflow/workspace.bzl -+++ b/tensorflow/workspace.bzl -@@ -278,6 +278,7 @@ def tf_workspace(path_prefix = "", tf_repo_name = ""): - tf_http_archive( - name = "astor_archive", - build_file = clean_dep("//third_party:astor.BUILD"), -+ patch_file = clean_dep("//third_party/systemlibs:0001-Don-t-use-async-as-a-keyword-argument-94.patch"), - sha256 = "ff6d2e2962d834acb125cc4dcc80c54a8c17c253f4cc9d9c43b5102a560bb75d", - strip_prefix = "astor-0.6.2", - system_build_file = clean_dep("//third_party/systemlibs:astor.BUILD"), -diff --git a/third_party/systemlibs/0001-Don-t-use-async-as-a-keyword-argument-94.patch b/third_party/systemlibs/0001-Don-t-use-async-as-a-keyword-argument-94.patch -new file mode 100644 -index 0000000..aafb172 ---- /dev/null -+++ b/third_party/systemlibs/0001-Don-t-use-async-as-a-keyword-argument-94.patch -@@ -0,0 +1,79 @@ -+From fe1ef7f9d746847c157197e4cb2ab6505fe19faf Mon Sep 17 00:00:00 2001 -+From: Berker Peksag <berker.peksag@gmail.com> -+Date: Fri, 23 Mar 2018 16:50:21 +0300 -+Subject: [PATCH] Don't use 'async' as a keyword argument (#94) -+ -+Fixes #86 -+ -+Upstream-Status: Backport[https://github.com/berkerpeksag/astor.git] -+Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com> -+--- -+ astor/code_gen.py | 18 +++++++++--------- -+ 1 file changed, 9 insertions(+), 9 deletions(-) -+ -+diff --git a/astor/code_gen.py b/astor/code_gen.py -+index 7c27f70..47d6acc 100644 -+--- a/astor/code_gen.py -++++ b/astor/code_gen.py -+@@ -308,8 +308,8 @@ class SourceGenerator(ExplicitNodeVisitor): -+ self.statement(node) -+ self.generic_visit(node) -+ -+- def visit_FunctionDef(self, node, async=False): -+- prefix = 'async ' if async else '' -++ def visit_FunctionDef(self, node, is_async=False): -++ prefix = 'async ' if is_async else '' -+ self.decorators(node, 1 if self.indentation else 2) -+ self.statement(node, '%sdef %s' % (prefix, node.name), '(') -+ self.visit_arguments(node.args) -+@@ -322,7 +322,7 @@ class SourceGenerator(ExplicitNodeVisitor): -+ -+ # introduced in Python 3.5 -+ def visit_AsyncFunctionDef(self, node): -+- self.visit_FunctionDef(node, async=True) -++ self.visit_FunctionDef(node, is_async=True) -+ -+ def visit_ClassDef(self, node): -+ have_args = [] -+@@ -364,24 +364,24 @@ class SourceGenerator(ExplicitNodeVisitor): -+ self.else_body(else_) -+ break -+ -+- def visit_For(self, node, async=False): -++ def visit_For(self, node, is_async=False): -+ set_precedence(node, node.target) -+- prefix = 'async ' if async else '' -++ prefix = 'async ' if is_async else '' -+ self.statement(node, '%sfor ' % prefix, -+ node.target, ' in ', node.iter, ':') -+ self.body_or_else(node) -+ -+ # introduced in Python 3.5 -+ def visit_AsyncFor(self, node): -+- self.visit_For(node, async=True) -++ self.visit_For(node, is_async=True) -+ -+ def visit_While(self, node): -+ set_precedence(node, node.test) -+ self.statement(node, 'while ', node.test, ':') -+ self.body_or_else(node) -+ -+- def visit_With(self, node, async=False): -+- prefix = 'async ' if async else '' -++ def visit_With(self, node, is_async=False): -++ prefix = 'async ' if is_async else '' -+ self.statement(node, '%swith ' % prefix) -+ if hasattr(node, "context_expr"): # Python < 3.3 -+ self.visit_withitem(node) -+@@ -392,7 +392,7 @@ class SourceGenerator(ExplicitNodeVisitor): -+ -+ # new for Python 3.5 -+ def visit_AsyncWith(self, node): -+- self.visit_With(node, async=True) -++ self.visit_With(node, is_async=True) -+ -+ # new for Python 3.3 -+ def visit_withitem(self, node): -+-- -+2.7.4 -+ --- -2.7.4 - diff --git a/recipes-framework/tensorflow/files/0001-add-yocto-toolchain-to-support-cross-compiling.patch b/recipes-framework/tensorflow/files/0001-add-yocto-toolchain-to-support-cross-compiling.patch index 5fa5f91..5fdc04c 100644 --- a/recipes-framework/tensorflow/files/0001-add-yocto-toolchain-to-support-cross-compiling.patch +++ b/recipes-framework/tensorflow/files/0001-add-yocto-toolchain-to-support-cross-compiling.patch @@ -1,44 +1,40 @@ -From dd303f745d159a2359c81922a2171a409998a71d Mon Sep 17 00:00:00 2001 -From: Hongxu Jia <hongxu.jia@windriver.com> -Date: Thu, 31 Jan 2019 20:37:26 +0800 +From 2e03e5bcd0b1e05f10f7d2d0cfede314fbfa5818 Mon Sep 17 00:00:00 2001 +From: Hongxu Jia <hongxu.jia@eng.windriver.com> +Date: Fri, 1 Mar 2024 00:22:22 -0800 Subject: [PATCH] add yocto toolchain to support cross compiling Upstream-Status: Inappropriate [oe specific] -Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com> +Signed-off-by: Hongxu Jia <hongxu.jia@eng.windriver.com> --- - WORKSPACE | 6 ++++++ - tensorflow/BUILD | 9 +++++++++ - tensorflow/workspace.bzl | 8 ++++++++ - third_party/aws/BUILD.bazel | 3 +++ - third_party/repo.bzl | 1 + - 5 files changed, 27 insertions(+) + WORKSPACE | 6 ++++++ + tensorflow/BUILD | 9 +++++++++ + tensorflow/workspace2.bzl | 8 ++++++++ + 3 files changed, 23 insertions(+) diff --git a/WORKSPACE b/WORKSPACE -index 7057d3f..869c180 100644 +index 720fee74bd2..94095bf1914 100644 --- a/WORKSPACE +++ b/WORKSPACE -@@ -53,6 +53,12 @@ android_configure(name="local_config_android") - load("@local_config_android//:android.bzl", "android_workspace") - android_workspace() +@@ -40,3 +40,9 @@ tf_workspace1() + load("@//tensorflow:workspace0.bzl", "tf_workspace0") + tf_workspace0() ++ +new_local_repository( + name = "yocto_compiler", + path = "%%WORKDIR%%", + build_file = "//:BUILD.yocto_compiler", +) -+ - # Please add all new TensorFlow dependencies in workspace.bzl. - tf_workspace() - diff --git a/tensorflow/BUILD b/tensorflow/BUILD -index 823ad8f..6270301 100644 +index 9e724aff49b..0918af13243 100644 --- a/tensorflow/BUILD +++ b/tensorflow/BUILD -@@ -100,6 +100,15 @@ config_setting( +@@ -352,6 +352,15 @@ config_setting( + visibility = ["//visibility:public"], ) - config_setting( ++config_setting( + name = "yocto_armeabi", + values = { + "crosstool_top": "@local_config_yocto_compiler//:toolchain", @@ -47,62 +43,35 @@ index 823ad8f..6270301 100644 + visibility = ["//visibility:public"], +) + -+config_setting( + config_setting( name = "android_arm", - values = { - "crosstool_top": "//external:android/crosstool", -diff --git a/tensorflow/workspace.bzl b/tensorflow/workspace.bzl -index aefab03..12c6fab 100755 ---- a/tensorflow/workspace.bzl -+++ b/tensorflow/workspace.bzl -@@ -12,6 +12,7 @@ load("//third_party/sycl:sycl_configure.bzl", "sycl_configure") - load("//third_party/systemlibs:syslibs_configure.bzl", "syslibs_configure") - load("//third_party/toolchains/clang6:repo.bzl", "clang6_configure") - load("//third_party/toolchains/cpus/arm:arm_compiler_configure.bzl", "arm_compiler_configure") + constraint_values = if_google( +diff --git a/tensorflow/workspace2.bzl b/tensorflow/workspace2.bzl +index 3ef4a544f1a..9e4c2da9fe2 100644 +--- a/tensorflow/workspace2.bzl ++++ b/tensorflow/workspace2.bzl +@@ -49,6 +49,7 @@ load("//tensorflow/tools/def_file_filter:def_file_filter_configure.bzl", "def_fi + load("//tensorflow/tools/toolchains:cpus/aarch64/aarch64_compiler_configure.bzl", "aarch64_compiler_configure") + load("//tensorflow/tools/toolchains:cpus/arm/arm_compiler_configure.bzl", "arm_compiler_configure") + load("//tensorflow/tools/toolchains/clang6:repo.bzl", "clang6_configure") +load("//third_party/toolchains/yocto:yocto_compiler_configure.bzl", "yocto_compiler_configure") - load("//third_party:repo.bzl", "tf_http_archive") - load("//third_party/clang_toolchain:cc_configure_clang.bzl", "cc_download_clang_toolchain") - load("@io_bazel_rules_closure//closure/private:java_import_external.bzl", "java_import_external") -@@ -76,6 +77,13 @@ def tf_workspace(path_prefix = "", tf_repo_name = ""): - remote_config_repo = "../arm_compiler", - ) + load("//tensorflow/tools/toolchains/embedded/arm-linux:arm_linux_toolchain_configure.bzl", "arm_linux_toolchain_configure") + load("//tensorflow/tools/toolchains/remote:configure.bzl", "remote_execution_configure") + load("//tensorflow/tools/toolchains/remote_config:configs.bzl", "initialize_rbe_configs") +@@ -127,6 +128,13 @@ def _tf_toolchains(): + # Load aarch64 toolchain + aarch64_compiler_configure() + # Point //external/local_config_yocto_compiler to //external/yocto_compiler + yocto_compiler_configure( + name = "local_config_yocto_compiler", -+ build_file = clean_dep("//third_party/toolchains/yocto:BUILD"), ++ build_file = "//third_party/toolchains/yocto:BUILD", + remote_config_repo = "../yocto_compiler", + ) + - mkl_repository( - name = "mkl_linux", - build_file = clean_dep("//third_party/mkl:mkl.BUILD"), -diff --git a/third_party/aws/BUILD.bazel b/third_party/aws/BUILD.bazel -index 5426f79..b106b12 100644 ---- a/third_party/aws/BUILD.bazel -+++ b/third_party/aws/BUILD.bazel -@@ -24,6 +24,9 @@ cc_library( - "@org_tensorflow//tensorflow:raspberry_pi_armeabi": glob([ - "aws-cpp-sdk-core/source/platform/linux-shared/*.cpp", - ]), -+ "@org_tensorflow//tensorflow:yocto_armeabi": glob([ -+ "aws-cpp-sdk-core/source/platform/linux-shared/*.cpp", -+ ]), - "//conditions:default": [], - }) + glob([ - "aws-cpp-sdk-core/include/**/*.h", -diff --git a/third_party/repo.bzl b/third_party/repo.bzl -index bad6d20..9823cab 100644 ---- a/third_party/repo.bzl -+++ b/third_party/repo.bzl -@@ -16,6 +16,7 @@ - - _SINGLE_URL_WHITELIST = depset([ - "arm_compiler", -+ "yocto_compiler", - ]) - - def _is_windows(ctx): + # TFLite crossbuild toolchain for embeddeds Linux + arm_linux_toolchain_configure( + name = "local_config_embedded_arm", -- -2.7.4 +2.42.0 diff --git a/recipes-framework/tensorflow/files/0001-build-api_gen_binary_target-as-host-tools.patch b/recipes-framework/tensorflow/files/0001-build-api_gen_binary_target-as-host-tools.patch new file mode 100644 index 0000000..c7f3034 --- /dev/null +++ b/recipes-framework/tensorflow/files/0001-build-api_gen_binary_target-as-host-tools.patch @@ -0,0 +1,49 @@ +From e1471b0dd1eb2c6ee152f749437cab65c2b27ef3 Mon Sep 17 00:00:00 2001 +From: Hongxu Jia <hongxu.jia@eng.windriver.com> +Date: Fri, 1 Mar 2024 00:41:25 -0800 +Subject: [PATCH] build api_gen_binary_target as host tools + +For cross compiling, build api_gen_binary_target as target tools will +cause load target library failed. + +$ bazel-out/aarch64-opt/bin/tensorflow/create_tensorflow.python_api_tf_python_api_gen_v2 --root_init_template=tensorflow/api_template.__init__.py --apidir=bazel-out/aarch64-opt/bin/tensorflow/_api/v2/ --apiname=tensorflow --apiversion=2 --compat_apiversion=1 --compat_apiversion=2 --compat_init_template=tensorflow/compat_template_v1.__init__.py --compat_init_template=tensorflow/compat_template.__init__.py --packages=tensorflow.python,tensorflow.dtensor.python.accelerator_util,tensorflow.dtensor.python.api,tensorflow.dtensor.python.config,tensorflow.dtensor.python.d_checkpoint,tensorflow.dtensor.python.d_variable,tensorflow.dtensor.python.input_util,tensorflow.dtensor.python.layout,tensorflow.dtensor.python.mesh_util,tensorflow.dtensor.python.tpu_util,tensorflow.dtensor.python.save_restore,tensorflow.lite.python.analyzer,tensorflow.lite.python.lite,tensorflow.lite.python.authoring.authoring,tensorflow.python.modules_with_exports --output_package=tensorflow._api.v2 --use_relative_imports=True --loading=default bazel-out/aarch64-opt/bin/tensorflow/tf_python_api_gen_v2.params + +Traceback (most recent call last): + File "/buildarea/raid0/hjia/wrlinux-23/lat_cd_091209/build-ts-14-v2/tmp-glibc/work/cortexa57-wrs-linux/tensorflow/2.14.0/bazel/output_base/execroot/org_tensorflow/bazel-out/aarch64-opt/bin/tensorflow/create_tensorflow.python_api_tf_python_api_gen_v2.runfiles/org_tensorflow/tensorflow/python/tools/api/generator/create_python_api.py", line 22, in <module> + from tensorflow.python.tools.api.generator import doc_srcs + File "/buildarea/raid0/hjia/wrlinux-23/lat_cd_091209/build-ts-14-v2/tmp-glibc/work/cortexa57-wrs-linux/tensorflow/2.14.0/bazel/output_base/execroot/org_tensorflow/bazel-out/aarch64-opt/bin/tensorflow/create_tensorflow.python_api_tf_python_api_gen_v2.runfiles/org_tensorflow/tensorflow/python/__init__.py", line 36, in <module> + from tensorflow.python import pywrap_tensorflow as _pywrap_tensorflow + File "/buildarea/raid0/hjia/wrlinux-23/lat_cd_091209/build-ts-14-v2/tmp-glibc/work/cortexa57-wrs-linux/tensorflow/2.14.0/bazel/output_base/execroot/org_tensorflow/bazel-out/aarch64-opt/bin/tensorflow/create_tensorflow.python_api_tf_python_api_gen_v2.runfiles/org_tensorflow/tensorflow/python/pywrap_tensorflow.py", line 26, in <module> + self_check.preload_check() + File "/buildarea/raid0/hjia/wrlinux-23/lat_cd_091209/build-ts-14-v2/tmp-glibc/work/cortexa57-wrs-linux/tensorflow/2.14.0/bazel/output_base/execroot/org_tensorflow/bazel-out/aarch64-opt/bin/tensorflow/create_tensorflow.python_api_tf_python_api_gen_v2.runfiles/org_tensorflow/tensorflow/python/platform/self_check.py", line 63, in preload_check + from tensorflow.python.platform import _pywrap_cpu_feature_guard +ImportError: /buildarea/raid0/hjia/wrlinux-23/lat_cd_091209/build-ts-14-v2/tmp-glibc/work/cortexa57-wrs-linux/tensorflow/2.14.0/bazel/output_base/execroot/org_tensorflow/bazel-out/aarch64-opt/bin/tensorflow/create_tensorflow.python_api_tf_python_api_gen_v2.runfiles/org_tensorflow/tensorflow/python/platform/_pywrap_cpu_feature_guard.so: cannot open shared object file: No such file or directory + +Build api_gen_binary_target as host tools and load native library +at build time + +Upstream-Status: Inappropriate [oe specific] + +Rebase to 2.16 + +Signed-off-by: Hongxu Jia <hongxu.jia@eng.windriver.com> +--- + tensorflow/python/tools/api/generator/api_gen.bzl | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/tensorflow/python/tools/api/generator/api_gen.bzl b/tensorflow/python/tools/api/generator/api_gen.bzl +index c41aeecc476..a087557ad0f 100644 +--- a/tensorflow/python/tools/api/generator/api_gen.bzl ++++ b/tensorflow/python/tools/api/generator/api_gen.bzl +@@ -267,7 +267,7 @@ api_gen_rule = rule( + "outs": attr.output_list(mandatory = True), + "srcs": attr.label_list(allow_files = True), + "flags": attr.string_list(), +- "api_gen_binary_target": attr.label(executable = True, cfg = if_oss("target", "exec"), mandatory = True), ++ "api_gen_binary_target": attr.label(executable = True, cfg = "exec", mandatory = True), + "loading_value": attr.string(mandatory = True), + "api_packages_path": attr.output(), + }, +-- +2.42.0 + diff --git a/recipes-framework/tensorflow/files/0001-drop-bazel_toolchains_repositories-to-support-offlin.patch b/recipes-framework/tensorflow/files/0001-drop-bazel_toolchains_repositories-to-support-offlin.patch new file mode 100644 index 0000000..730f2c2 --- /dev/null +++ b/recipes-framework/tensorflow/files/0001-drop-bazel_toolchains_repositories-to-support-offlin.patch @@ -0,0 +1,39 @@ +From 6bb9c02aae20996a6e4edd8fe743a90ce8d677aa Mon Sep 17 00:00:00 2001 +From: Hongxu Jia <hongxu.jia@windriver.com> +Date: Sun, 18 Sep 2022 23:52:34 -0700 +Subject: [PATCH] drop bazel_toolchains_repositories to support offline build + +Upstream-Status: Inappropriate [oe specific] + +Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com> + +Rebase to 2.10.0 +Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com> +--- + tensorflow/workspace0.bzl | 3 --- + 1 file changed, 3 deletions(-) + +diff --git a/tensorflow/workspace0.bzl b/tensorflow/workspace0.bzl +index c3c081b19ef..445de71bb13 100644 +--- a/tensorflow/workspace0.bzl ++++ b/tensorflow/workspace0.bzl +@@ -2,7 +2,6 @@ + + load("//third_party/googleapis:repository_rules.bzl", "config_googleapis") + load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") +-load("@bazel_toolchains//repositories:repositories.bzl", bazel_toolchains_repositories = "repositories") + load("@build_bazel_rules_apple//apple:repositories.bzl", "apple_rules_dependencies") + load("@build_bazel_rules_swift//swift:repositories.bzl", "swift_rules_dependencies") + load("@build_bazel_apple_support//lib:repositories.bzl", "apple_support_dependencies") +@@ -104,8 +103,6 @@ def workspace(): + ], + ) + +- bazel_toolchains_repositories() +- + # Apple rules for Bazel. https://github.com/bazelbuild/rules_apple. + # Note: We add this to fix Kokoro builds. + # The rules below call into `rules_proto` but the hash has changed and +-- +2.37.1 + diff --git a/recipes-framework/tensorflow/files/0001-drop-v2-config.patch b/recipes-framework/tensorflow/files/0001-drop-v2-config.patch new file mode 100644 index 0000000..ff74a3c --- /dev/null +++ b/recipes-framework/tensorflow/files/0001-drop-v2-config.patch @@ -0,0 +1,29 @@ +From 104224b8b30f74dabed893aa057f400ad7cd2695 Mon Sep 17 00:00:00 2001 +From: Hongxu Jia <hongxu.jia@windriver.com> +Date: Mon, 16 May 2022 00:10:55 -0700 +Subject: [PATCH] drop v2 config + +Upstream-Status: Inappropriate [oe specific] + +Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com> +--- + .bazelrc | 3 --- + 1 file changed, 3 deletions(-) + +diff --git a/.bazelrc b/.bazelrc +index b6a72c1e5d3..a71ade6950f 100644 +--- a/.bazelrc ++++ b/.bazelrc +@@ -138,9 +138,6 @@ build --define=with_xla_support=true + # TODO(mihaimaruseac): Document this option or remove if no longer needed + build --config=short_logs + +-# TODO(mihaimaruseac): Document this option or remove if no longer needed +-build --config=v2 +- + # Disable AWS/HDFS support by default + build --define=no_aws_support=true + build --define=no_hdfs_support=true +-- +2.36.0 + diff --git a/recipes-framework/tensorflow/files/0001-fix-build-failure.patch b/recipes-framework/tensorflow/files/0001-fix-build-failure.patch new file mode 100644 index 0000000..30a0361 --- /dev/null +++ b/recipes-framework/tensorflow/files/0001-fix-build-failure.patch @@ -0,0 +1,54 @@ +From cd26d8228aef93559dc11c7584d8cf8d0a529d1d Mon Sep 17 00:00:00 2001 +From: Hongxu Jia <hongxu.jia@windriver.com> +Date: Mon, 4 Mar 2024 15:07:58 +0800 +Subject: [PATCH] fix build failure + +... +ERROR: /buildarea/raid5/hjia/wrlinux-24/build_master-wr_ts_intel_2024030114/build/tmp-glibc/work/x86_64-linux/tensorflow-native/2.16.0/git/tensorflow/BUILD:1173:21: in cc_shared_library rule //tensorflow:libtensorflow_framework.so.2.16.0: +Traceback (most recent call last): + File "/virtual_builtins_bzl/common/cc/experimental_cc_shared_library.bzl", line 453, column 105, in _cc_shared_library_impl + File "/virtual_builtins_bzl/common/cc/experimental_cc_shared_library.bzl", line 349, column 37, in _filter_inputs + File "/virtual_builtins_bzl/common/cc/experimental_cc_shared_library.bzl", line 386, column 9, in _throw_error_if_unaccounted_libs +Error in fail: The following libraries cannot be linked either statically or dynamically: +@riegeli//riegeli/bytes:fd_reader +@riegeli//riegeli/bytes:fd_internal +@riegeli//riegeli/bytes:fd_internal_for_headers +@riegeli//riegeli/bytes:buffered_writer +@riegeli//riegeli/records:record_reader +@riegeli//riegeli/records:chunk_reader +@riegeli//riegeli/records:record_position +@riegeli//riegeli/records:block +@riegeli//riegeli/bytes:string_writer +@riegeli//riegeli/ordered_varint:ordered_varint_reading +(and 74 others) + +To ignore which libraries get linked statically for now, add the following to 'static_deps': + "@riegeli//:__subpackages__", + "@org_brotli//:__subpackages__", + "@net_zstd//:__subpackages__", +... + +Upstream-Status: Inappropriate [Yocto specific] + +Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com> +--- + tensorflow/BUILD | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/tensorflow/BUILD b/tensorflow/BUILD +index 2a49fdfce60..24c2bbf82ef 100644 +--- a/tensorflow/BUILD ++++ b/tensorflow/BUILD +@@ -131,6 +131,9 @@ PACKAGE_STATIC_DEPS = [ + "@triton//:__subpackages__", + "@local_tsl//:__subpackages__", + "@local_xla//:__subpackages__", ++ "@riegeli//:__subpackages__", ++ "@org_brotli//:__subpackages__", ++ "@net_zstd//:__subpackages__", + ] + tsl_async_value_deps() + + package( +-- +2.27.0 + diff --git a/recipes-framework/tensorflow/files/0001-fix-build-tensorflow-lite-examples-label_image-label.patch b/recipes-framework/tensorflow/files/0001-fix-build-tensorflow-lite-examples-label_image-label.patch index ba40d51..0502c5b 100644 --- a/recipes-framework/tensorflow/files/0001-fix-build-tensorflow-lite-examples-label_image-label.patch +++ b/recipes-framework/tensorflow/files/0001-fix-build-tensorflow-lite-examples-label_image-label.patch @@ -1,13 +1,14 @@ -From 1930f8aabbfe00debd2914f759cb5ac263215d49 Mon Sep 17 00:00:00 2001 +From 1af9e2180f680c1b0c94fbeeaee9dc522f353d07 Mon Sep 17 00:00:00 2001 From: Hongxu Jia <hongxu.jia@windriver.com> -Date: Sun, 24 Feb 2019 03:33:00 -0500 +Date: Tue, 17 Aug 2021 16:00:24 +0800 Subject: [PATCH] fix build //tensorflow/lite/examples/label_image:label_image failure It caused undefined reference neon_tensor_utils failure ... |tensor_utils.cc:(.text._ZN6tflite12tensor_utils18ReductionSumVectorEPKfPfii+0x0): -undefined reference to `tflite::tensor_utils::NeonReductionSumVector(float const*, +undefined reference to +`tflite::tensor_utils::NeonReductionSumVector(float const*, float*, int, int)' ... @@ -16,37 +17,35 @@ Upstream-Status: Inappropriate [oe specific] Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com> --- - tensorflow/lite/kernels/internal/BUILD | 10 ++++++++++ - 1 file changed, 10 insertions(+) + tensorflow/lite/kernels/internal/BUILD | 8 ++++++++ + 1 file changed, 8 insertions(+) diff --git a/tensorflow/lite/kernels/internal/BUILD b/tensorflow/lite/kernels/internal/BUILD -index 4be3226..959a9f0 100644 +index 8c714fc282d..6ea96e4f103 100644 --- a/tensorflow/lite/kernels/internal/BUILD +++ b/tensorflow/lite/kernels/internal/BUILD -@@ -93,6 +93,13 @@ config_setting( +@@ -112,6 +112,13 @@ config_setting( + }, ) - config_setting( ++config_setting( + name = "armeabi", + values = { + "cpu": "armeabi", + }, +) + -+config_setting( + config_setting( name = "haswell", values = { - "cpu": "haswell", -@@ -504,6 +511,9 @@ cc_library( - ":armeabi-v7a": [ - ":neon_tensor_utils", - ], -+ ":armeabi": [ -+ ":neon_tensor_utils", -+ ], - ":armv7a": [ - ":neon_tensor_utils", - ], +@@ -235,6 +242,7 @@ selects.config_setting_group( + ":arm", + ":arm64-v8a", + ":armeabi-v7a", ++ ":armeabi", + ":armhf", + ":armv7a", + ":ios_armv7", -- -2.8.1 +2.27.0 diff --git a/recipes-framework/tensorflow/files/0001-fix-gcc-internal-compile-error-on-qemuarm64.patch b/recipes-framework/tensorflow/files/0001-fix-gcc-internal-compile-error-on-qemuarm64.patch deleted file mode 100644 index aca3de4..0000000 --- a/recipes-framework/tensorflow/files/0001-fix-gcc-internal-compile-error-on-qemuarm64.patch +++ /dev/null @@ -1,64 +0,0 @@ -From e9871369eee1d98652eaf1c7dcc6adaf72733f55 Mon Sep 17 00:00:00 2001 -From: Hongxu Jia <hongxu.jia@windriver.com> -Date: Wed, 13 Feb 2019 20:58:17 -0500 -Subject: [PATCH] fix gcc internal compile error on qemuarm64 - -Backport a fix from eigen upstream to fix the error. - -Upstream-Status: Inappropriate [oe specific] -Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com> ---- - tensorflow/workspace.bzl | 1 + - ...ling-workaround-on-architectures-with-SSE.patch | 28 ++++++++++++++++++++++ - 2 files changed, 29 insertions(+) - create mode 100644 third_party/0001-enable-spilling-workaround-on-architectures-with-SSE.patch - -diff --git a/tensorflow/workspace.bzl b/tensorflow/workspace.bzl -index 12c6fab..aa49190 100755 ---- a/tensorflow/workspace.bzl -+++ b/tensorflow/workspace.bzl -@@ -144,6 +144,7 @@ def tf_workspace(path_prefix = "", tf_repo_name = ""): - tf_http_archive( - name = "eigen_archive", - build_file = clean_dep("//third_party:eigen.BUILD"), -+ patch_file = clean_dep("//third_party:0001-enable-spilling-workaround-on-architectures-with-SSE.patch"), - sha256 = "753fbb58d0a49b6bcbcfb126ebfa2e21fc97f7471529ba835a096008ce588d8a", - strip_prefix = "eigen-eigen-9f48e814419e", - urls = [ -diff --git a/third_party/0001-enable-spilling-workaround-on-architectures-with-SSE.patch b/third_party/0001-enable-spilling-workaround-on-architectures-with-SSE.patch -new file mode 100644 -index 0000000..e3848bd ---- /dev/null -+++ b/third_party/0001-enable-spilling-workaround-on-architectures-with-SSE.patch -@@ -0,0 +1,28 @@ -+From c1b4d0195674d4196683d4988d774e74e3cc291a Mon Sep 17 00:00:00 2001 -+From: Gael Guennebaud <g.gael@free.fr> -+Date: Mon, 10 Dec 2018 23:22:44 +0100 -+Subject: [PATCH] enable spilling workaround on architectures with SSE/AVX -+ -+Upstream-Status: Backport [https://github.com/eigenteam/eigen-git-mirror.git] -+Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com> -+ -+--- -+ Eigen/src/Core/products/GeneralBlockPanelKernel.h | 2 +- -+ 1 file changed, 1 insertion(+), 1 deletion(-) -+ -+diff --git a/Eigen/src/Core/products/GeneralBlockPanelKernel.h b/Eigen/src/Core/products/GeneralBlockPanelKernel.h -+index 61521e2..b1e98b6 100644 -+--- a/Eigen/src/Core/products/GeneralBlockPanelKernel.h -++++ b/Eigen/src/Core/products/GeneralBlockPanelKernel.h -+@@ -1391,7 +1391,7 @@ void gebp_kernel<LhsScalar,RhsScalar,Index,DataMapper,mr,nr,ConjugateLhs,Conjuga -+ -+ // NOTE: the begin/end asm comments below work around bug 935! -+ // but they are not enough for gcc>=6 without FMA (bug 1637) -+- #if EIGEN_GNUC_AT_LEAST(6,0) -++ #if EIGEN_GNUC_AT_LEAST(6,0) && defined(EIGEN_VECTORIZE_SSE) -+ #define EIGEN_GEBP_2PX4_SPILLING_WORKAROUND __asm__ ("" : [a0] "+rm" (A0),[a1] "+rm" (A1)); -+ #else -+ #define EIGEN_GEBP_2PX4_SPILLING_WORKAROUND -+-- -+2.8.1 -+ --- -2.8.1 - diff --git a/recipes-framework/tensorflow/files/0001-grpc-Define-gettid-only-for-glibc-2.30.patch b/recipes-framework/tensorflow/files/0001-grpc-Define-gettid-only-for-glibc-2.30.patch deleted file mode 100644 index 89dff12..0000000 --- a/recipes-framework/tensorflow/files/0001-grpc-Define-gettid-only-for-glibc-2.30.patch +++ /dev/null @@ -1,89 +0,0 @@ -From 7bf3f05197bb6d71beba9dcd0ac83ddfcf7f1919 Mon Sep 17 00:00:00 2001 -From: Hongxu Jia <hongxu.jia@windriver.com> -Date: Fri, 23 Aug 2019 13:54:52 +0000 -Subject: [PATCH] grpc: Define gettid() only for glibc < 2.30 - -glibc 2.30 has added this API, so let us use that when possible - -Upstream-Status: Pending - -Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com> ---- - tensorflow/workspace.bzl | 1 + - ...01-Define-gettid-only-for-glibc-2.30.patch | 52 +++++++++++++++++++ - 2 files changed, 53 insertions(+) - create mode 100644 third_party/systemlibs/0001-Define-gettid-only-for-glibc-2.30.patch - -diff --git a/tensorflow/workspace.bzl b/tensorflow/workspace.bzl -index 788eca2f67..8a37fe5643 100755 ---- a/tensorflow/workspace.bzl -+++ b/tensorflow/workspace.bzl -@@ -475,6 +475,7 @@ def tf_workspace(path_prefix = "", tf_repo_name = ""): - sha256 = "1aa84387232dda273ea8fdfe722622084f72c16f7b84bfc519ac7759b71cdc91", - strip_prefix = "grpc-69b6c047bc767b4d80e7af4d00ccb7c45b683dae", - system_build_file = clean_dep("//third_party/systemlibs:grpc.BUILD"), -+ patch_file = clean_dep("//third_party/systemlibs:0001-Define-gettid-only-for-glibc-2.30.patch"), - urls = [ - "https://mirror.bazel.build/github.com/grpc/grpc/archive/69b6c047bc767b4d80e7af4d00ccb7c45b683dae.tar.gz", - "https://github.com/grpc/grpc/archive/69b6c047bc767b4d80e7af4d00ccb7c45b683dae.tar.gz", -diff --git a/third_party/systemlibs/0001-Define-gettid-only-for-glibc-2.30.patch b/third_party/systemlibs/0001-Define-gettid-only-for-glibc-2.30.patch -new file mode 100644 -index 0000000000..30f1d7b252 ---- /dev/null -+++ b/third_party/systemlibs/0001-Define-gettid-only-for-glibc-2.30.patch -@@ -0,0 +1,52 @@ -+From 1d630079c3d1013baebd19060f4e6050112cb66d Mon Sep 17 00:00:00 2001 -+From: Hongxu Jia <hongxu.jia@windriver.com> -+Date: Fri, 23 Aug 2019 13:52:01 +0000 -+Subject: [PATCH] Define gettid() only for glibc < 2.30 -+ -+glibc 2.30 has added this API, so let us use that when possible -+ -+Upstream-Status: Pending -+Signed-off-by: Khem Raj <raj.khem@gmail.com> -+ -+Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com> -+--- -+ src/core/lib/gpr/log_linux.cc | 4 ++++ -+ src/core/lib/iomgr/ev_epollex_linux.cc | 4 ++++ -+ 2 files changed, 8 insertions(+) -+ -+diff --git a/src/core/lib/gpr/log_linux.cc b/src/core/lib/gpr/log_linux.cc -+index 561276f..25a7486 100644 -+--- a/src/core/lib/gpr/log_linux.cc -++++ b/src/core/lib/gpr/log_linux.cc -+@@ -40,7 +40,11 @@ -+ #include <time.h> -+ #include <unistd.h> -+ -++#if defined(__GLIBC__) && (__GLIBC_MINOR__ >= 29) -++#include <unistd.h> -++#else -+ static long gettid(void) { return syscall(__NR_gettid); } -++#endif -+ -+ void gpr_log(const char* file, int line, gpr_log_severity severity, -+ const char* format, ...) { -+diff --git a/src/core/lib/iomgr/ev_epollex_linux.cc b/src/core/lib/iomgr/ev_epollex_linux.cc -+index 06a382c..ec321f2 100644 -+--- a/src/core/lib/iomgr/ev_epollex_linux.cc -++++ b/src/core/lib/iomgr/ev_epollex_linux.cc -+@@ -1150,8 +1150,12 @@ static void end_worker(grpc_pollset* pollset, grpc_pollset_worker* worker, -+ } -+ -+ #ifndef NDEBUG -++#if defined(__GLIBC__) && (__GLIBC_MINOR__ >= 29) -++#include <unistd.h> -++#else -+ static long gettid(void) { return syscall(__NR_gettid); } -+ #endif -++#endif -+ -+ /* pollset->mu lock must be held by the caller before calling this. -+ The function pollset_work() may temporarily release the lock (pollset->po.mu) -+-- -+2.17.1 -+ --- -2.17.1 - diff --git a/recipes-framework/tensorflow/files/0001-hardcode-go-SDKS.patch b/recipes-framework/tensorflow/files/0001-hardcode-go-SDKS.patch new file mode 100644 index 0000000..b705ec7 --- /dev/null +++ b/recipes-framework/tensorflow/files/0001-hardcode-go-SDKS.patch @@ -0,0 +1,93 @@ +From c0fa623063942d53f9f65fb14ada4cbec5cc9b9a Mon Sep 17 00:00:00 2001 +From: Hongxu Jia <hongxu.jia@eng.windriver.com> +Date: Thu, 1 Dec 2022 23:10:37 +0800 +Subject: [PATCH] hardcode go SDKS + +If sdks was unspecified, download a full list of files. +Even if version was specified, we need to download the file list +to find the SHA-256 sum. If we don't have it, Bazel won't cache +the downloaded archive. + +But for Yocto, in order to support offline build ,we need to cache +downloaded archive, so hardcode go SDKS list files rather than +fetch from internet + +Upstream-Status: Inappropriate [Yocto specific] + +Signed-off-by: Hongxu Jia <hongxu.jia@eng.windriver.com> +--- + tensorflow/workspace2.bzl | 1 + + third_party/0001-hardcode-go-SDKS.patch | 49 +++++++++++++++++++++++++ + 2 files changed, 50 insertions(+) + create mode 100644 third_party/0001-hardcode-go-SDKS.patch + +diff --git a/tensorflow/workspace2.bzl b/tensorflow/workspace2.bzl +index 1b947d006fe..410a0ba8b54 100644 +--- a/tensorflow/workspace2.bzl ++++ b/tensorflow/workspace2.bzl +@@ -883,6 +883,7 @@ def _tf_repositories(): + # - patch upb so that it's compatible with Bazel 6.0, the latest version of upb doesn't work with the old grpc version. + tf_http_archive( + name = "io_bazel_rules_go", ++ patch_file = ["//third_party:0001-hardcode-go-SDKS.patch"], + sha256 = "16e9fca53ed6bd4ff4ad76facc9b7b651a89db1689a2877d6fd7b82aa824e366", + urls = tf_mirror_urls("https://github.com/bazelbuild/rules_go/releases/download/v0.34.0/rules_go-v0.34.0.zip"), + ) +diff --git a/third_party/0001-hardcode-go-SDKS.patch b/third_party/0001-hardcode-go-SDKS.patch +new file mode 100644 +index 00000000000..b51d7262f4c +--- /dev/null ++++ b/third_party/0001-hardcode-go-SDKS.patch +@@ -0,0 +1,49 @@ ++From 34242e73f76eff09ee33152c58c3be650331b7ff Mon Sep 17 00:00:00 2001 ++From: Hongxu Jia <hongxu.jia@eng.windriver.com> ++Date: Thu, 1 Dec 2022 15:07:10 +0000 ++Subject: [PATCH] hardcode go SDKS ++ ++If sdks was unspecified, download a full list of files. ++Even if version was specified, we need to download the file list ++to find the SHA-256 sum. If we don't have it, Bazel won't cache ++the downloaded archive. ++ ++But for Yocto, in order to support offline build ,we need to cache ++downloaded archive, so hardcode go SDKS list files rather than ++fetch from internet ++ ++Upstream-Status: Inappropriate [Yocto specific] ++ ++Signed-off-by: Hongxu Jia <hongxu.jia@eng.windriver.com> ++--- ++ go/private/sdk.bzl | 7 +++++++ ++ 1 file changed, 7 insertions(+) ++ ++diff --git a/go/private/sdk.bzl b/go/private/sdk.bzl ++index ee53cb0..3cb57ac 100755 ++--- a/go/private/sdk.bzl +++++ b/go/private/sdk.bzl ++@@ -43,6 +43,12 @@ def go_host_sdk(name, register_toolchains = True, **kwargs): ++ if register_toolchains: ++ _register_toolchains(name) ++ +++GO_SDKS = { +++ "linux_amd64": ("go1.18.4.linux-amd64.tar.gz", "c9b099b68d93f5c5c8a8844a89f8db07eaa58270e3a1e01804f17f4cf8df02f5"), +++ "linux_arm64": ("go1.18.4.linux-arm64.tar.gz", "35014d92b50d97da41dade965df7ebeb9a715da600206aa59ce1b2d05527421f"), +++ "linux_armv6l": ("go1.18.4.linux-armv6l.tar.gz", "7dfeab572e49638b0f3d9901457f0622c27b73301c2b99db9f5e9568ff40460c") +++} +++ ++ def _go_download_sdk_impl(ctx): ++ if not ctx.attr.goos and not ctx.attr.goarch: ++ goos, goarch = _detect_host_platform(ctx) ++@@ -431,6 +437,7 @@ def go_register_toolchains(version = None, nogo = None, go_version = None): ++ go_download_sdk( ++ name = "go_sdk", ++ version = version, +++ sdks = GO_SDKS, ++ ) ++ ++ if nogo: ++-- ++2.32.0 ++ +-- +2.27.0 + diff --git a/recipes-framework/tensorflow/files/0001-label_image-tweak-default-model-location.patch b/recipes-framework/tensorflow/files/0001-label_image-tweak-default-model-location.patch index e2432db..5962c90 100644 --- a/recipes-framework/tensorflow/files/0001-label_image-tweak-default-model-location.patch +++ b/recipes-framework/tensorflow/files/0001-label_image-tweak-default-model-location.patch @@ -1,6 +1,6 @@ -From 14cbd9b4740b9fcb4552a9c2160be04040415987 Mon Sep 17 00:00:00 2001 +From 17e03724c925f8d0b11c8f14699646aa498af798 Mon Sep 17 00:00:00 2001 From: Hongxu Jia <hongxu.jia@windriver.com> -Date: Mon, 25 Feb 2019 00:54:21 -0500 +Date: Mon, 16 May 2022 00:36:00 -0700 Subject: [PATCH] label_image: tweak default model location Upstream-Status: Inappropriate [oe specific] @@ -12,10 +12,10 @@ Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com> 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tensorflow/examples/label_image/label_image.py b/tensorflow/examples/label_image/label_image.py -index fe5e0fc..55e344a 100644 +index 3e4bc1ddaab..83558251d77 100644 --- a/tensorflow/examples/label_image/label_image.py +++ b/tensorflow/examples/label_image/label_image.py -@@ -73,10 +73,10 @@ def load_labels(label_file): +@@ -62,10 +62,10 @@ def load_labels(label_file): if __name__ == "__main__": @@ -30,10 +30,10 @@ index fe5e0fc..55e344a 100644 input_width = 299 input_mean = 0 diff --git a/tensorflow/examples/label_image/main.cc b/tensorflow/examples/label_image/main.cc -index ee2927d..2c59370 100644 +index 13bb5980276..38935a57dd4 100644 --- a/tensorflow/examples/label_image/main.cc +++ b/tensorflow/examples/label_image/main.cc -@@ -278,11 +278,11 @@ int main(int argc, char* argv[]) { +@@ -279,11 +279,11 @@ int main(int argc, char* argv[]) { // They define where the graph and input data is located, and what kind of // input the model expects. If you train your own model, or use something // other than inception_v3, then you'll need to update these. @@ -45,9 +45,9 @@ index ee2927d..2c59370 100644 string labels = - "tensorflow/examples/label_image/data/imagenet_slim_labels.txt"; + "/usr/share/label_image/imagenet_slim_labels.txt"; - int32 input_width = 299; - int32 input_height = 299; + int32_t input_width = 299; + int32_t input_height = 299; float input_mean = 0; -- -2.8.1 +2.36.0 diff --git a/recipes-framework/tensorflow/files/0001-label_image.lite-tweak-default-model-location.patch b/recipes-framework/tensorflow/files/0001-label_image.lite-tweak-default-model-location.patch index 9185c54..597021a 100644 --- a/recipes-framework/tensorflow/files/0001-label_image.lite-tweak-default-model-location.patch +++ b/recipes-framework/tensorflow/files/0001-label_image.lite-tweak-default-model-location.patch @@ -1,32 +1,35 @@ -From 6d519e53de0a47cebb72111608f7424d7585c6bb Mon Sep 17 00:00:00 2001 +From dd73bef88a23d29299bc6e2f3c892ed81d65a86c Mon Sep 17 00:00:00 2001 From: Hongxu Jia <hongxu.jia@windriver.com> -Date: Tue, 5 Mar 2019 22:06:34 -0500 +Date: Wed, 9 Dec 2020 09:53:30 +0800 Subject: [PATCH] label_image.lite: tweak default model location Upstream-Status: Inappropriate [oe specific] Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com> --- - tensorflow/lite/examples/label_image/label_image.h | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) + tensorflow/lite/examples/label_image/label_image.h | 8 +++++--- + 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tensorflow/lite/examples/label_image/label_image.h b/tensorflow/lite/examples/label_image/label_image.h -index 88b047f..c541fec 100644 +index 1c00edb6558..a5bcf8c64d8 100644 --- a/tensorflow/lite/examples/label_image/label_image.h +++ b/tensorflow/lite/examples/label_image/label_image.h -@@ -29,9 +29,9 @@ struct Settings { +@@ -34,10 +34,12 @@ struct Settings { int loop_count = 1; float input_mean = 127.5f; float input_std = 127.5f; - string model_name = "./mobilenet_quant_v1_224.tflite"; ++ string model_name = "/usr/share/label_image/mobilenet_v1_1.0_224_quant.tflite"; + tflite::FlatBufferModel* model; - string input_bmp_name = "./grace_hopper.bmp"; - string labels_file_name = "./labels.txt"; -+ string model_name = "/usr/share/label_image/mobilenet_v1_1.0_224_quant.tflite"; + string input_bmp_name = "/usr/share/label_image/grace_hopper.bmp"; + string labels_file_name = "/usr/share/label_image/labels_mobilenet_quant_v1_224.txt"; - string input_layer_type = "uint8_t"; ++ ++ int number_of_threads = 4; int number_of_results = 5; + int max_profiling_buffer_entries = 1024; -- -2.8.1 +2.18.2 diff --git a/recipes-framework/tensorflow/files/0001-make-hermetic-python3-support-offline-build.patch b/recipes-framework/tensorflow/files/0001-make-hermetic-python3-support-offline-build.patch new file mode 100644 index 0000000..3d9fa7f --- /dev/null +++ b/recipes-framework/tensorflow/files/0001-make-hermetic-python3-support-offline-build.patch @@ -0,0 +1,69 @@ +From deed5b2168689c08da37f94492323cc52313f29e Mon Sep 17 00:00:00 2001 +From: Hongxu Jia <hongxu.jia@windriver.com> +Date: Fri, 8 Mar 2024 11:31:26 +0800 +Subject: [PATCH] make hermetic python3 support offline build + +If environment TS_DL_DIR is set, download python whl from local archive other then +python index + +Upstream-Status: Inappropriate [Yocto specific] + +Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com> +--- + WORKSPACE | 2 ++ + third_party/0001-support-offline-build.patch | 30 ++++++++++++++++++++ + 2 files changed, 32 insertions(+) + create mode 100644 third_party/0001-support-offline-build.patch + +diff --git a/WORKSPACE b/WORKSPACE +index a697405110e..9b33f0cfdf1 100644 +--- a/WORKSPACE ++++ b/WORKSPACE +@@ -16,6 +16,8 @@ http_archive( + name = "rules_python", + sha256 = "9d04041ac92a0985e344235f5d946f71ac543f1b1565f2cdbc9a2aaee8adf55b", + strip_prefix = "rules_python-0.26.0", ++ patch_args = ["-p1"], ++ patches = ["//third_party:0001-support-offline-build.patch"], + url = "https://github.com/bazelbuild/rules_python/releases/download/0.26.0/rules_python-0.26.0.tar.gz", + ) + +diff --git a/third_party/0001-support-offline-build.patch b/third_party/0001-support-offline-build.patch +new file mode 100644 +index 00000000000..abe5e354c5b +--- /dev/null ++++ b/third_party/0001-support-offline-build.patch +@@ -0,0 +1,30 @@ ++From 82d4d1c2ff7dfa2c15c3f058fbd11b60681cad47 Mon Sep 17 00:00:00 2001 ++From: Hongxu Jia <hongxu.jia@windriver.com> ++Date: Fri, 8 Mar 2024 09:58:38 +0800 ++Subject: [PATCH] support offline build ++ ++If environment TS_DL_DIR is set, download python whl from local archive other then ++python index ++ ++Upstream-Status: Inappropriate [Yocto specific] ++ ++Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com> ++--- ++ python/pip_install/tools/wheel_installer/wheel_installer.py | 1 + ++ 1 file changed, 1 insertion(+) ++ ++diff --git a/python/pip_install/tools/wheel_installer/wheel_installer.py b/python/pip_install/tools/wheel_installer/wheel_installer.py ++index c6c2961..10421d0 100644 ++--- a/python/pip_install/tools/wheel_installer/wheel_installer.py +++++ b/python/pip_install/tools/wheel_installer/wheel_installer.py ++@@ -160,6 +160,7 @@ def main() -> None: ++ + (["--isolated"] if args.isolated else []) ++ + (["download", "--only-binary=:all:"] if args.download_only else ["wheel"]) ++ + ["--no-deps"] +++ + (["--cache-dir", os.environ.get('TS_DL_DIR')] if os.environ.get('TS_DL_DIR') else []) ++ + deserialized_args["extra_pip_args"] ++ ) ++ ++-- ++2.27.0 ++ +-- +2.27.0 + diff --git a/recipes-framework/tensorflow/files/0001-support-32-bit-x64-and-arm-for-yocto.patch b/recipes-framework/tensorflow/files/0001-support-32-bit-x64-and-arm-for-yocto.patch new file mode 100644 index 0000000..d9d79e8 --- /dev/null +++ b/recipes-framework/tensorflow/files/0001-support-32-bit-x64-and-arm-for-yocto.patch @@ -0,0 +1,125 @@ +From 161e6195a47466b354dbb9a095c5aeeba890a81a Mon Sep 17 00:00:00 2001 +From: Hongxu Jia <hongxu.jia@eng.windriver.com> +Date: Fri, 1 Mar 2024 00:28:25 -0800 +Subject: [PATCH] support 32 bit x64 and arm for yocto + +Upstream-Status: Inappropriate [oe specific] + +Rebase to 2.14.0 + +Signed-off-by: Hongxu Jia <hongxu.jia@eng.windriver.com> +--- + tensorflow/BUILD | 3 -- + tensorflow/workspace2.bzl | 2 ++ + .../0001-XNNPACK-support-32-bit-x86.patch | 29 +++++++++++++++++++ + .../0001-cpuinfo-support-32-bit-x86.patch | 28 ++++++++++++++++++ + 4 files changed, 59 insertions(+), 3 deletions(-) + create mode 100644 third_party/0001-XNNPACK-support-32-bit-x86.patch + create mode 100644 third_party/0001-cpuinfo-support-32-bit-x86.patch + +diff --git a/tensorflow/BUILD b/tensorflow/BUILD +index 0918af13243..3684d9a8757 100644 +--- a/tensorflow/BUILD ++++ b/tensorflow/BUILD +@@ -269,9 +269,6 @@ config_setting( + [], + ), + values = dict( +- if_oss( +- {"crosstool_top": "//external:android/crosstool"}, +- ), + cpu = "x86", + ), + visibility = ["//visibility:public"], +diff --git a/tensorflow/workspace2.bzl b/tensorflow/workspace2.bzl +index 9e4c2da9fe2..0aed90f6203 100644 +--- a/tensorflow/workspace2.bzl ++++ b/tensorflow/workspace2.bzl +@@ -160,6 +160,7 @@ def _tf_repositories(): + name = "XNNPACK", + sha256 = "434fe914cb52da3e66ba920082af969f527f23729fff182aecd87ac5324e9f90", + strip_prefix = "XNNPACK-dcbfffb80fb4f6fcfcfb5b3723854ec8797fa546", ++ patch_file = ["//third_party:0001-XNNPACK-support-32-bit-x86.patch"], + urls = tf_mirror_urls("https://github.com/google/XNNPACK/archive/dcbfffb80fb4f6fcfcfb5b3723854ec8797fa546.zip"), + ) + # LINT.ThenChange(//tensorflow/lite/tools/cmake/modules/xnnpack.cmake) +@@ -182,6 +183,7 @@ def _tf_repositories(): + name = "cpuinfo", + strip_prefix = "cpuinfo-ef634603954d88d2643d5809011288b890ac126e", + sha256 = "e07512a11e1c71687359a133f49d60583d7465b737fe5dbe11f461c9aaa72a2b", ++ patch_file = ["//third_party:0001-cpuinfo-support-32-bit-x86.patch"], + urls = tf_mirror_urls("https://github.com/pytorch/cpuinfo/archive/ef634603954d88d2643d5809011288b890ac126e.zip"), + ) + +diff --git a/third_party/0001-XNNPACK-support-32-bit-x86.patch b/third_party/0001-XNNPACK-support-32-bit-x86.patch +new file mode 100644 +index 00000000000..9d7e91ff9fe +--- /dev/null ++++ b/third_party/0001-XNNPACK-support-32-bit-x86.patch +@@ -0,0 +1,29 @@ ++From 13f013db421c5aefa021f3b75d9d8554ad4fde52 Mon Sep 17 00:00:00 2001 ++From: Hongxu Jia <hongxu.jia@eng.windriver.com> ++Date: Fri, 1 Mar 2024 00:35:18 -0800 ++Subject: [PATCH] XNNPACK: support 32 bit x86 ++ ++Use android_x86 as a workaround to support 32 bit x86 ++ ++Upstream-Status: Inappropriate [oe specific] ++ ++Signed-off-by: Hongxu Jia <hongxu.jia@eng.windriver.com> ++--- ++ build_config/BUILD.bazel | 1 - ++ 1 file changed, 1 deletion(-) ++ ++diff --git a/build_config/BUILD.bazel b/build_config/BUILD.bazel ++index d0b8902..75dfb79 100644 ++--- a/build_config/BUILD.bazel +++++ b/build_config/BUILD.bazel ++@@ -73,7 +73,6 @@ config_setting( ++ config_setting( ++ name = "android_x86", ++ values = { ++- "crosstool_top": "//external:android/crosstool", ++ "cpu": "x86", ++ }, ++ ) ++-- ++2.42.0 ++ +diff --git a/third_party/0001-cpuinfo-support-32-bit-x86.patch b/third_party/0001-cpuinfo-support-32-bit-x86.patch +new file mode 100644 +index 00000000000..0c83cf01675 +--- /dev/null ++++ b/third_party/0001-cpuinfo-support-32-bit-x86.patch +@@ -0,0 +1,28 @@ ++From f5e52b2db5516954dab9026e4f386982c4c3c3a4 Mon Sep 17 00:00:00 2001 ++From: Hongxu Jia <hongxu.jia@windriver.com> ++Date: Mon, 19 Sep 2022 00:10:18 -0700 ++Subject: [PATCH] cpuinfo: support 32 bit x86 ++ ++Use android_x86 as a workaround to support 32 bit x86 ++ ++Upstream-Status: Inappropriate [oe specific] ++Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com> ++--- ++ BUILD.bazel | 1 - ++ 1 file changed, 1 deletion(-) ++ ++diff --git a/BUILD.bazel b/BUILD.bazel ++index 7c002fe..68fd5b5 100644 ++--- a/BUILD.bazel +++++ b/BUILD.bazel ++@@ -274,7 +274,6 @@ config_setting( ++ config_setting( ++ name = "android_x86", ++ values = { ++- "crosstool_top": "//external:android/crosstool", ++ "cpu": "x86", ++ }, ++ visibility = ["//visibility:public"], ++-- ++2.37.1 ++ +-- +2.42.0 + diff --git a/recipes-framework/tensorflow/files/0001-support-hermetic-Python.patch b/recipes-framework/tensorflow/files/0001-support-hermetic-Python.patch new file mode 100644 index 0000000..a1be846 --- /dev/null +++ b/recipes-framework/tensorflow/files/0001-support-hermetic-Python.patch @@ -0,0 +1,75 @@ +From cd7dc62667df74f9e4c8293dbc087a3ed10c8890 Mon Sep 17 00:00:00 2001 +From: Hongxu Jia <hongxu.jia@windriver.com> +Date: Mon, 4 Mar 2024 17:44:35 +0800 +Subject: [PATCH] support hermetic Python + +Due to commit [e85860e8382 use hermetic Python in Tensorflow. See +ci/official/requirements_updater/README.md for details.] applied + +It use hermetic Python to instead of external Python + +Upstream-Status: Inappropriate [Yocto specific] + +Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com> +--- + tensorflow/BUILD | 3 +++ + tensorflow/compiler/tf2tensorrt/BUILD | 1 + + tensorflow/python/BUILD | 2 ++ + tensorflow/tensorflow.bzl | 2 ++ + 4 files changed, 8 insertions(+) + +diff --git a/tensorflow/BUILD b/tensorflow/BUILD +index 24c2bbf82ef..0bf6127ffd1 100644 +--- a/tensorflow/BUILD ++++ b/tensorflow/BUILD +@@ -134,6 +134,9 @@ PACKAGE_STATIC_DEPS = [ + "@riegeli//:__subpackages__", + "@org_brotli//:__subpackages__", + "@net_zstd//:__subpackages__", ++ "@ducc//:__subpackages__", ++ "@pybind11//:__subpackages__", ++ "@python_x86_64-unknown-linux-gnu//:__subpackages__", + ] + tsl_async_value_deps() + + package( +diff --git a/tensorflow/compiler/tf2tensorrt/BUILD b/tensorflow/compiler/tf2tensorrt/BUILD +index 91ef722b52d..320c3e80e6c 100644 +--- a/tensorflow/compiler/tf2tensorrt/BUILD ++++ b/tensorflow/compiler/tf2tensorrt/BUILD +@@ -1097,6 +1097,7 @@ pybind_extension( + "@zlib//:__subpackages__", + "@local_tsl//tsl:__subpackages__", + "@local_xla//xla:__subpackages__", ++ "@python_x86_64-unknown-linux-gnu//:__subpackages__", + ], + deps = [ + ":common_utils", +diff --git a/tensorflow/python/BUILD b/tensorflow/python/BUILD +index 675709d4314..65b3fd20b4f 100644 +--- a/tensorflow/python/BUILD ++++ b/tensorflow/python/BUILD +@@ -741,6 +741,8 @@ pywrap_tensorflow_macro( + "@zlib//:__subpackages__", + "@local_tsl//tsl:__subpackages__", + "@local_xla//xla:__subpackages__", ++ "@pypi_numpy//:__subpackages__", ++ "@python_x86_64-unknown-linux-gnu//:__subpackages__", + ] + tsl_async_value_deps(), + win_def_file = ":pywrap_tensorflow_filtered_def_file", + deps = [ +diff --git a/tensorflow/tensorflow.bzl b/tensorflow/tensorflow.bzl +index 45c597b3ef4..d821a60aa5f 100644 +--- a/tensorflow/tensorflow.bzl ++++ b/tensorflow/tensorflow.bzl +@@ -3304,6 +3304,8 @@ def tf_python_pybind_static_deps(testonly = False): + "@upb//:__subpackages__", + "@zlib//:__subpackages__", + "@local_tsl//tsl:__subpackages__", ++ "@python_x86_64-unknown-linux-gnu//:__subpackages__", ++ "@pypi_numpy//:__subpackages__", + ] + static_deps += tsl_async_value_deps() + static_deps += [] if not testonly else [ +-- +2.27.0 + diff --git a/recipes-framework/tensorflow/files/0001-support-musl.patch b/recipes-framework/tensorflow/files/0001-support-musl.patch deleted file mode 100644 index f76041b..0000000 --- a/recipes-framework/tensorflow/files/0001-support-musl.patch +++ /dev/null @@ -1,49 +0,0 @@ -From 02e58aa624aa6c330984474b9119c6b29a1ed77d Mon Sep 17 00:00:00 2001 -From: Hongxu Jia <hongxu.jia@windriver.com> -Date: Thu, 14 Feb 2019 10:26:27 -0500 -Subject: [PATCH] support musl - -Build fails looking for `execinfo.h` when building against musl -|In file included from ./tensorflow/core/platform/stacktrace.h:26, -| from tensorflow/core/platform/stacktrace_handler.cc:34: -|./tensorflow/core/platform/default/stacktrace.h:27:10: fatal error: -execinfo.h: No such file or directory - -Upstream-Status: Pending -Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com> ---- - tensorflow/core/platform/default/stacktrace.h | 3 ++- - tensorflow/core/platform/stacktrace_handler.cc | 3 ++- - 2 files changed, 4 insertions(+), 2 deletions(-) - -diff --git a/tensorflow/core/platform/default/stacktrace.h b/tensorflow/core/platform/default/stacktrace.h -index c8e297f..8fecf05 100644 ---- a/tensorflow/core/platform/default/stacktrace.h -+++ b/tensorflow/core/platform/default/stacktrace.h -@@ -18,7 +18,8 @@ limitations under the License. - - #include "tensorflow/core/platform/platform.h" - #if !defined(IS_MOBILE_PLATFORM) && defined(PLATFORM_POSIX) && \ -- (defined(__clang__) || defined(__GNUC__)) -+ (defined(__clang__) || defined(__GNUC__)) && \ -+ defined(__GLIBC__) - #define TF_GENERATE_BACKTRACE - #endif - -diff --git a/tensorflow/core/platform/stacktrace_handler.cc b/tensorflow/core/platform/stacktrace_handler.cc -index ff31c97..41d62f7 100644 ---- a/tensorflow/core/platform/stacktrace_handler.cc -+++ b/tensorflow/core/platform/stacktrace_handler.cc -@@ -16,7 +16,8 @@ limitations under the License. - #include "tensorflow/core/platform/platform.h" - - #if !defined(PLATFORM_GOOGLE) && !defined(IS_MOBILE_PLATFORM) && \ -- defined(PLATFORM_POSIX) && (defined(__clang__) || defined(__GNUC__)) -+ defined(PLATFORM_POSIX) && (defined(__clang__) || defined(__GNUC__)) && \ -+ defined(__GLIBC__) - #define TF_GENERATE_STACKTRACE - #endif - --- -2.8.1 - diff --git a/recipes-framework/tensorflow/files/0001-third_party-eigen_archive-workaround-ice-failure-whi.patch b/recipes-framework/tensorflow/files/0001-third_party-eigen_archive-workaround-ice-failure-whi.patch new file mode 100644 index 0000000..b1571ab --- /dev/null +++ b/recipes-framework/tensorflow/files/0001-third_party-eigen_archive-workaround-ice-failure-whi.patch @@ -0,0 +1,111 @@ +From 385074d9300c18293a42c9d8ca9fb12cbffccb80 Mon Sep 17 00:00:00 2001 +From: Hongxu Jia <hongxu.jia@windriver.com> +Date: Mon, 16 May 2022 23:15:47 -0700 +Subject: [PATCH] third_party/eigen_archive:workaround ice failure while + building from source with gcc 7.3.1 + +The root cause is gcc ice issue: +https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89752 + +But we could not patch on native gcc,so try to workaround, +Refer: https://github.com/tensorflow/tensorflow/issues/25323 + +Upstream-Status: Inappropriate [wr-installer specific] + +Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com> +--- + ...ailure-while-building-from-source-wi.patch | 69 +++++++++++++++++++ + third_party/eigen3/workspace.bzl | 1 + + 2 files changed, 70 insertions(+) + create mode 100644 third_party/eigen3/0001-workaround-ice-failure-while-building-from-source-wi.patch + +diff --git a/third_party/eigen3/0001-workaround-ice-failure-while-building-from-source-wi.patch b/third_party/eigen3/0001-workaround-ice-failure-while-building-from-source-wi.patch +new file mode 100644 +index 00000000000..436f35fca13 +--- /dev/null ++++ b/third_party/eigen3/0001-workaround-ice-failure-while-building-from-source-wi.patch +@@ -0,0 +1,69 @@ ++From 035fd96026e18d61c19da038ab2b0f7a61e97799 Mon Sep 17 00:00:00 2001 ++From: Hongxu Jia <hongxu.jia@windriver.com> ++Date: Mon, 19 Sep 2022 01:08:18 -0700 ++Subject: [PATCH] workaround ice failure while building from source with gcc ++ 7.3.1 ++ ++The root cause is gcc ice issue: ++https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89752 ++ ++But we could not patch on native gcc,so try to workaround, ++Refer: https://github.com/tensorflow/tensorflow/issues/25323 ++ ++Upstream-Status: Inappropriate [wr-installer specific] ++ ++Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com> ++--- ++ unsupported/Eigen/CXX11/src/Tensor/TensorImagePatch.h | 3 ++- ++ unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h | 9 ++++++--- ++ 2 files changed, 8 insertions(+), 4 deletions(-) ++ ++diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorImagePatch.h b/unsupported/Eigen/CXX11/src/Tensor/TensorImagePatch.h ++index a9b281f..ec570d6 100644 ++--- a/unsupported/Eigen/CXX11/src/Tensor/TensorImagePatch.h +++++ b/unsupported/Eigen/CXX11/src/Tensor/TensorImagePatch.h ++@@ -544,7 +544,8 @@ struct TensorEvaluator<const TensorImagePatchOp<Rows, Cols, ArgType>, Device> ++ EIGEN_ALIGN_MAX std::remove_const_t<CoeffReturnType> values[PacketSize]; ++ EIGEN_UNROLL_LOOP ++ for (int i = 0; i < PacketSize; ++i) { ++- values[i] = coeff(index+i); +++ Self::CoeffReturnType a = coeff(index+i); +++ values[i] = a; ++ } ++ PacketReturnType rslt = internal::pload<PacketReturnType>(values); ++ return rslt; ++diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h ++index e62397a..fcd44c3 100644 ++--- a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h +++++ b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h ++@@ -850,8 +850,9 @@ static constexpr bool RunningOnGPU = false; ++ const Index firstIndex = firstInput(index); ++ for (Index i = 0; i < PacketSize; ++i) { ++ Op reducer(m_reducer); ++- values[i] = internal::InnerMostDimReducer<Self, Op>::reduce(*this, firstIndex + i * num_values_to_reduce, +++ Self::CoeffReturnType a = internal::InnerMostDimReducer<Self, Op>::reduce(*this, firstIndex + i * num_values_to_reduce, ++ num_values_to_reduce, reducer); +++ values[i] = a; ++ } ++ } else if (PreservingInnerMostDims) { ++ const Index firstIndex = firstInput(index); ++@@ -864,12 +865,14 @@ static constexpr bool RunningOnGPU = false; ++ return reducer.finalizePacket(accum); ++ } else { ++ for (int i = 0; i < PacketSize; ++i) { ++- values[i] = coeff(index + i); +++ Self::CoeffReturnType a = coeff(index + i); +++ values[i] = a; ++ } ++ } ++ } else { ++ for (int i = 0; i < PacketSize; ++i) { ++- values[i] = coeff(index + i); +++ Self::CoeffReturnType a = coeff(index + i); +++ values[i] = a; ++ } ++ } ++ PacketReturnType rslt = internal::pload<PacketReturnType>(values); ++-- ++2.37.1 ++ +diff --git a/third_party/eigen3/workspace.bzl b/third_party/eigen3/workspace.bzl +index 1380722ee67..722cfbece83 100644 +--- a/third_party/eigen3/workspace.bzl ++++ b/third_party/eigen3/workspace.bzl +@@ -14,6 +14,7 @@ def repo(): + tf_http_archive( + name = "eigen_archive", + build_file = "//third_party/eigen3:eigen_archive.BUILD", ++ patch_file = ["//third_party/eigen3:0001-workaround-ice-failure-while-building-from-source-wi.patch"], + sha256 = EIGEN_SHA256, + strip_prefix = "eigen-{commit}".format(commit = EIGEN_COMMIT), + urls = tf_mirror_urls("https://gitlab.com/libeigen/eigen/-/archive/{commit}/eigen-{commit}.tar.gz".format(commit = EIGEN_COMMIT)), +-- +2.37.1 + diff --git a/recipes-framework/tensorflow/files/0001-use-local-bazel-to-workaround-bazel-paralle-issue.patch b/recipes-framework/tensorflow/files/0001-use-local-bazel-to-workaround-bazel-paralle-issue.patch index 14e8e47..8a17700 100644 --- a/recipes-framework/tensorflow/files/0001-use-local-bazel-to-workaround-bazel-paralle-issue.patch +++ b/recipes-framework/tensorflow/files/0001-use-local-bazel-to-workaround-bazel-paralle-issue.patch @@ -1,28 +1,29 @@ -From ecc7014fe42ac0bc7bc502f2671a8da09c90d6ea Mon Sep 17 00:00:00 2001 +From bbdf1bbca17f8bce98e32b25aa9bfadc8f465f24 Mon Sep 17 00:00:00 2001 From: Hongxu Jia <hongxu.jia@windriver.com> -Date: Wed, 13 Mar 2019 17:55:08 +0800 +Date: Sun, 15 May 2022 23:59:17 -0700 Subject: [PATCH] use local bazel to workaround bazel paralle issue Upstream-Status: Inappropriate [oe specific] Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com> +Signed-off-by: Julien STEPHAN <jstephan@baylibre.com> --- configure.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.py b/configure.py -index 4f8cae2..2121a90 100644 +index dae3dce89d3..979f00f3633 100644 --- a/configure.py +++ b/configure.py -@@ -454,7 +454,7 @@ def check_bazel_version(min_version, max_version): - print('Cannot find bazel. Please install bazel.') - sys.exit(0) - curr_version = run_shell( -- ['bazel', '--batch', '--bazelrc=/dev/null', 'version']) -+ ['../bazel/bazel', '--batch', '--bazelrc=/dev/null', 'version']) - - for line in curr_version.split('\n'): - if 'Build label: ' in line: +@@ -475,7 +475,7 @@ def check_bazel_version(min_version, max_version): + Returns: + The bazel version detected. + """ +- bazel_executable = which('bazel') ++ bazel_executable = "%%WORKDIR%%/bazel/bazel" + if bazel_executable is None: + bazel_executable = which('bazelisk') + if bazel_executable is None: -- -2.7.4 +2.36.0 diff --git a/recipes-framework/tensorflow/files/0002-Replace-distutils.sysconfig.get_python_lib-with-sysc.patch b/recipes-framework/tensorflow/files/0002-Replace-distutils.sysconfig.get_python_lib-with-sysc.patch new file mode 100644 index 0000000..acde266 --- /dev/null +++ b/recipes-framework/tensorflow/files/0002-Replace-distutils.sysconfig.get_python_lib-with-sysc.patch @@ -0,0 +1,73 @@ +From 3b3b8bc65c30fb5ac2a3d5beaa424b27ceb41dc8 Mon Sep 17 00:00:00 2001 +From: Hongxu Jia <hongxu.jia@eng.windriver.com> +Date: Thu, 29 Feb 2024 23:26:53 -0800 +Subject: [PATCH] eplace distutils.sysconfig.get_python_lib() with + sysconfig.get_path('purelib') - python 3.10 support + +This is part of the effort for 51776 to get python 3.10 support. +This PR replace distutils.sysconfig.get_python_lib() with sysconfig.get_path('purelib') +as distutils has been deprecated by python 3.10. + +Note sysconfig has been available since python 3.2. + +Signed-off-by: Yong Tang <yong.tang.github@outlook.com> + +Upstream-Status: Backport from tensorflow github +[https://github.com/tensorflow/tensorflow/pull/51865] + +Rebase to 2.16 +Signed-off-by: Hongxu Jia <hongxu.jia@eng.windriver.com> +--- + tensorflow/api_template.__init__.py | 5 ++--- + tensorflow/api_template_v1.__init__.py | 5 ++--- + 2 files changed, 4 insertions(+), 6 deletions(-) + +diff --git a/tensorflow/api_template.__init__.py b/tensorflow/api_template.__init__.py +index a0f88926b5e..d98c045bdeb 100644 +--- a/tensorflow/api_template.__init__.py ++++ b/tensorflow/api_template.__init__.py +@@ -27,7 +27,7 @@ this file with a file generated from [`api_template.__init__.py`](https://www.gi + """ + # pylint: disable=g-bad-import-order,protected-access,g-import-not-at-top + +-import distutils as _distutils ++import sysconfig as _sysconfig + import importlib + import inspect as _inspect + import os as _os +@@ -98,8 +98,7 @@ _site_packages_dirs += [p for p in _sys.path if "site-packages" in p] + if "getsitepackages" in dir(_site): + _site_packages_dirs += _site.getsitepackages() + +-if "sysconfig" in dir(_distutils): +- _site_packages_dirs += [_distutils.sysconfig.get_python_lib()] ++_site_packages_dirs += [_sysconfig.get_path('purelib')] + + _site_packages_dirs = list(set(_site_packages_dirs)) + +diff --git a/tensorflow/api_template_v1.__init__.py b/tensorflow/api_template_v1.__init__.py +index 6a4ab4e655f..012c54f7fed 100644 +--- a/tensorflow/api_template_v1.__init__.py ++++ b/tensorflow/api_template_v1.__init__.py +@@ -14,7 +14,7 @@ + # ============================================================================== + """Bring in all of the public TensorFlow interface into this module.""" + +-import distutils as _distutils ++import sysconfig as _sysconfig + import importlib + import inspect as _inspect + import os as _os +@@ -147,8 +147,7 @@ _site_packages_dirs += [p for p in _sys.path if "site-packages" in p] + if "getsitepackages" in dir(_site): + _site_packages_dirs += _site.getsitepackages() + +-if "sysconfig" in dir(_distutils): +- _site_packages_dirs += [_distutils.sysconfig.get_python_lib()] ++_site_packages_dirs += [_sysconfig.get_path('purelib')] + + _site_packages_dirs = list(set(_site_packages_dirs)) + +-- +2.42.0 + diff --git a/recipes-framework/tensorflow/files/BUILD b/recipes-framework/tensorflow/files/BUILD deleted file mode 100644 index fd1f99a..0000000 --- a/recipes-framework/tensorflow/files/BUILD +++ /dev/null @@ -1,56 +0,0 @@ -package(default_visibility = ["//visibility:public"]) - -cc_toolchain_suite( - name = "toolchain", - toolchains = { - "armeabi|compiler": ":cc-compiler-armeabi", - "local|compiler": ":cc-compiler-local", - "armeabi": ":cc-compiler-armeabi", - "k8": ":cc-compiler-local", - "piii": ":cc-compiler-local", - "arm": ":cc-compiler-local", - "s390x": ":cc-compiler-local", - }, -) - -filegroup( - name = "empty", - srcs = [], -) - -filegroup( - name = "arm_linux_all_files", - srcs = [ - "@yocto_compiler//:compiler_pieces", - ], -) - -cc_toolchain( - name = "cc-compiler-local", - all_files = ":empty", - compiler_files = ":empty", - cpu = "local", - dwp_files = ":empty", - dynamic_runtime_libs = [":empty"], - linker_files = ":empty", - objcopy_files = ":empty", - static_runtime_libs = [":empty"], - strip_files = ":empty", - supports_param_files = 1, - toolchain_identifier = "local_linux", -) - -cc_toolchain( - name = "cc-compiler-armeabi", - all_files = ":arm_linux_all_files", - compiler_files = ":arm_linux_all_files", - cpu = "armeabi", - dwp_files = ":empty", - dynamic_runtime_libs = [":empty"], - linker_files = ":arm_linux_all_files", - objcopy_files = "arm_linux_all_files", - static_runtime_libs = [":empty"], - strip_files = "arm_linux_all_files", - supports_param_files = 1, - toolchain_identifier = "yocto-linux-gnueabihf", -) diff --git a/recipes-framework/tensorflow/files/BUILD.in b/recipes-framework/tensorflow/files/BUILD.in new file mode 100644 index 0000000..2e230a6 --- /dev/null +++ b/recipes-framework/tensorflow/files/BUILD.in @@ -0,0 +1,40 @@ +package(default_visibility = ["//visibility:public"]) + +load(":cc_config.bzl", "cc_toolchain_config") + +cc_toolchain_suite( + name = "toolchain", + toolchains = { + "%%CPU%%": ":cc-compiler-yocto", + }, +) + +filegroup( + name = "empty", + srcs = [], +) + +filegroup( + name = "yocto_linux_all_files", + srcs = [ + "@yocto_compiler//:compiler_pieces", + ], +) + +cc_toolchain_config( + name = "yocto_config", + cpu = "%%CPU%%", +) + +cc_toolchain( + name = "cc-compiler-yocto", + all_files = ":yocto_linux_all_files", + compiler_files = ":yocto_linux_all_files", + dwp_files = ":empty", + linker_files = ":yocto_linux_all_files", + objcopy_files = "yocto_linux_all_files", + strip_files = "yocto_linux_all_files", + supports_param_files = 1, + toolchain_config = ":yocto_config", + toolchain_identifier = "yocto-linux-toolchain", +) diff --git a/recipes-framework/tensorflow/files/CROSSTOOL.tpl b/recipes-framework/tensorflow/files/CROSSTOOL.tpl deleted file mode 100644 index 296d6a6..0000000 --- a/recipes-framework/tensorflow/files/CROSSTOOL.tpl +++ /dev/null @@ -1,229 +0,0 @@ -major_version: "local" -minor_version: "" -default_target_cpu: "same_as_host" - -toolchain { - abi_version: "armeabi" - abi_libc_version: "armeabi" - builtin_sysroot: "" - compiler: "compiler" - host_system_name: "armeabi" - needsPic: true - supports_gold_linker: false - supports_incremental_linker: false - supports_fission: false - supports_interface_shared_objects: false - supports_normalizing_ar: false - supports_start_end_lib: false - target_libc: "armeabi" - target_cpu: "armeabi" - target_system_name: "armeabi" - toolchain_identifier: "yocto-linux-gnueabihf" - - tool_path { name: "ar" path: "%%YOCTO_COMPILER_PATH%%/recipe-sysroot-native/usr/bin/%%CT_NAME%%/%%CT_NAME%%-ar" } - tool_path { name: "compat-ld" path: "/bin/false" } - tool_path { name: "cpp" path: "%%YOCTO_COMPILER_PATH%%/recipe-sysroot-native/usr/bin/%%CT_NAME%%/%%CT_NAME%%-cpp" } - tool_path { name: "dwp" path: "%%YOCTO_COMPILER_PATH%%/recipe-sysroot-native/usr/bin/%%CT_NAME%%/%%CT_NAME%%-dwp" } - tool_path { name: "gcc" path: "%%YOCTO_COMPILER_PATH%%/recipe-sysroot-native/usr/bin/%%CT_NAME%%/%%CT_NAME%%-gcc" } - tool_path { name: "gcov" path: "%%YOCTO_COMPILER_PATH%%/recipe-sysroot-native/usr/bin/%%CT_NAME%%/%%CT_NAME%%-gcov" } - tool_path { name: "ld" path: "%%YOCTO_COMPILER_PATH%%/recipe-sysroot-native/usr/bin/%%CT_NAME%%/%%CT_NAME%%-ld" } - - tool_path { name: "nm" path: "%%YOCTO_COMPILER_PATH%%/recipe-sysroot-native/usr/bin/%%CT_NAME%%/%%CT_NAME%%-nm" } - tool_path { name: "objcopy" path: "%%YOCTO_COMPILER_PATH%%/recipe-sysroot-native/usr/bin/%%CT_NAME%%/%%CT_NAME%%-objcopy" } - tool_path { name: "objdump" path: "%%YOCTO_COMPILER_PATH%%/recipe-sysroot-native/usr/bin/%%CT_NAME%%/%%CT_NAME%%-objdump" } - tool_path { name: "strip" path: "%%YOCTO_COMPILER_PATH%%/recipe-sysroot-native/usr/bin/%%CT_NAME%%/%%CT_NAME%%-strip" } - - - cxx_builtin_include_directory: "%%YOCTO_COMPILER_PATH%%" - - compiler_flag: "--sysroot=%%YOCTO_COMPILER_PATH%%/recipe-sysroot" - - # The path below must match the one used in - # tensorflow/tools/ci_build/pi/build_raspberry_pi.sh. - cxx_builtin_include_directory: "/tmp/openblas_install/include/" - cxx_flag: "-std=c++11" - # The cxx_builtin_include_directory directives don't seem to be adding these, so - # explicitly set them as flags. There's a query to the Bazel team outstanding about - # why this is necessary. - linker_flag: "-lstdc++" - - unfiltered_cxx_flag: "-Wno-builtin-macro-redefined" - unfiltered_cxx_flag: "-D__DATE__=\"redacted\"" - unfiltered_cxx_flag: "-D__TIMESTAMP__=\"redacted\"" - unfiltered_cxx_flag: "-D__TIME__=\"redacted\"" - - unfiltered_cxx_flag: "-no-canonical-prefixes" - unfiltered_cxx_flag: "-fno-canonical-system-headers" - - # Include target pyconfig.h - compiler_flag: "-D_PYTHON_INCLUDE_TARGET" - - compiler_flag: "-U_FORTIFY_SOURCE" - compiler_flag: "-D_FORTIFY_SOURCE=1" - compiler_flag: "-fstack-protector" - compiler_flag: "-DRASPBERRY_PI" # To differentiate from mobile builds. - linker_flag: "-Wl,-z,relro,-z,now" - - linker_flag: "-no-canonical-prefixes" - linker_flag: "-pass-exit-codes" - - linker_flag: "-Wl,--build-id=md5" - - compilation_mode_flags { - mode: DBG - # Enable debug symbols. - compiler_flag: "-g" - } - compilation_mode_flags { - mode: OPT - - # No debug symbols. - # Maybe we should enable https://gcc.gnu.org/wiki/DebugFission for opt or - # even generally? However, that can't happen here, as it requires special - # handling in Bazel. - compiler_flag: "-g0" - - # Conservative choice for -O - # -O3 can increase binary size and even slow down the resulting binaries. - # Profile first and / or use FDO if you need better performance than this. - compiler_flag: "-O2" - - # Disable assertions - compiler_flag: "-DNDEBUG" - - # Removal of unused code and data at link time (can this increase binary size in some cases?). - compiler_flag: "-ffunction-sections" - compiler_flag: "-fdata-sections" - linker_flag: "-Wl,--gc-sections" - } - linking_mode_flags { mode: DYNAMIC } - -} - -toolchain { - abi_version: "local" - abi_libc_version: "local" - builtin_sysroot: "" - compiler: "compiler" - host_system_name: "local" - needsPic: true - supports_gold_linker: false - supports_incremental_linker: false - supports_fission: false - supports_interface_shared_objects: false - supports_normalizing_ar: false - supports_start_end_lib: false - target_libc: "local" - target_cpu: "local" - target_system_name: "local" - toolchain_identifier: "local_linux" - - tool_path { name: "ar" path: "/usr/bin/ar" } - tool_path { name: "compat-ld" path: "/usr/bin/ld" } - tool_path { name: "cpp" path: "/usr/bin/cpp" } - tool_path { name: "dwp" path: "/usr/bin/dwp" } - tool_path { name: "gcc" path: "/usr/bin/gcc" } - cxx_flag: "-std=c++0x" - linker_flag: "-lstdc++" - linker_flag: "-B/usr/bin/" - - # TODO(bazel-team): In theory, the path here ought to exactly match the path - # used by gcc. That works because bazel currently doesn't track files at - # absolute locations and has no remote execution, yet. However, this will need - # to be fixed, maybe with auto-detection? - cxx_builtin_include_directory: "/usr/lib/gcc/" - cxx_builtin_include_directory: "/usr/local/include" - cxx_builtin_include_directory: "/usr/include" - cxx_builtin_include_directory: "%%YOCTO_COMPILER_PATH%%/recipe-sysroot-native/usr/include" - - tool_path { name: "gcov" path: "/usr/bin/gcov" } - - # C(++) compiles invoke the compiler (as that is the one knowing where - # to find libraries), but we provide LD so other rules can invoke the linker. - tool_path { name: "ld" path: "/usr/bin/ld" } - - tool_path { name: "nm" path: "/usr/bin/nm" } - tool_path { name: "objcopy" path: "/usr/bin/objcopy" } - objcopy_embed_flag: "-I" - objcopy_embed_flag: "binary" - tool_path { name: "objdump" path: "/usr/bin/objdump" } - tool_path { name: "strip" path: "/usr/bin/strip" } - - # Anticipated future default. - unfiltered_cxx_flag: "-no-canonical-prefixes" - unfiltered_cxx_flag: "-fno-canonical-system-headers" - - # Make C++ compilation deterministic. Use linkstamping instead of these - # compiler symbols. - unfiltered_cxx_flag: "-Wno-builtin-macro-redefined" - unfiltered_cxx_flag: "-D__DATE__=\"redacted\"" - unfiltered_cxx_flag: "-D__TIMESTAMP__=\"redacted\"" - unfiltered_cxx_flag: "-D__TIME__=\"redacted\"" - - # Security hardening on by default. - # Conservative choice; -D_FORTIFY_SOURCE=2 may be unsafe in some cases. - # We need to undef it before redefining it as some distributions now have - # it enabled by default. - compiler_flag: "-U_FORTIFY_SOURCE" - compiler_flag: "-D_FORTIFY_SOURCE=1" - compiler_flag: "-fstack-protector" - linker_flag: "-Wl,-z,relro,-z,now" - - # Include native pyconfig.h - compiler_flag: "-D_PYTHON_INCLUDE_NATIVE" - - # Enable coloring even if there's no attached terminal. Bazel removes the - # escape sequences if --nocolor is specified. This isn't supported by gcc - # on Ubuntu 14.04. - # compiler_flag: "-fcolor-diagnostics" - - # All warnings are enabled. Maybe enable -Werror as well? - compiler_flag: "-Wall" - # Enable a few more warnings that aren't part of -Wall. - compiler_flag: "-Wunused-but-set-parameter" - # But disable some that are problematic. - compiler_flag: "-Wno-free-nonheap-object" # has false positives - - # Keep stack frames for debugging, even in opt mode. - compiler_flag: "-fno-omit-frame-pointer" - - # Anticipated future default. - linker_flag: "-no-canonical-prefixes" - # Have gcc return the exit code from ld. - linker_flag: "-pass-exit-codes" - # Stamp the binary with a unique identifier. - linker_flag: "-Wl,--build-id=md5" - linker_flag: "-Wl,--hash-style=gnu" - # Gold linker only? Can we enable this by default? - # linker_flag: "-Wl,--warn-execstack" - # linker_flag: "-Wl,--detect-odr-violations" - - compilation_mode_flags { - mode: DBG - # Enable debug symbols. - compiler_flag: "-g" - } - compilation_mode_flags { - mode: OPT - - # No debug symbols. - # Maybe we should enable https://gcc.gnu.org/wiki/DebugFission for opt or - # even generally? However, that can't happen here, as it requires special - # handling in Bazel. - compiler_flag: "-g0" - - # Conservative choice for -O - # -O3 can increase binary size and even slow down the resulting binaries. - # Profile first and / or use FDO if you need better performance than this. - compiler_flag: "-O2" - - # Disable assertions - compiler_flag: "-DNDEBUG" - - # Removal of unused code and data at link time (can this increase binary size in some cases?). - compiler_flag: "-ffunction-sections" - compiler_flag: "-fdata-sections" - linker_flag: "-Wl,--gc-sections" - } - linking_mode_flags { mode: DYNAMIC } -} diff --git a/recipes-framework/tensorflow/files/cc_config.bzl.tpl b/recipes-framework/tensorflow/files/cc_config.bzl.tpl new file mode 100644 index 0000000..7ab7ea8 --- /dev/null +++ b/recipes-framework/tensorflow/files/cc_config.bzl.tpl @@ -0,0 +1,411 @@ +load("@bazel_tools//tools/cpp:cc_toolchain_config_lib.bzl", + "action_config", + "artifact_name_pattern", + "env_entry", + "env_set", + "feature", + "feature_set", + "flag_group", + "flag_set", + "make_variable", + "tool", + "tool_path", + "variable_with_value", + "with_feature_set", +) +load("@bazel_tools//tools/build_defs/cc:action_names.bzl", "ACTION_NAMES") + +def _impl(ctx): + toolchain_identifier = "yocto-linux-toolchain" + host_system_name = ctx.attr.cpu + target_system_name = ctx.attr.cpu + target_cpu = ctx.attr.cpu + target_libc = ctx.attr.cpu + abi_version = ctx.attr.cpu + abi_libc_version = ctx.attr.cpu + + compiler = "compiler" + + cc_target_os = None + + builtin_sysroot = None + + all_compile_actions = [ + ACTION_NAMES.c_compile, + ACTION_NAMES.cpp_compile, + ACTION_NAMES.linkstamp_compile, + ACTION_NAMES.assemble, + ACTION_NAMES.preprocess_assemble, + ACTION_NAMES.cpp_header_parsing, + ACTION_NAMES.cpp_module_compile, + ACTION_NAMES.cpp_module_codegen, + ACTION_NAMES.clif_match, + ACTION_NAMES.lto_backend, + ] + + all_cpp_compile_actions = [ + ACTION_NAMES.cpp_compile, + ACTION_NAMES.linkstamp_compile, + ACTION_NAMES.cpp_header_parsing, + ACTION_NAMES.cpp_module_compile, + ACTION_NAMES.cpp_module_codegen, + ACTION_NAMES.clif_match, + ] + + preprocessor_compile_actions = [ + ACTION_NAMES.c_compile, + ACTION_NAMES.cpp_compile, + ACTION_NAMES.linkstamp_compile, + ACTION_NAMES.preprocess_assemble, + ACTION_NAMES.cpp_header_parsing, + ACTION_NAMES.cpp_module_compile, + ACTION_NAMES.clif_match, + ] + + codegen_compile_actions = [ + ACTION_NAMES.c_compile, + ACTION_NAMES.cpp_compile, + ACTION_NAMES.linkstamp_compile, + ACTION_NAMES.assemble, + ACTION_NAMES.preprocess_assemble, + ACTION_NAMES.cpp_module_codegen, + ACTION_NAMES.lto_backend, + ] + + all_link_actions = [ + ACTION_NAMES.cpp_link_executable, + ACTION_NAMES.cpp_link_dynamic_library, + ACTION_NAMES.cpp_link_nodeps_dynamic_library, + ] + + objcopy_embed_data_action = action_config( + action_name = "objcopy_embed_data", + enabled = True, + tools = [tool(path = "/usr/bin/objcopy")], + ) + + action_configs = [] + + opt_feature = feature(name = "opt") + + dbg_feature = feature(name = "dbg") + + sysroot_feature = feature( + name = "sysroot", + enabled = True, + flag_sets = [ + flag_set( + actions = [ + ACTION_NAMES.preprocess_assemble, + ACTION_NAMES.linkstamp_compile, + ACTION_NAMES.c_compile, + ACTION_NAMES.cpp_compile, + ACTION_NAMES.cpp_header_parsing, + ACTION_NAMES.cpp_module_compile, + ACTION_NAMES.cpp_module_codegen, + ACTION_NAMES.lto_backend, + ACTION_NAMES.clif_match, + ACTION_NAMES.cpp_link_executable, + ACTION_NAMES.cpp_link_dynamic_library, + ACTION_NAMES.cpp_link_nodeps_dynamic_library, + ], + flag_groups = [ + flag_group( + flags = ["--sysroot=%{YOCTO_COMPILER_PATH}%/recipe-sysroot"], + expand_if_available = "sysroot", + ), + ], + ), + ], + ) + + unfiltered_compile_flags_feature = feature( + name = "unfiltered_compile_flags", + enabled = True, + flag_sets = [ + flag_set( + actions = [ + ACTION_NAMES.assemble, + ACTION_NAMES.preprocess_assemble, + ACTION_NAMES.linkstamp_compile, + ACTION_NAMES.c_compile, + ACTION_NAMES.cpp_compile, + ACTION_NAMES.cpp_header_parsing, + ACTION_NAMES.cpp_module_compile, + ACTION_NAMES.cpp_module_codegen, + ACTION_NAMES.lto_backend, + ACTION_NAMES.clif_match, + ], + flag_groups = [ + flag_group( + flags = [ + "-Wno-builtin-macro-redefined", + "-D__DATE__=\"redacted\"", + "-D__TIMESTAMP__=\"redacted\"", + "-D__TIME__=\"redacted\"", + "-no-canonical-prefixes", + "-fno-canonical-system-headers", + ], + ), + ], + ), + ], + ) + + objcopy_embed_flags_feature = feature( + name = "objcopy_embed_flags", + enabled = True, + flag_sets = [ + flag_set( + actions = ["objcopy_embed_data"], + flag_groups = [flag_group(flags = ["-I", "binary"])], + ), + ], + ) + + default_compile_flags_feature = feature( + name = "default_compile_flags", + enabled = True, + flag_sets = [ + flag_set( + actions = [ + ACTION_NAMES.assemble, + ACTION_NAMES.preprocess_assemble, + ACTION_NAMES.linkstamp_compile, + ACTION_NAMES.c_compile, + ACTION_NAMES.cpp_compile, + ACTION_NAMES.cpp_header_parsing, + ACTION_NAMES.cpp_module_compile, + ACTION_NAMES.cpp_module_codegen, + ACTION_NAMES.lto_backend, + ACTION_NAMES.clif_match, + ], + flag_groups = [ + flag_group( + flags = [ + "-fstack-protector", + ], + ), + ], + ), + flag_set( + actions = [ + ACTION_NAMES.assemble, + ACTION_NAMES.preprocess_assemble, + ACTION_NAMES.linkstamp_compile, + ACTION_NAMES.c_compile, + ACTION_NAMES.cpp_compile, + ACTION_NAMES.cpp_header_parsing, + ACTION_NAMES.cpp_module_compile, + ACTION_NAMES.cpp_module_codegen, + ACTION_NAMES.lto_backend, + ACTION_NAMES.clif_match, + ], + flag_groups = [flag_group(flags = ["-g"])], + with_features = [with_feature_set(features = ["dbg"])], + ), + flag_set( + actions = [ + ACTION_NAMES.assemble, + ACTION_NAMES.preprocess_assemble, + ACTION_NAMES.linkstamp_compile, + ACTION_NAMES.c_compile, + ACTION_NAMES.cpp_compile, + ACTION_NAMES.cpp_header_parsing, + ACTION_NAMES.cpp_module_compile, + ACTION_NAMES.cpp_module_codegen, + ACTION_NAMES.lto_backend, + ACTION_NAMES.clif_match, + ], + flag_groups = [ + flag_group( + flags = [ + "-g0", + "-O2", + "-DNDEBUG", + "-ffunction-sections", + "-fdata-sections", + ], + ), + ], + with_features = [with_feature_set(features = ["opt"])], + ), + flag_set( + actions = [ + ACTION_NAMES.linkstamp_compile, + ACTION_NAMES.cpp_compile, + ACTION_NAMES.cpp_header_parsing, + ACTION_NAMES.cpp_module_compile, + ACTION_NAMES.cpp_module_codegen, + ACTION_NAMES.lto_backend, + ACTION_NAMES.clif_match, + ], + flag_groups = [ + flag_group( + flags = [ + # Include target pyconfig.h + "-D_PYTHON_INCLUDE_TARGET", + ], + ), + ], + ), + ], + ) + + default_link_flags_feature = feature( + name = "default_link_flags", + enabled = True, + flag_sets = [ + flag_set( + actions = all_link_actions, + flag_groups = [ + flag_group( + flags = [ + "-lstdc++", + "-Wl,-z,relro,-z,now", + "-no-canonical-prefixes", + "-pass-exit-codes", + "-Wl,--build-id=md5", + "-Wl,--hash-style=gnu", + ], + ), + ], + ), + flag_set( + actions = all_link_actions, + flag_groups = [flag_group(flags = ["-Wl,--gc-sections"])], + with_features = [with_feature_set(features = ["opt"])], + ), + ], + ) + + supports_dynamic_linker_feature = feature(name = "supports_dynamic_linker", enabled = True) + + supports_pic_feature = feature(name = "supports_pic", enabled = True) + + user_compile_flags_feature = feature( + name = "user_compile_flags", + enabled = True, + flag_sets = [ + flag_set( + actions = [ + ACTION_NAMES.assemble, + ACTION_NAMES.preprocess_assemble, + ACTION_NAMES.linkstamp_compile, + ACTION_NAMES.c_compile, + ACTION_NAMES.cpp_compile, + ACTION_NAMES.cpp_header_parsing, + ACTION_NAMES.cpp_module_compile, + ACTION_NAMES.cpp_module_codegen, + ACTION_NAMES.lto_backend, + ACTION_NAMES.clif_match, + ], + flag_groups = [ + flag_group( + flags = ["%{user_compile_flags}"], + iterate_over = "user_compile_flags", + expand_if_available = "user_compile_flags", + ), + ], + ), + ], + ) + + features = [ + default_compile_flags_feature, + default_link_flags_feature, + supports_dynamic_linker_feature, + supports_pic_feature, + opt_feature, + dbg_feature, + user_compile_flags_feature, + sysroot_feature, + unfiltered_compile_flags_feature, + ] + + cxx_builtin_include_directories = [ + "%{YOCTO_COMPILER_PATH}%", + ] + + artifact_name_patterns = [] + + make_variables = [] + + tool_paths = [ + tool_path( + name = "ar", + path = "%{YOCTO_COMPILER_PATH}%/recipe-sysroot-native/usr/bin/%{CT_NAME}%/%{CT_NAME}%-ar", + ), + tool_path(name = "compat-ld", path = "/bin/false"), + tool_path( + name = "cpp", + path = "%{YOCTO_COMPILER_PATH}%/recipe-sysroot-native/usr/bin/%{CT_NAME}%/%{CT_NAME}%-cpp", + ), + tool_path( + name = "dwp", + path = "%{YOCTO_COMPILER_PATH}%/recipe-sysroot-native/usr/bin/%{CT_NAME}%/%{CT_NAME}%-dwp", + ), + tool_path( + name = "gcc", + path = "%{YOCTO_COMPILER_PATH}%/recipe-sysroot-native/usr/bin/%{CT_NAME}%/%{CT_NAME}%-gcc", + ), + tool_path( + name = "gcov", + path = "%{YOCTO_COMPILER_PATH}%/recipe-sysroot-native/usr/bin/%{CT_NAME}%/%{CT_NAME}%-gcov", + ), + tool_path( + name = "ld", + path = "%{YOCTO_COMPILER_PATH}%/recipe-sysroot-native/usr/bin/%{CT_NAME}%/%{CT_NAME}%-ld", + ), + tool_path( + name = "nm", + path = "%{YOCTO_COMPILER_PATH}%/recipe-sysroot-native/usr/bin/%{CT_NAME}%/%{CT_NAME}%-nm", + ), + tool_path( + name = "objcopy", + path = "%{YOCTO_COMPILER_PATH}%/recipe-sysroot-native/usr/bin/%{CT_NAME}%/%{CT_NAME}%-objcopy", + ), + tool_path( + name = "objdump", + path = "%{YOCTO_COMPILER_PATH}%/recipe-sysroot-native/usr/bin/%{CT_NAME}%/%{CT_NAME}%-objdump", + ), + tool_path( + name = "strip", + path = "%{YOCTO_COMPILER_PATH}%/recipe-sysroot-native/usr/bin/%{CT_NAME}%/%{CT_NAME}%-strip", + ), + ] + + out = ctx.actions.declare_file(ctx.label.name) + ctx.actions.write(out, "Fake executable") + return [ + cc_common.create_cc_toolchain_config_info( + ctx = ctx, + features = features, + action_configs = action_configs, + artifact_name_patterns = artifact_name_patterns, + cxx_builtin_include_directories = cxx_builtin_include_directories, + toolchain_identifier = toolchain_identifier, + host_system_name = host_system_name, + target_system_name = target_system_name, + target_cpu = target_cpu, + target_libc = target_libc, + compiler = compiler, + abi_version = abi_version, + abi_libc_version = abi_libc_version, + tool_paths = tool_paths, + make_variables = make_variables, + builtin_sysroot = builtin_sysroot, + cc_target_os = cc_target_os + ), + DefaultInfo( + executable = out, + ), + ] +cc_toolchain_config = rule( + implementation = _impl, + attrs = { + "cpu": attr.string(mandatory=True), + }, + provides = [CcToolchainConfigInfo], + executable = True, +) diff --git a/recipes-framework/tensorflow/files/yocto_compiler_configure.bzl b/recipes-framework/tensorflow/files/yocto_compiler_configure.bzl index 19c7cd1..2635da4 100644 --- a/recipes-framework/tensorflow/files/yocto_compiler_configure.bzl +++ b/recipes-framework/tensorflow/files/yocto_compiler_configure.bzl @@ -9,11 +9,19 @@ def _tpl(repository_ctx, tpl, substitutions={}, out=None): Label("//third_party/toolchains/yocto:%s.tpl" % tpl), substitutions) - def _yocto_compiler_configure_impl(repository_ctx): - _tpl(repository_ctx, "CROSSTOOL") - repository_ctx.symlink(repository_ctx.attr.build_file, "BUILD") + if "CT_NAME" in repository_ctx.os.environ: + cross_tool_name = repository_ctx.os.environ["CT_NAME"] + else: + cross_tool_name = "x86_64-wrs-linux" + _tpl(repository_ctx, "cc_config.bzl", { + "%{YOCTO_COMPILER_PATH}%": str(repository_ctx.path( + repository_ctx.attr.remote_config_repo, + )), + "%{CT_NAME}%": cross_tool_name, + }) + repository_ctx.symlink(repository_ctx.attr.build_file, "BUILD") yocto_compiler_configure = repository_rule( implementation = _yocto_compiler_configure_impl, diff --git a/recipes-framework/tensorflow/keras/0001-customize-for-yocto.patch b/recipes-framework/tensorflow/keras/0001-customize-for-yocto.patch new file mode 100644 index 0000000..1aa6a77 --- /dev/null +++ b/recipes-framework/tensorflow/keras/0001-customize-for-yocto.patch @@ -0,0 +1,28 @@ +From 375582ae1bf40a66300630b325d8739668e22ffc Mon Sep 17 00:00:00 2001 +From: Hongxu Jia <hongxu.jia@eng.windriver.com> +Date: Wed, 13 Mar 2024 06:10:17 -0700 +Subject: [PATCH] customize for yocto + +Upstream-Status: Inappropriate [oe specific] + +Signed-off-by: Hongxu Jia <hongxu.jia@eng.windriver.com> +--- + tf_keras/tools/pip_package/build_pip_package.sh | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/tf_keras/tools/pip_package/build_pip_package.sh b/tf_keras/tools/pip_package/build_pip_package.sh +index 8695fceee..43c3546b2 100755 +--- a/tf_keras/tools/pip_package/build_pip_package.sh ++++ b/tf_keras/tools/pip_package/build_pip_package.sh +@@ -39,7 +39,7 @@ function prepare_src() { + + # Verifies all expected files are in pip. + # Creates init files in all directory in pip. +- python tf_keras/tools/pip_package/create_pip_helper.py --pip-root "${TMPDIR}/tf_keras/" --bazel-root "./tf_keras" ++ nativepython3 tf_keras/tools/pip_package/create_pip_helper.py --pip-root "${TMPDIR}/tf_keras/" --bazel-root "./tf_keras" + } + + function build_wheel() { +-- +2.42.0 + diff --git a/recipes-framework/tensorflow/keras/0001-skip-pip-file-check.patch b/recipes-framework/tensorflow/keras/0001-skip-pip-file-check.patch new file mode 100644 index 0000000..18196f9 --- /dev/null +++ b/recipes-framework/tensorflow/keras/0001-skip-pip-file-check.patch @@ -0,0 +1,37 @@ +From c01d71e8750d5f8e73c8fed5bb96645751c3e364 Mon Sep 17 00:00:00 2001 +From: Hongxu Jia <hongxu.jia@windriver.com> +Date: Wed, 13 Mar 2024 21:44:51 +0800 +Subject: [PATCH] skip pip file check + +|PipPackagingError: Pip package missing the file ./tf_keras/layers/experimental/dynamic_embedding.py. +If this is expected, add it to PIP_EXCLUDED_FILES in create_pip_helper.py. +Otherwise, make sure it is a build dependency of the pip package + +Upstream-Status: Inappropriate [Yocto specific] + +Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com> +--- + tf_keras/tools/pip_package/create_pip_helper.py | 7 +++++++ + 1 file changed, 7 insertions(+) + +diff --git a/tf_keras/tools/pip_package/create_pip_helper.py b/tf_keras/tools/pip_package/create_pip_helper.py +index 65401cfa9..b677f6017 100644 +--- a/tf_keras/tools/pip_package/create_pip_helper.py ++++ b/tf_keras/tools/pip_package/create_pip_helper.py +@@ -31,6 +31,13 @@ PIP_EXCLUDED_FILES = frozenset( + "tf_keras/saving/legacy/saved_model/create_test_saved_model.py", + "tf_keras/tools/pip_package/setup.py", + "tf_keras/tools/pip_package/create_pip_helper.py", ++ "tf_keras/layers/experimental/dynamic_embedding_distributed_test.py", ++ "tf_keras/layers/experimental/dynamic_lookup_distributed_test.py", ++ "tf_keras/layers/experimental/__init__.py", ++ "tf_keras/layers/experimental/dynamic_embedding.py", ++ "tf_keras/layers/experimental/dynamic_lookup.py", ++ "tf_keras/layers/experimental/dynamic_embedding_test.py", ++ "tf_keras/layers/experimental/dynamic_lookup_test.py", + ] + ) + +-- +2.27.0 + diff --git a/recipes-framework/tensorflow/keras_2.16.0.bb b/recipes-framework/tensorflow/keras_2.16.0.bb new file mode 100644 index 0000000..b99edc9 --- /dev/null +++ b/recipes-framework/tensorflow/keras_2.16.0.bb @@ -0,0 +1,62 @@ +DESCRIPTION = "TensorFlow Keras is an implementation of the Keras API that\ + uses TensorFlow as a backend." +LICENSE = "Apache-2.0" +LIC_FILES_CHKSUM = "file://LICENSE;md5=175792518e4ac015ab6696d16c4f607e" + +SRC_URI = "git://github.com/keras-team/tf-keras.git;branch=r2.16;protocol=https \ + file://0001-customize-for-yocto.patch \ + file://0001-skip-pip-file-check.patch \ + " + +SRCREV = "7fb2e8b64dd12a61109abdad341bbf63888a0ce6" +S = "${WORKDIR}/git" + +inherit python3native bazel + +DEPENDS += " \ + python3-pip-native \ + python3-wheel-native \ + python3-absl-native \ + python3-wrapt-native \ + python3-opt-einsum-native \ + python3-gast-native \ + python3-astunparse-native \ + python3-termcolor-native \ + python3-typing-extensions-native \ + python3-flatbuffers-native \ + python3-mldtypes-native \ + python3-pybind11-native \ + python3-protobuf-native \ + tensorflow-native \ +" + +do_compile () { + unset CC + export TMPDIR="${WORKDIR}" + export PYTHON_BIN_PATH="${PYTHON}" + + ${BAZEL} build \ + --subcommands --explain=${T}/explain.log \ + --verbose_explanations --verbose_failures \ + --verbose_failures \ + --python_path="${PYTHON}" \ + //tf_keras/tools/pip_package:build_pip_package + + ${S}/bazel-bin/tf_keras/tools/pip_package/build_pip_package \ + ${WORKDIR}/tf_keras_pip +} + +do_install () { + echo "Installing pip package" + install -d ${D}${PYTHON_SITEPACKAGES_DIR} + ${STAGING_BINDIR_NATIVE}/pip3 install --disable-pip-version-check -v --no-deps \ + -t ${D}/${PYTHON_SITEPACKAGES_DIR} --no-cache-dir ${WORKDIR}/tf_keras_pip/*.whl + + # Provides module keras as usual + ln -snrf ${D}/${PYTHON_SITEPACKAGES_DIR}/tf_keras ${D}/${PYTHON_SITEPACKAGES_DIR}/keras + +} + +FILES:${PN} += "${libdir}/*" + +BBCLASSEXTEND = "native" diff --git a/recipes-framework/tensorflow/tensorboard/0001-customize-for-Yocto.patch b/recipes-framework/tensorflow/tensorboard/0001-customize-for-Yocto.patch deleted file mode 100644 index 07d8257..0000000 --- a/recipes-framework/tensorflow/tensorboard/0001-customize-for-Yocto.patch +++ /dev/null @@ -1,132 +0,0 @@ -From 03b1ddf5058485ce1c94e6a8dc0762ad3430b6a2 Mon Sep 17 00:00:00 2001 -From: Hongxu Jia <hongxu.jia@windriver.com> -Date: Thu, 25 Apr 2019 21:13:32 +0800 -Subject: [PATCH] customize for Yocto - -- Remove virtualenv/pip/bdist_wheel calling which Yocto does not support - -- Add Yocto toolchain to support cross compiling - -Upstream-Status: Inappropriate [oe specific] - -Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com> ---- - WORKSPACE | 6 ++++++ - tensorboard/pip_package/build_pip_package.sh | 31 +++------------------------- - third_party/workspace.bzl | 8 +++++++ - 3 files changed, 17 insertions(+), 28 deletions(-) - -diff --git a/WORKSPACE b/WORKSPACE -index 8ab70cc..0c18f6f 100644 ---- a/WORKSPACE -+++ b/WORKSPACE -@@ -1,5 +1,11 @@ - workspace(name = "org_tensorflow_tensorboard") - -+new_local_repository( -+ name = "yocto_compiler", -+ path = "%%WORKDIR%%", -+ build_file = "BUILD.yocto_compiler", -+) -+ - load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") - - # Needed as a transitive dependency of rules_webtesting below. -diff --git a/tensorboard/pip_package/build_pip_package.sh b/tensorboard/pip_package/build_pip_package.sh -index 754fa83..969709d 100755 ---- a/tensorboard/pip_package/build_pip_package.sh -+++ b/tensorboard/pip_package/build_pip_package.sh -@@ -23,7 +23,7 @@ else - sedi="sed -i" - fi - --run_smoke_test=1 -+run_smoke_test=0 - while [ "$#" -gt 0 ]; do - case "$1" in - "--no-smoke") -@@ -71,31 +71,20 @@ from tensorboard.plugins.beholder import Beholder, BeholderHook - } - - set -x --command -v curl >/dev/null --command -v perl >/dev/null --command -v python2 >/dev/null --command -v python3 >/dev/null --command -v virtualenv >/dev/null - [ -d "${RUNFILES}" ] - --dest=/tmp/tensorboard -+dest=${DESTDIR} - if [ ! -e $dest ]; then -- mkdir $dest -+ mkdir -p $dest - else - dest="$(mktemp -d -p /tmp -t tensorboard-pip.XXXXXXXXXX)" - fi - cd "${dest}" - - cp -LR "${RUNFILES}/org_tensorflow_tensorboard/tensorboard" . --mv -f "tensorboard/pip_package/LICENSE" . --mv -f "tensorboard/pip_package/MANIFEST.in" . --mv -f "tensorboard/pip_package/README.rst" . --mv -f "tensorboard/pip_package/setup.cfg" . --mv -f "tensorboard/pip_package/setup.py" . - rm -rf tensorboard/pip_package - - rm -f tensorboard/tensorboard # bazel py_binary sh wrapper --chmod -x LICENSE # bazel symlinks confuse cp - find . -name __init__.py | xargs chmod -x # which goes for all genfiles - - mkdir -p tensorboard/_vendor -@@ -117,21 +106,7 @@ find tensorboard -name \*.py | - s/from tensorflow_serving/from tensorboard._vendor.tensorflow_serving/ - ' - --virtualenv venv --export VIRTUAL_ENV=venv --export PATH="$PWD/venv/bin:${PATH}" --unset PYTHON_HOME -- --# Require wheel for bdist_wheel command, and setuptools 36.2.0+ so that --# env markers are handled (https://github.com/pypa/setuptools/pull/1081) --pip install -qU wheel 'setuptools>=36.2.0' -- --python setup.py bdist_wheel --python-tag py2 >/dev/null --python setup.py bdist_wheel --python-tag py3 >/dev/null -- - if [ "$run_smoke_test" = 1 ]; then - smoke 2 - smoke 3 - fi -- --ls -hal "$PWD/dist" -diff --git a/third_party/workspace.bzl b/third_party/workspace.bzl -index 083c441..24786f8 100644 ---- a/third_party/workspace.bzl -+++ b/third_party/workspace.bzl -@@ -24,6 +24,7 @@ load("//third_party:polymer.bzl", "tensorboard_polymer_workspace") - load("//third_party:python.bzl", "tensorboard_python_workspace") - load("//third_party:js.bzl", "tensorboard_js_workspace") - load("//third_party:typings.bzl", "tensorboard_typings_workspace") -+load("//third_party/toolchains/yocto:yocto_compiler_configure.bzl", "yocto_compiler_configure") - - def tensorboard_workspace(): - tensorboard_fonts_workspace() -@@ -32,6 +33,13 @@ def tensorboard_workspace(): - tensorboard_typings_workspace() - tensorboard_js_workspace() - -+ # Point //external/local_config_yocto_compiler to //external/yocto_compiler -+ yocto_compiler_configure( -+ name = "local_config_yocto_compiler", -+ build_file = str(Label("//third_party/toolchains/yocto:BUILD")), -+ remote_config_repo = "../yocto_compiler", -+ ) -+ - http_archive( - name = "com_google_protobuf_js", - strip_prefix = "protobuf-3.6.0/js", --- -2.7.4 - diff --git a/recipes-framework/tensorflow/tensorboard_1.12.2.bb b/recipes-framework/tensorflow/tensorboard_1.12.2.bb deleted file mode 100644 index efa44a1..0000000 --- a/recipes-framework/tensorflow/tensorboard_1.12.2.bb +++ /dev/null @@ -1,64 +0,0 @@ -DESCRIPTION = "A suite of web applications for inspecting and understanding \ -your TensorFlow runs and graphs." -LICENSE = "Apache-2.0" -LIC_FILES_CHKSUM = "file://LICENSE;md5=e74df23890b9521cc481e3348863e45d" - -SRC_URI = "git://github.com/tensorflow/tensorboard.git; \ - file://0001-customize-for-Yocto.patch \ - file://BUILD \ - file://BUILD.yocto_compiler \ - file://CROSSTOOL.tpl \ - file://yocto_compiler_configure.bzl \ - " -SRCREV = "7194c7486a0c4d107322ffad102c1ca0fcc0fc24" -S = "${WORKDIR}/git" - -DEPENDS = "util-linux-native" - -RDEPENDS_${PN} += "python3 \ - python3-numpy \ - python3-protobuf \ - python3-grpcio \ - python3-werkzeug \ - python3-six \ - python3-markdown \ -" -inherit python3native bazel - -do_configure_append () { - mkdir -p ${S}/third_party/toolchains/yocto/ - install -m 644 ${WORKDIR}/BUILD ${S}/third_party/toolchains/yocto/ - install -m 644 ${WORKDIR}/CROSSTOOL.tpl ${S}/third_party/toolchains/yocto/ - install -m 644 ${WORKDIR}/yocto_compiler_configure.bzl ${S}/third_party/toolchains/yocto/ - install -m 644 ${WORKDIR}/BUILD.yocto_compiler ${S} - - CT_NAME=$(echo ${HOST_PREFIX} | rev | cut -c 2- | rev) - SED_COMMAND="s#%%CT_NAME%%#${CT_NAME}#g" - SED_COMMAND="${SED_COMMAND}; s#%%WORKDIR%%#${WORKDIR}#g" - SED_COMMAND="${SED_COMMAND}; s#%%YOCTO_COMPILER_PATH%%#${BAZEL_OUTPUTBASE_DIR}/external/yocto_compiler#g" - - sed -i "${SED_COMMAND}" ${S}/BUILD.yocto_compiler \ - ${S}/third_party/toolchains/yocto/CROSSTOOL.tpl \ - ${S}/WORKSPACE -} - -do_compile () { - unset CC - DESTDIR=${WORKDIR}/python-tensorboard \ - ${BAZEL} run \ - --cpu=armeabi \ - --subcommands --explain=${T}/explain.log \ - --verbose_explanations --verbose_failures \ - --crosstool_top=@local_config_yocto_compiler//:toolchain \ - --verbose_failures \ - //tensorboard/pip_package:build_pip_package - - ${BAZEL} shutdown -} - -do_install () { - install -d ${D}${PYTHON_SITEPACKAGES_DIR} - cp -rf ${WORKDIR}/python-tensorboard/* ${D}${PYTHON_SITEPACKAGES_DIR} -} - -FILES_${PN} += "${libdir}/*" diff --git a/recipes-framework/tensorflow/tensorboard_2.16.2.bb b/recipes-framework/tensorflow/tensorboard_2.16.2.bb new file mode 100644 index 0000000..415587c --- /dev/null +++ b/recipes-framework/tensorflow/tensorboard_2.16.2.bb @@ -0,0 +1,51 @@ +DESCRIPTION = "A suite of web applications for inspecting and understanding \ +your TensorFlow runs and graphs." +LICENSE = "Apache-2.0" +LIC_FILES_CHKSUM = "file://tensorboard-2.16.2.dist-info/LICENSE;md5=6767c3dee46f5a6b27902ea046d2389d" + +SRC_URI = " \ + https://files.pythonhosted.org/packages/3a/d0/b97889ffa769e2d1fdebb632084d5e8b53fc299d43a537acee7ec0c021a3/tensorboard-2.16.2-py3-none-any.whl \ +" + + +do_unpack[depends] += "python3-pip-native:do_populate_sysroot" + +SRC_URI[md5sum] = "beb9a3fd5a6490048da95ea0a84d4240" +SRC_URI[sha256sum] = "9f2b4e7dad86667615c0e5cd072f1ea8403fc032a299f0072d6f74855775cc45" + +RDEPENDS:${PN} += "python3 \ + python3-core \ + python3-numpy \ + python3-protobuf \ + python3-grpcio \ + python3-werkzeug \ + python3-six \ + python3-markdown \ + python3-absl \ + python3-google-auth \ + python3-google-auth-oauthlib \ + python3-requests \ +" + +inherit python3native + +do_unpack () { + echo "Installing pip package" + ${STAGING_BINDIR_NATIVE}/pip3 install --disable-pip-version-check -v \ + -t ${S} --no-cache-dir --no-deps \ + ${DL_DIR}/tensorboard-2.16.2-py3-none-any.whl + + rm ${S}/${PYTHON_SITEPACKAGES_DIR}/bin ${S}/${PYTHON_SITEPACKAGES_DIR}/tensorboard-2.16.2.dist-info -rf + rm ${S}/${PYTHON_SITEPACKAGES_DIR}/bin -rf + +} + +do_install () { + install -d ${D}${PYTHON_SITEPACKAGES_DIR} + cp -rf ${S}/* ${D}${PYTHON_SITEPACKAGES_DIR}/ +} + +do_configure[noexec] = "1" +do_compile[noexec] = "1" + +FILES:${PN} += "${libdir}/*" diff --git a/recipes-framework/tensorflow/tensorflow-estimator/0001-customize-for-yocto.patch b/recipes-framework/tensorflow/tensorflow-estimator/0001-customize-for-yocto.patch new file mode 100644 index 0000000..e9b66d5 --- /dev/null +++ b/recipes-framework/tensorflow/tensorflow-estimator/0001-customize-for-yocto.patch @@ -0,0 +1,28 @@ +From a1bcf09a43fc44ad5e04c441ee45cc23d16cf7d2 Mon Sep 17 00:00:00 2001 +From: Hongxu Jia <hongxu.jia@windriver.com> +Date: Wed, 9 Dec 2020 17:59:01 +0800 +Subject: [PATCH] customize for yocto + +Upstream-Status: Inappropriate [oe specific] + +Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com> +--- + tensorflow_estimator/tools/pip_package/build_pip_package.sh | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/tensorflow_estimator/tools/pip_package/build_pip_package.sh b/tensorflow_estimator/tools/pip_package/build_pip_package.sh +index d4953a6..e08cd8a 100755 +--- a/tensorflow_estimator/tools/pip_package/build_pip_package.sh ++++ b/tensorflow_estimator/tools/pip_package/build_pip_package.sh +@@ -38,7 +38,7 @@ function prepare_src() { + + # Verifies all expected files are in pip. + # Creates init files in all directory in pip. +- python tensorflow_estimator/tools/pip_package/create_pip_helper.py --pip-root "${TMPDIR}/tensorflow_estimator/" --bazel-root "./tensorflow_estimator" ++ nativepython3 tensorflow_estimator/tools/pip_package/create_pip_helper.py --pip-root "${TMPDIR}/tensorflow_estimator/" --bazel-root "./tensorflow_estimator" + } + + function build_wheel() { +-- +2.18.2 + diff --git a/recipes-framework/tensorflow/tensorflow-estimator_1.13.bb b/recipes-framework/tensorflow/tensorflow-estimator_2.15.0.bb index dd6e1f6..1c7312e 100644 --- a/recipes-framework/tensorflow/tensorflow-estimator_1.13.bb +++ b/recipes-framework/tensorflow/tensorflow-estimator_2.15.0.bb @@ -3,9 +3,10 @@ learning programming." LICENSE = "Apache-2.0" LIC_FILES_CHKSUM = "file://LICENSE;md5=01e86893010a1b87e69a213faa753ebd" -SRC_URI = "git://github.com/tensorflow/estimator.git;branch=r1.13 \ +SRC_URI = "git://github.com/tensorflow/estimator.git;branch=r2.15;protocol=https \ + file://0001-customize-for-yocto.patch \ " -SRCREV = "340703eed78ba4854862f749ed94f91598826e79" +SRCREV = "b5f91f8e4113396f0a5f090d6a52d676271caf48" S = "${WORKDIR}/git" inherit python3native bazel @@ -19,12 +20,19 @@ DEPENDS += " \ python3-astor-native \ python3-gast-native \ python3-termcolor-native \ + python3-wrapt-native \ + python3-opt-einsum-native \ + python3-astunparse-native \ + flatbuffers-native \ tensorflow-native \ + keras-native \ " do_compile () { unset CC export TMPDIR="${WORKDIR}" + export PYTHON_BIN_PATH="${PYTHON}" + ${BAZEL} build \ --subcommands --explain=${T}/explain.log \ --verbose_explanations --verbose_failures \ @@ -32,9 +40,6 @@ do_compile () { --python_path="${PYTHON}" \ //tensorflow_estimator/tools/pip_package:build_pip_package - ${BAZEL} shutdown - - PYTHON_BIN_PATH="${PYTHON}" \ ${S}/bazel-bin/tensorflow_estimator/tools/pip_package/build_pip_package \ ${WORKDIR}/estimator_pip } @@ -47,6 +52,6 @@ do_install () { } -FILES_${PN} += "${libdir}/*" +FILES:${PN} += "${libdir}/*" BBCLASSEXTEND = "native" diff --git a/recipes-framework/tensorflow/tensorflow-lite_2.16.1.bb b/recipes-framework/tensorflow/tensorflow-lite_2.16.1.bb new file mode 100644 index 0000000..dd3ef0b --- /dev/null +++ b/recipes-framework/tensorflow/tensorflow-lite_2.16.1.bb @@ -0,0 +1,133 @@ +include tensorflow.inc + +SRC_URI += " \ + file://0001-add-yocto-toolchain-to-support-cross-compiling.patch \ + file://0001-fix-build-tensorflow-lite-examples-label_image-label.patch \ + file://0001-label_image-tweak-default-model-location.patch \ + file://0001-label_image.lite-tweak-default-model-location.patch \ + file://0001-CheckFeatureOrDie-use-warning-to-avoid-die.patch \ + file://0001-support-32-bit-x64-and-arm-for-yocto.patch \ + file://BUILD.in \ + file://BUILD.yocto_compiler \ + file://cc_config.bzl.tpl \ + file://yocto_compiler_configure.bzl \ + " + +SRC_URI += "https://storage.googleapis.com/download.tensorflow.org/models/inception_v3_2016_08_28_frozen.pb.tar.gz;name=model-inv3" +SRC_URI[model-inv3.md5sum] = "a904ddf15593d03c7dd786d552e22d73" +SRC_URI[model-inv3.sha256sum] = "7045b72a954af4dce36346f478610acdccbf149168fa25c78e54e32f0c723d6d" + +SRC_URI += "https://storage.googleapis.com/download.tensorflow.org/models/tflite/mobilenet_v1_1.0_224_quant_and_labels.zip;name=model-mobv1" +SRC_URI[model-mobv1.md5sum] = "38ac0c626947875bd311ef96c8baab62" +SRC_URI[model-mobv1.sha256sum] = "2f8054076cf655e1a73778a49bd8fd0306d32b290b7e576dda9574f00f186c0f" + +RDEPENDS:${PN} += " \ + python3 \ + python3-core \ + python3-numpy \ +" + +do_configure:append () { + mkdir -p ${S}/third_party/toolchains/yocto/ + sed "s#%%CPU%%#${BAZEL_TARGET_CPU}#g" ${WORKDIR}/BUILD.in > ${S}/third_party/toolchains/yocto/BUILD + chmod 644 ${S}/third_party/toolchains/yocto/BUILD + install -m 644 ${WORKDIR}/cc_config.bzl.tpl ${S}/third_party/toolchains/yocto/ + install -m 644 ${WORKDIR}/yocto_compiler_configure.bzl ${S}/third_party/toolchains/yocto/ + install -m 644 ${WORKDIR}/BUILD.yocto_compiler ${S} + + CT_NAME=$(echo ${HOST_PREFIX} | rev | cut -c 2- | rev) + SED_COMMAND="s#%%CT_NAME%%#${CT_NAME}#g" + SED_COMMAND="${SED_COMMAND}; s#%%WORKDIR%%#${WORKDIR}#g" + SED_COMMAND="${SED_COMMAND}; s#%%YOCTO_COMPILER_PATH%%#${BAZEL_OUTPUTBASE_DIR}/external/yocto_compiler#g" + + sed -i "${SED_COMMAND}" ${S}/BUILD.yocto_compiler \ + ${S}/WORKSPACE \ + ${S}/configure.py + + ${TF_CONFIG} \ + ./configure +} + +TF_TARGET_EXTRA ??= "" + +export CUSTOM_BAZEL_FLAGS = " \ + ${TF_ARGS_EXTRA} \ + --jobs=auto \ + -c opt \ + --cpu=${BAZEL_TARGET_CPU} \ + --crosstool_top=@local_config_yocto_compiler//:toolchain \ + --host_crosstool_top=@bazel_tools//tools/cpp:toolchain \ +" + +do_compile () { + export CT_NAME=$(echo ${HOST_PREFIX} | rev | cut -c 2- | rev) + unset CC + + ${BAZEL} build \ + ${CUSTOM_BAZEL_FLAGS} \ + --copt -DTF_LITE_DISABLE_X86_NEON --copt -DMESA_EGL_NO_X11_HEADERS \ + --define tflite_with_xnnpack=false \ + --repo_env=TF_PYTHON_VERSION=3.12 \ + tensorflow/lite:libtensorflowlite.so \ + tensorflow/lite/tools/benchmark:benchmark_model \ + //tensorflow/lite/examples/label_image:label_image \ + ${TF_TARGET_EXTRA} + + # build pip package + ${S}/tensorflow/lite/tools/pip_package/build_pip_package_with_bazel.sh + +} + +do_install() { + install -d ${D}${libdir} + install -m 644 ${S}/bazel-bin/tensorflow/lite/libtensorflowlite.so \ + ${D}${libdir} + + install -d ${D}${sbindir} + install -m 755 ${S}/bazel-bin/tensorflow/lite/tools/benchmark/benchmark_model \ + ${D}${sbindir} + + install -m 755 ${S}/bazel-bin/tensorflow/lite/examples/label_image/label_image \ + ${D}${sbindir}/label_image + + install -d ${D}${datadir}/label_image + install -m 644 ${WORKDIR}/imagenet_slim_labels.txt ${D}${datadir}/label_image + install -m 644 ${WORKDIR}/inception_v3_2016_08_28_frozen.pb \ + ${D}${datadir}/label_image + install -m 644 ${S}/tensorflow/examples/label_image/data/grace_hopper.jpg \ + ${D}${datadir}/label_image + + install -m 644 ${WORKDIR}/labels_mobilenet_quant_v1_224.txt ${D}${datadir}/label_image + install -m 644 ${WORKDIR}/mobilenet_v1_1.0_224_quant.tflite \ + ${D}${datadir}/label_image + install -m 644 ${S}/tensorflow/lite/examples/label_image/testdata/grace_hopper.bmp \ + ${D}${datadir}/label_image + + + #echo "Installing pip package" + install -d ${D}/${PYTHON_SITEPACKAGES_DIR} + ${STAGING_BINDIR_NATIVE}/pip3 install --disable-pip-version-check -v \ + -t ${D}/${PYTHON_SITEPACKAGES_DIR} --no-cache-dir --no-deps \ + ${S}/tensorflow/lite/tools/pip_package/gen/tflite_pip/python3/dist/tflite_runtime-${PV}*.whl + +} + +FILES:${PN} += "${libdir} ${sbindir} ${datadir}/*" +INSANE_SKIP:${PN} += "dev-so \ + already-stripped \ + " + +SOLIBS = ".so" +FILES_SOLIBSDEV = "" +ALLOW_EMPTY:${PN} = "1" + +inherit siteinfo unsupportarch +python __anonymous() { + if d.getVar("SITEINFO_ENDIANNESS") == 'be': + msg = "\nIt failed to use pre-build model to do predict/inference on big-endian platform" + msg += "\n(such as qemumips), since upstream does not support big-endian very well." + msg += "\nDetails: https://github.com/tensorflow/tensorflow/issues/16364" + bb.warn(msg) +} + +COMPATIBLE_HOST:arm = "null" diff --git a/recipes-framework/tensorflow/tensorflow-native_1.13.0.bb b/recipes-framework/tensorflow/tensorflow-native_1.13.0.bb deleted file mode 100644 index fa9b04c..0000000 --- a/recipes-framework/tensorflow/tensorflow-native_1.13.0.bb +++ /dev/null @@ -1,72 +0,0 @@ -DESCRIPTION = "TensorFlow C/C++ Libraries" -LICENSE = "Apache-2.0" -LIC_FILES_CHKSUM = "file://LICENSE;md5=01e86893010a1b87e69a213faa753ebd" - -DEPENDS = "bazel-native protobuf-native util-linux-native protobuf" -SRCREV = "c8875cbb1341f6ca14dd0ec908f1dde7d67f7808" -SRC_URI = "git://github.com/tensorflow/tensorflow.git;branch=r1.13 \ - file://0001-SyntaxError-around-async-keyword-on-Python-3.7.patch \ - file://0001-use-local-bazel-to-workaround-bazel-paralle-issue.patch \ - file://0001-grpc-Define-gettid-only-for-glibc-2.30.patch \ - " -S = "${WORKDIR}/git" - -DEPENDS += " \ - python3 \ - python3-numpy-native \ - python3-keras-applications-native \ - python3-keras-preprocessing-native \ - python3-pip-native \ - python3-wheel-native \ -" - -inherit python3native bazel native - -export PYTHON_BIN_PATH="${PYTHON}" -export PYTHON_LIB_PATH="${PYTHON_SITEPACKAGES_DIR}" - -do_configure_append () { - TF_NEED_CUDA=0 \ - TF_NEED_OPENCL_SYCL=0 \ - TF_NEED_OPENCL=0 \ - TF_CUDA_CLANG=0 \ - TF_DOWNLOAD_CLANG=0 \ - TF_ENABLE_XLA=0 \ - TF_NEED_MPI=0 \ - TF_SET_ANDROID_WORKSPACE=0 \ - ./configure -} - -do_compile () { - unset CC - ${BAZEL} build \ - -c opt \ - --subcommands --explain=${T}/explain.log \ - --verbose_explanations --verbose_failures \ - --verbose_failures \ - //tensorflow/tools/pip_package:build_pip_package - - ${BAZEL} shutdown -} - -do_install() { - export TMPDIR="${WORKDIR}" - echo "Generating pip package" - BDIST_OPTS="--universal" \ - ${S}/bazel-bin/tensorflow/tools/pip_package/build_pip_package ${WORKDIR} - - echo "Installing pip package" - install -d ${D}/${PYTHON_SITEPACKAGES_DIR} - ${STAGING_BINDIR_NATIVE}/pip3 install --disable-pip-version-check -v --no-deps \ - -t ${D}/${PYTHON_SITEPACKAGES_DIR} --no-cache-dir ${WORKDIR}/tensorflow*.whl - - install -d ${D}${sbindir} - ( - cd ${D}${PYTHON_SITEPACKAGES_DIR}/bin; - for app in `ls`; do - mv $app ${D}${sbindir} - done - - ) - -} diff --git a/recipes-framework/tensorflow/tensorflow-native_2.16.1.bb b/recipes-framework/tensorflow/tensorflow-native_2.16.1.bb new file mode 100644 index 0000000..aeeebb9 --- /dev/null +++ b/recipes-framework/tensorflow/tensorflow-native_2.16.1.bb @@ -0,0 +1,51 @@ +include tensorflow.inc + +inherit native + +do_configure:append () { + + cat >> "${S}/bazelrc" <<-EOF +build --conlyopt=-Wno-stringop-overflow +build --conlyopt=-Wno-dangling-pointer +EOF + + SED_COMMAND="s#%%WORKDIR%%#${WORKDIR}#g" + sed -i "${SED_COMMAND}" ${S}/configure.py + + ${TF_CONFIG} \ + ./configure +} + +do_compile () { + unset CC + ${BAZEL} build \ + ${TF_ARGS_EXTRA} \ + -c opt \ + --subcommands --explain=${T}/explain.log \ + --verbose_explanations --verbose_failures \ + --repo_env=TF_PYTHON_VERSION=3.12 \ + --verbose_failures \ + //tensorflow/tools/pip_package:build_pip_package +} + +do_install() { + export TMPDIR="${WORKDIR}" + echo "Generating pip package" + BDIST_OPTS="--universal" \ + ${S}/bazel-bin/tensorflow/tools/pip_package/build_pip_package ${WORKDIR} + + echo "Installing pip package" + install -d ${D}/${PYTHON_SITEPACKAGES_DIR} + ${STAGING_BINDIR_NATIVE}/pip3 install --disable-pip-version-check -v --no-deps \ + -t ${D}/${PYTHON_SITEPACKAGES_DIR} --no-cache-dir ${WORKDIR}/tensorflow-${PV}*.whl + + install -d ${D}${sbindir} + ( + cd ${D}${PYTHON_SITEPACKAGES_DIR}/bin; + for app in `ls`; do + mv $app ${D}${sbindir} + done + + ) + +} diff --git a/recipes-framework/tensorflow/tensorflow.inc b/recipes-framework/tensorflow/tensorflow.inc new file mode 100644 index 0000000..1480c0a --- /dev/null +++ b/recipes-framework/tensorflow/tensorflow.inc @@ -0,0 +1,65 @@ +DESCRIPTION = "TensorFlow C/C++ Libraries" +LICENSE = "Apache-2.0" +LIC_FILES_CHKSUM = "file://LICENSE;md5=4158a261ca7f2525513e31ba9c50ae98" + +DEPENDS = " \ + bazel-native \ + protobuf-native \ + util-linux-native \ + patchelf-native \ + protobuf \ +" +SRCREV = "5bc9d26649cca274750ad3625bd93422617eed4b" +SRC_URI = "git://github.com/tensorflow/tensorflow.git;branch=r2.16;protocol=https \ + file://0001-use-local-bazel-to-workaround-bazel-paralle-issue.patch \ + file://0001-third_party-eigen_archive-workaround-ice-failure-whi.patch \ + file://0001-drop-bazel_toolchains_repositories-to-support-offlin.patch \ + file://0001-drop-v2-config.patch \ + file://0002-Replace-distutils.sysconfig.get_python_lib-with-sysc.patch \ + file://0001-hardcode-go-SDKS.patch \ + file://0001-fix-build-failure.patch \ + file://0001-support-hermetic-Python.patch \ + file://0001-make-hermetic-python3-support-offline-build.patch \ + " + +S = "${WORKDIR}/git" + +DEPENDS += " \ + python3 \ + python3-requests-native \ + python3-numpy-native \ + python3-keras-applications-native \ + python3-keras-preprocessing-native \ + python3-pip-native \ + python3-wheel-native \ + python3-packaging-native \ +" + +inherit python3native bazel + +TF_CONFIG ?= " \ + TF_NEED_CUDA=0 \ + TF_NEED_OPENCL_SYCL=0 \ + TF_NEED_OPENCL=0 \ + TF_CUDA_CLANG=0 \ + TF_DOWNLOAD_CLANG=0 \ + TF_ENABLE_XLA=0 \ + TF_NEED_MPI=0 \ + TF_SET_ANDROID_WORKSPACE=0 \ + TF_NEED_CLANG=0 \ + TF_NEED_ROCM=0 \ +" + +inherit tensorflow_ver + +CC:append:arm = " -mfp16-format=ieee" + +CFLAGS += "-Wno-stringop-overflow -Wno-dangling-pointer" + +export TS_DL_DIR + +do_compile[network] = "1" + +do_compile:append() { + chmod a+w ${BAZEL_DIR}/output_base/execroot/org_tensorflow/bazel-out/*/bin/tensorflow/lite/python/conversion_metadata_schema_py_srcs_no_include_all || true +} diff --git a/recipes-framework/tensorflow/tensorflow_1.13.0.bb b/recipes-framework/tensorflow/tensorflow_2.16.1.bb index 223044f..713c9c0 100644 --- a/recipes-framework/tensorflow/tensorflow_1.13.0.bb +++ b/recipes-framework/tensorflow/tensorflow_2.16.1.bb @@ -1,28 +1,19 @@ -DESCRIPTION = "TensorFlow C/C++ Libraries" -LICENSE = "Apache-2.0" -LIC_FILES_CHKSUM = "file://LICENSE;md5=01e86893010a1b87e69a213faa753ebd" +include tensorflow.inc -DEPENDS = "bazel-native protobuf-native util-linux-native protobuf" -SRCREV = "c8875cbb1341f6ca14dd0ec908f1dde7d67f7808" -SRC_URI = "git://github.com/tensorflow/tensorflow.git;branch=r1.13 \ +SRC_URI += " \ file://0001-add-yocto-toolchain-to-support-cross-compiling.patch \ - file://0001-fix-gcc-internal-compile-error-on-qemuarm64.patch \ - file://0001-SyntaxError-around-async-keyword-on-Python-3.7.patch \ - file://0001-support-musl.patch \ file://0001-fix-build-tensorflow-lite-examples-label_image-label.patch \ file://0001-label_image-tweak-default-model-location.patch \ file://0001-label_image.lite-tweak-default-model-location.patch \ - file://0001-use-local-bazel-to-workaround-bazel-paralle-issue.patch \ file://0001-CheckFeatureOrDie-use-warning-to-avoid-die.patch \ - file://0001-grpc-Define-gettid-only-for-glibc-2.30.patch \ - file://BUILD \ + file://0001-support-32-bit-x64-and-arm-for-yocto.patch \ + file://0001-build-api_gen_binary_target-as-host-tools.patch \ + file://BUILD.in \ file://BUILD.yocto_compiler \ - file://CROSSTOOL.tpl \ + file://cc_config.bzl.tpl \ file://yocto_compiler_configure.bzl \ " -S = "${WORKDIR}/git" - SRC_URI += "https://storage.googleapis.com/download.tensorflow.org/models/inception_v3_2016_08_28_frozen.pb.tar.gz;name=model-inv3" SRC_URI[model-inv3.md5sum] = "a904ddf15593d03c7dd786d552e22d73" SRC_URI[model-inv3.sha256sum] = "7045b72a954af4dce36346f478610acdccbf149168fa25c78e54e32f0c723d6d" @@ -31,17 +22,9 @@ SRC_URI += "https://storage.googleapis.com/download.tensorflow.org/models/tflite SRC_URI[model-mobv1.md5sum] = "38ac0c626947875bd311ef96c8baab62" SRC_URI[model-mobv1.sha256sum] = "2f8054076cf655e1a73778a49bd8fd0306d32b290b7e576dda9574f00f186c0f" -DEPENDS += " \ - python3 \ - python3-numpy-native \ - python3-keras-applications-native \ - python3-keras-preprocessing-native \ - python3-pip-native \ - python3-wheel-native \ -" - -RDEPENDS_${PN} += " \ +RDEPENDS:python3-tensorflow += " \ python3 \ + python3-core \ python3-numpy \ python3-keras-applications \ python3-keras-preprocessing \ @@ -49,50 +32,27 @@ RDEPENDS_${PN} += " \ python3-grpcio \ python3-absl \ python3-astor \ + python3-astunparse \ python3-gast \ python3-termcolor \ + python3-wrapt \ + python3-opt-einsum \ + python3-google-pasta \ + python3-typing-extensions \ + python3-packaging \ + python3-flatbuffers \ + python3-mldtypes \ + python3-pybind11 \ tensorboard \ tensorflow-estimator \ + keras \ " -inherit python3native bazel - -export PYTHON_BIN_PATH="${PYTHON}" -export PYTHON_LIB_PATH="${STAGING_LIBDIR_NATIVE}/${PYTHON_DIR}/site-packages" - -TF_CONFIG ?= " \ - TF_NEED_CUDA=0 \ - TF_NEED_OPENCL_SYCL=0 \ - TF_NEED_OPENCL=0 \ - TF_CUDA_CLANG=0 \ - TF_DOWNLOAD_CLANG=0 \ - TF_ENABLE_XLA=0 \ - TF_NEED_MPI=0 \ - TF_SET_ANDROID_WORKSPACE=0 \ -" -do_configure_append () { - CROSSTOOL_PYTHON_INCLUDE_PATH="${STAGING_INCDIR}/python${PYTHON_BASEVERSION}${PYTHON_ABI}" - if [ ! -e ${CROSSTOOL_PYTHON_INCLUDE_PATH}/pyconfig-target.h ];then - mv ${CROSSTOOL_PYTHON_INCLUDE_PATH}/pyconfig.h ${CROSSTOOL_PYTHON_INCLUDE_PATH}/pyconfig-target.h - fi - - install -m 644 ${STAGING_INCDIR_NATIVE}/python${PYTHON_BASEVERSION}${PYTHON_ABI}/pyconfig.h \ - ${CROSSTOOL_PYTHON_INCLUDE_PATH}/pyconfig-native.h - - cat > ${CROSSTOOL_PYTHON_INCLUDE_PATH}/pyconfig.h <<ENDOF -#if defined (_PYTHON_INCLUDE_TARGET) -#include "pyconfig-target.h" -#elif defined (_PYTHON_INCLUDE_NATIVE) -#include "pyconfig-native.h" -#else -#error "_PYTHON_INCLUDE_TARGET or _PYTHON_INCLUDE_NATIVE is not defined" -#endif // End of #if defined (_PYTHON_INCLUDE_TARGET) - -ENDOF - +do_configure:append () { mkdir -p ${S}/third_party/toolchains/yocto/ - install -m 644 ${WORKDIR}/BUILD ${S}/third_party/toolchains/yocto/ - install -m 644 ${WORKDIR}/CROSSTOOL.tpl ${S}/third_party/toolchains/yocto/ + sed "s#%%CPU%%#${BAZEL_TARGET_CPU}#g" ${WORKDIR}/BUILD.in > ${S}/third_party/toolchains/yocto/BUILD + chmod 644 ${S}/third_party/toolchains/yocto/BUILD + install -m 644 ${WORKDIR}/cc_config.bzl.tpl ${S}/third_party/toolchains/yocto/ install -m 644 ${WORKDIR}/yocto_compiler_configure.bzl ${S}/third_party/toolchains/yocto/ install -m 644 ${WORKDIR}/BUILD.yocto_compiler ${S} @@ -102,26 +62,29 @@ ENDOF SED_COMMAND="${SED_COMMAND}; s#%%YOCTO_COMPILER_PATH%%#${BAZEL_OUTPUTBASE_DIR}/external/yocto_compiler#g" sed -i "${SED_COMMAND}" ${S}/BUILD.yocto_compiler \ - ${S}/third_party/toolchains/yocto/CROSSTOOL.tpl \ - ${S}/WORKSPACE + ${S}/WORKSPACE \ + ${S}/configure.py ${TF_CONFIG} \ ./configure } -TF_ARGS_EXTRA ??= "" TF_TARGET_EXTRA ??= "" do_compile () { + export CT_NAME=$(echo ${HOST_PREFIX} | rev | cut -c 2- | rev) unset CC ${BAZEL} build \ ${TF_ARGS_EXTRA} \ -c opt \ - --cpu=armeabi \ + --cpu=${BAZEL_TARGET_CPU} \ --subcommands --explain=${T}/explain.log \ --verbose_explanations --verbose_failures \ --crosstool_top=@local_config_yocto_compiler//:toolchain \ + --host_crosstool_top=@bazel_tools//tools/cpp:toolchain \ --verbose_failures \ --copt -DTF_LITE_DISABLE_X86_NEON \ + --define tflite_with_xnnpack=false \ + --repo_env=TF_PYTHON_VERSION=3.12 \ //tensorflow:libtensorflow.so \ //tensorflow:libtensorflow_cc.so \ //tensorflow:libtensorflow_framework.so \ @@ -130,8 +93,6 @@ do_compile () { tensorflow/examples/label_image/... \ //tensorflow/lite/examples/label_image:label_image \ ${TF_TARGET_EXTRA} - - ${BAZEL} shutdown } do_install() { @@ -140,8 +101,6 @@ do_install() { ${D}${libdir} install -m 644 ${S}/bazel-bin/tensorflow/libtensorflow_cc.so \ ${D}${libdir} - install -m 644 ${S}/bazel-bin/tensorflow/libtensorflow_framework.so \ - ${D}${libdir} install -d ${D}${sbindir} install -m 755 ${S}/bazel-bin/tensorflow/tools/benchmark/benchmark_model \ @@ -176,34 +135,47 @@ do_install() { install -d ${D}/${PYTHON_SITEPACKAGES_DIR} ${STAGING_BINDIR_NATIVE}/pip3 install --disable-pip-version-check -v \ -t ${D}/${PYTHON_SITEPACKAGES_DIR} --no-cache-dir --no-deps \ - ${WORKDIR}/tensorflow*.whl + ${WORKDIR}/tensorflow-${PV}*.whl ( cd ${D}${PYTHON_SITEPACKAGES_DIR}/bin; for app in `ls`; do - sed -i "s:^'''exec' ${PYTHON} :'''exec' /usr/bin/python3 :g" $app + sed -i "s:${STAGING_BINDIR_NATIVE}/nativepython3:/usr/bin/python3:g" $app mv $app ${D}${sbindir} done - rm -f ${D}${PYTHON_SITEPACKAGES_DIR}/tensorflow/libtensorflow_framework.so + mv ${D}${PYTHON_SITEPACKAGES_DIR}/tensorflow/libtensorflow_framework.so* ${D}${libdir} ) } -FILES_${PN}-dev = "" -INSANE_SKIP_${PN} += "dev-so \ +FILES:${PN}-dev = "" +INSANE_SKIP:${PN} += "dev-so \ + already-stripped \ " -FILES_${PN} += "${libdir}/* ${datadir}/*" -inherit siteinfo -UNSUPPORTED_TARGET_ARCH = "powerpc" -python __anonymous() { - target_arch = d.getVar("TARGET_ARCH") - if target_arch in d.getVar("UNSUPPORTED_TARGET_ARCH").split(): - raise bb.parse.SkipPackage("TensorFlow does not support Target Arch '%s'" % target_arch) +PACKAGE_BEFORE_PN += "libtensorflow-c libtensorflow-framework label-image label-image-lite python3-tensorflow" + +RDEPENDS:label-image += "libtensorflow-framework" +RDEPENDS:python3-tensorflow += "libtensorflow-framework" +RDEPENDS:${PN} += "libtensorflow-c libtensorflow-framework label-image label-image-lite python3-tensorflow" + +ALLOW_EMPTY:${PN} = "1" +PRIVATE_LIBS:python3-tensorflow = "libtensorflow_cc.so.2" + +FILES:python3-tensorflow += "${libdir}/* ${datadir}/* ${sbindir}/*" +FILES:libtensorflow-c = "${libdir}/libtensorflow.so ${libdir}/libtensorflow_cc.so" +FILES:libtensorflow-framework = "${libdir}/libtensorflow.so ${libdir}/libtensorflow_framework.so*" +FILES:label-image = "${sbindir}/label_image" +FILES:label-image-lite = "${sbindir}/label_image.lite" + +inherit siteinfo unsupportarch +python __anonymous() { if d.getVar("SITEINFO_ENDIANNESS") == 'be': msg = "\nIt failed to use pre-build model to do predict/inference on big-endian platform" msg += "\n(such as qemumips), since upstream does not support big-endian very well." msg += "\nDetails: https://github.com/tensorflow/tensorflow/issues/16364" bb.warn(msg) } + +COMPATIBLE_HOST:arm = "null" diff --git a/recipes-model/googlecodelabs/tensorflow-for-poets_2.bb b/recipes-model/googlecodelabs/tensorflow-for-poets_2.bb index c0821ea..b3eb21f 100644 --- a/recipes-model/googlecodelabs/tensorflow-for-poets_2.bb +++ b/recipes-model/googlecodelabs/tensorflow-for-poets_2.bb @@ -19,6 +19,11 @@ SRC_URI += "http://download.tensorflow.org/example_images/flower_photos.tgz;name SRC_URI[flower.md5sum] = "6f87fb78e9cc9ab41eff2015b380011d" SRC_URI[flower.sha256sum] = "4c54ace7911aaffe13a365c34f650e71dd5bf1be0a58b464e5a7183e3e595d9c" +# Model mobilenet_v1_0.50_224_frozen.tgz +SRC_URI += "http://download.tensorflow.org/models/mobilenet_v1_0.50_${IMAGE_SIZE}_frozen.tgz;name=mobilenet;" +SRC_URI[mobilenet.md5sum] = "aaed1fa724dda3e137d26a69a8c219f2" +SRC_URI[mobilenet.sha256sum] = "0901218facf3d30ae6d8829e0ab6a4f952f7a5b51d6fda0fb15c92838ec55265" + DEPENDS += " \ tensorflow-native \ python3-numpy-native \ @@ -32,7 +37,7 @@ DEPENDS += " \ python3-termcolor-native \ tensorflow-estimator-native \ " -RDEPENDS_${PN} += "tensorflow \ +RDEPENDS:${PN} += "tensorflow \ python3-core \ python3-pillow \ " @@ -47,6 +52,14 @@ do_install[vardeps] += "SAMPLE_IMAGES" RETRAIN_DATASET ??= "${WORKDIR}/flower_photos" SAMPLE_IMAGES ??= "${WORKDIR}/flower_photos/daisy/3475870145_685a19116d.jpg" +do_unpack[postfuncs] += "download_mobilenet_tarball" +download_mobilenet_tarball () { + if [ ! -e ${S}/tf_files/models/mobilenet_v1_0.50_${IMAGE_SIZE}_frozen.tgz ]; then + mkdir -p ${S}/tf_files/models + cp ${DL_DIR}/mobilenet_v1_0.50_${IMAGE_SIZE}_frozen.tgz ${S}/tf_files/models + fi +} + do_compile () { ${PYTHON} -m scripts.retrain \ --bottleneck_dir=tf_files/bottlenecks \ @@ -85,4 +98,12 @@ do_install () { cp -rf ${SAMPLE_IMAGES} ${D}${datadir}/label_image/ } -FILES_${PN} += "${libdir}/* ${datadir}/*" +FILES:${PN} += "${libdir}/* ${datadir}/*" + +inherit unsupportarch tensorflow_ver + +python __anonymous() { + if '--config=v1' not in (d.getVar("TF_ARGS_EXTRA") or "").split(): + msg = "\nIt requires tensorflow 1.x, add 'TF_ARGS_EXTRA = \"--config=v1\"' to local.conf" + raise bb.parse.SkipPackage(msg) +} |