From 6783eb2554aca154bd275dd3dd2759321a026346 Mon Sep 17 00:00:00 2001 From: barry Date: Thu, 15 Aug 2024 21:38:24 +0200 Subject: [PATCH 01/27] try build GPU version of tflite for linux x86_64 --- .github/workflows/tensorflow-lite.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/tensorflow-lite.yml b/.github/workflows/tensorflow-lite.yml index c71a7cb9cfc..5d536f4ea0a 100644 --- a/.github/workflows/tensorflow-lite.yml +++ b/.github/workflows/tensorflow-lite.yml @@ -47,6 +47,11 @@ jobs: # - uses: bytedeco/javacpp-presets/.github/actions/deploy-ubuntu@actions linux-x86_64: runs-on: ubuntu-20.04 + strategy: + matrix: + ext: + - gpu + - '' steps: - uses: bytedeco/javacpp-presets/.github/actions/deploy-ubuntu@actions macosx-x86_64: From 90090a9acfbe74dedf200bdc1eacf09ad4b9eee4 Mon Sep 17 00:00:00 2001 From: barry Date: Thu, 15 Aug 2024 21:59:46 +0200 Subject: [PATCH 02/27] fix extension '-gpu' and not 'gpu' --- .github/workflows/tensorflow-lite.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tensorflow-lite.yml b/.github/workflows/tensorflow-lite.yml index 5d536f4ea0a..14463a31997 100644 --- a/.github/workflows/tensorflow-lite.yml +++ b/.github/workflows/tensorflow-lite.yml @@ -50,7 +50,7 @@ jobs: strategy: matrix: ext: - - gpu + - '-gpu' - '' steps: - uses: bytedeco/javacpp-presets/.github/actions/deploy-ubuntu@actions From a77053441d8a92c28a1563bae340da216e641def Mon Sep 17 00:00:00 2001 From: barry Date: Thu, 15 Aug 2024 22:06:11 +0200 Subject: [PATCH 03/27] attach the installed artifacts --- .github/actions/deploy-ubuntu/action.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/actions/deploy-ubuntu/action.yml b/.github/actions/deploy-ubuntu/action.yml index 3e0646e99fa..0fe520b7d9d 100644 --- a/.github/actions/deploy-ubuntu/action.yml +++ b/.github/actions/deploy-ubuntu/action.yml @@ -341,6 +341,12 @@ runs: fi df -h + - name: Attach outputs + uses: actions/upload-artifact@v4 + with: + # attach the installed artifacts + path: /home/runner/.m2/repository/org/bytedeco/${{ env.CI_DEPLOY_MODULE }}/ + - name: Clean up shell: bash run: | From 5f9b5f23f93aa0a1ccc8d10417edd6dccb63f748 Mon Sep 17 00:00:00 2001 From: barry Date: Thu, 15 Aug 2024 22:07:54 +0200 Subject: [PATCH 04/27] trigger tflite build --- .github/workflows/tensorflow-lite.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/tensorflow-lite.yml b/.github/workflows/tensorflow-lite.yml index 14463a31997..8755f786afc 100644 --- a/.github/workflows/tensorflow-lite.yml +++ b/.github/workflows/tensorflow-lite.yml @@ -68,3 +68,4 @@ jobs: runs-on: ubuntu-20.04 steps: - uses: bytedeco/javacpp-presets/.github/actions/redeploy@actions + From dac6dc935f8703b8aca4a30583a39639b079a129 Mon Sep 17 00:00:00 2001 From: barry Date: Fri, 16 Aug 2024 11:37:58 +0200 Subject: [PATCH 05/27] refer to our own version of the ubuntu build which will attach artifacts --- .github/workflows/tensorflow-lite.yml | 20 +-- tensorflow-lite/platform/gpu/pom.xml | 167 ++++++++++++++++++++++++++ 2 files changed, 177 insertions(+), 10 deletions(-) create mode 100644 tensorflow-lite/platform/gpu/pom.xml diff --git a/.github/workflows/tensorflow-lite.yml b/.github/workflows/tensorflow-lite.yml index 8755f786afc..94e2b88bd36 100644 --- a/.github/workflows/tensorflow-lite.yml +++ b/.github/workflows/tensorflow-lite.yml @@ -24,27 +24,27 @@ jobs: android-arm64: runs-on: ubuntu-20.04 steps: - - uses: bytedeco/javacpp-presets/.github/actions/deploy-ubuntu@actions + - uses: barrypitman/javacpp-presets/.github/actions/deploy-ubuntu@actions # android-x86: # runs-on: ubuntu-20.04 # steps: -# - uses: bytedeco/javacpp-presets/.github/actions/deploy-ubuntu@actions +# - uses: barrypitman/javacpp-presets/.github/actions/deploy-ubuntu@actions android-x86_64: runs-on: ubuntu-20.04 steps: - - uses: bytedeco/javacpp-presets/.github/actions/deploy-ubuntu@actions + - uses: barrypitman/javacpp-presets/.github/actions/deploy-ubuntu@actions # linux-armhf: # runs-on: ubuntu-20.04 # steps: -# - uses: bytedeco/javacpp-presets/.github/actions/deploy-ubuntu@actions +# - uses: barrypitman/javacpp-presets/.github/actions/deploy-ubuntu@actions linux-arm64: runs-on: ubuntu-20.04 steps: - - uses: bytedeco/javacpp-presets/.github/actions/deploy-ubuntu@actions + - uses: barrypitman/javacpp-presets/.github/actions/deploy-ubuntu@actions # linux-x86: # runs-on: ubuntu-20.04 # steps: -# - uses: bytedeco/javacpp-presets/.github/actions/deploy-ubuntu@actions +# - uses: barrypitman/javacpp-presets/.github/actions/deploy-ubuntu@actions linux-x86_64: runs-on: ubuntu-20.04 strategy: @@ -53,19 +53,19 @@ jobs: - '-gpu' - '' steps: - - uses: bytedeco/javacpp-presets/.github/actions/deploy-ubuntu@actions + - uses: barrypitman/javacpp-presets/.github/actions/deploy-ubuntu@actions macosx-x86_64: runs-on: macos-11 steps: - - uses: bytedeco/javacpp-presets/.github/actions/deploy-macosx@actions + - uses: barrypitman/javacpp-presets/.github/actions/deploy-macosx@actions windows-x86_64: runs-on: windows-2019 steps: - - uses: bytedeco/javacpp-presets/.github/actions/deploy-windows@actions + - uses: barrypitman/javacpp-presets/.github/actions/deploy-windows@actions redeploy: # needs: [android-arm, android-arm64, android-x86, android-x86_64, linux-armhf, linux-arm64, linux-x86, linux-x86_64, macosx-x86_64, windows-x86_64] needs: [android-arm64, android-x86_64, linux-arm64, linux-x86_64, macosx-x86_64, windows-x86_64] runs-on: ubuntu-20.04 steps: - - uses: bytedeco/javacpp-presets/.github/actions/redeploy@actions + - uses: barrypitman/javacpp-presets/.github/actions/redeploy@actions diff --git a/tensorflow-lite/platform/gpu/pom.xml b/tensorflow-lite/platform/gpu/pom.xml new file mode 100644 index 00000000000..e108e0c23f9 --- /dev/null +++ b/tensorflow-lite/platform/gpu/pom.xml @@ -0,0 +1,167 @@ + + + 4.0.0 + + + org.bytedeco + javacpp-presets + 1.5.10 + ../../ + + + org.bytedeco + tensorflow-lite-platform-gpu + 2.15.0-${project.parent.version} + JavaCPP Presets Platform for TensorFlow Lite + + + tensorflow-lite + tensorflowlite + + + + + ${project.groupId} + ${javacpp.moduleId} + ${project.version} + + + + + + + + + ${project.groupId} + ${javacpp.moduleId} + ${project.version} + ${javacpp.platform.android-arm64} + + + + + + + + + ${project.groupId} + ${javacpp.moduleId} + ${project.version} + ${javacpp.platform.android-x86_64} + + + + + + + + + ${project.groupId} + ${javacpp.moduleId} + ${project.version} + ${javacpp.platform.linux-arm64} + + + + + + + + + ${project.groupId} + ${javacpp.moduleId} + ${project.version} + ${javacpp.platform.linux-x86_64} + + + ${project.groupId} + ${javacpp.moduleId} + ${project.version} + ${javacpp.platform.macosx-x86_64} + + + ${project.groupId} + ${javacpp.moduleId} + ${project.version} + ${javacpp.platform.windows-x86_64} + + + + + + + maven-jar-plugin + + + default-jar + + + + ${javacpp.moduleId}.jar ${javacpp.moduleId}-linux-armhf.jar ${javacpp.moduleId}-linux-arm64.jar ${javacpp.moduleId}-linux-x86.jar ${javacpp.moduleId}-linux-x86_64.jar ${javacpp.moduleId}-macosx-x86_64.jar ${javacpp.moduleId}-windows-x86_64.jar + + + + + + empty-javadoc-jar + + jar + + + javadoc + + + + empty-sources-jar + + jar + + + sources + + + + + + org.moditect + moditect-maven-plugin + + + add-module-infos + none + + + add-platform-module-info + package + + add-module-info + + + + + ${project.build.directory}/${project.artifactId}.jar + + module org.bytedeco.${javacpp.packageName}.platform { +// requires static org.bytedeco.${javacpp.moduleId}.android.arm; +// requires static org.bytedeco.${javacpp.moduleId}.android.arm64; +// requires static org.bytedeco.${javacpp.moduleId}.android.x86; +// requires static org.bytedeco.${javacpp.moduleId}.android.x86_64; +// requires static org.bytedeco.${javacpp.packageName}.linux.armhf; + requires static org.bytedeco.${javacpp.packageName}.linux.arm64; +// requires static org.bytedeco.${javacpp.packageName}.linux.x86; + requires static org.bytedeco.${javacpp.packageName}.linux.x86_64; + requires static org.bytedeco.${javacpp.packageName}.macosx.x86_64; + requires static org.bytedeco.${javacpp.packageName}.windows.x86_64; + } + + + + + + + + + + + From ca050e80fbfce04f24e6534b6717fcd87d97c665 Mon Sep 17 00:00:00 2001 From: barry Date: Fri, 16 Aug 2024 11:44:30 +0200 Subject: [PATCH 06/27] refer to our own version of the ubuntu build which will attach artifacts --- .github/workflows/tensorflow-lite.yml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/tensorflow-lite.yml b/.github/workflows/tensorflow-lite.yml index 94e2b88bd36..04cdfed332e 100644 --- a/.github/workflows/tensorflow-lite.yml +++ b/.github/workflows/tensorflow-lite.yml @@ -20,31 +20,31 @@ jobs: # android-arm: # runs-on: ubuntu-20.04 # steps: -# - uses: bytedeco/javacpp-presets/.github/actions/deploy-ubuntu@actions +# - uses: bytedeco/javacpp-presets/.github/actions/deploy-ubuntu android-arm64: runs-on: ubuntu-20.04 steps: - - uses: barrypitman/javacpp-presets/.github/actions/deploy-ubuntu@actions + - uses: ./.github/actions/deploy-ubuntu # android-x86: # runs-on: ubuntu-20.04 # steps: -# - uses: barrypitman/javacpp-presets/.github/actions/deploy-ubuntu@actions +# - uses: ./.github/actions/deploy-ubuntu android-x86_64: runs-on: ubuntu-20.04 steps: - - uses: barrypitman/javacpp-presets/.github/actions/deploy-ubuntu@actions + - uses: ./.github/actions/deploy-ubuntu # linux-armhf: # runs-on: ubuntu-20.04 # steps: -# - uses: barrypitman/javacpp-presets/.github/actions/deploy-ubuntu@actions +# - uses: ./.github/actions/deploy-ubuntu linux-arm64: runs-on: ubuntu-20.04 steps: - - uses: barrypitman/javacpp-presets/.github/actions/deploy-ubuntu@actions + - uses: ./.github/actions/deploy-ubuntu # linux-x86: # runs-on: ubuntu-20.04 # steps: -# - uses: barrypitman/javacpp-presets/.github/actions/deploy-ubuntu@actions +# - uses: ./.github/actions/deploy-ubuntu linux-x86_64: runs-on: ubuntu-20.04 strategy: @@ -53,19 +53,19 @@ jobs: - '-gpu' - '' steps: - - uses: barrypitman/javacpp-presets/.github/actions/deploy-ubuntu@actions + - uses: ./.github/actions/deploy-ubuntu macosx-x86_64: runs-on: macos-11 steps: - - uses: barrypitman/javacpp-presets/.github/actions/deploy-macosx@actions + - uses: ./.github/actions/deploy-macosx windows-x86_64: runs-on: windows-2019 steps: - - uses: barrypitman/javacpp-presets/.github/actions/deploy-windows@actions + - uses: ./.github/actions/deploy-windows redeploy: # needs: [android-arm, android-arm64, android-x86, android-x86_64, linux-armhf, linux-arm64, linux-x86, linux-x86_64, macosx-x86_64, windows-x86_64] needs: [android-arm64, android-x86_64, linux-arm64, linux-x86_64, macosx-x86_64, windows-x86_64] runs-on: ubuntu-20.04 steps: - - uses: barrypitman/javacpp-presets/.github/actions/redeploy@actions + - uses: ./.github/actions/redeploy From 7f72a1b5fbf42ed564074e9a6e9dff60d70dfd08 Mon Sep 17 00:00:00 2001 From: barry Date: Fri, 16 Aug 2024 11:49:49 +0200 Subject: [PATCH 07/27] refer to our own version of the ubuntu build which will attach artifacts --- .github/workflows/tensorflow-lite.yml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/tensorflow-lite.yml b/.github/workflows/tensorflow-lite.yml index 04cdfed332e..e18512db173 100644 --- a/.github/workflows/tensorflow-lite.yml +++ b/.github/workflows/tensorflow-lite.yml @@ -24,27 +24,27 @@ jobs: android-arm64: runs-on: ubuntu-20.04 steps: - - uses: ./.github/actions/deploy-ubuntu + - uses: barrypitman/javacpp-presets/.github/actions/deploy-ubuntu # android-x86: # runs-on: ubuntu-20.04 # steps: -# - uses: ./.github/actions/deploy-ubuntu +# - uses: barrypitman/javacpp-presets/.github/actions/deploy-ubuntu android-x86_64: runs-on: ubuntu-20.04 steps: - - uses: ./.github/actions/deploy-ubuntu + - uses: barrypitman/javacpp-presets/.github/actions/deploy-ubuntu # linux-armhf: # runs-on: ubuntu-20.04 # steps: -# - uses: ./.github/actions/deploy-ubuntu +# - uses: barrypitman/javacpp-presets/.github/actions/deploy-ubuntu linux-arm64: runs-on: ubuntu-20.04 steps: - - uses: ./.github/actions/deploy-ubuntu + - uses: barrypitman/javacpp-presets/.github/actions/deploy-ubuntu # linux-x86: # runs-on: ubuntu-20.04 # steps: -# - uses: ./.github/actions/deploy-ubuntu +# - uses: barrypitman/javacpp-presets/.github/actions/deploy-ubuntu linux-x86_64: runs-on: ubuntu-20.04 strategy: @@ -53,19 +53,19 @@ jobs: - '-gpu' - '' steps: - - uses: ./.github/actions/deploy-ubuntu + - uses: barrypitman/javacpp-presets/.github/actions/deploy-ubuntu macosx-x86_64: runs-on: macos-11 steps: - - uses: ./.github/actions/deploy-macosx + - uses: barrypitman/javacpp-presets/.github/actions/deploy-macosx windows-x86_64: runs-on: windows-2019 steps: - - uses: ./.github/actions/deploy-windows + - uses: barrypitman/javacpp-presets/.github/actions/deploy-windows redeploy: # needs: [android-arm, android-arm64, android-x86, android-x86_64, linux-armhf, linux-arm64, linux-x86, linux-x86_64, macosx-x86_64, windows-x86_64] needs: [android-arm64, android-x86_64, linux-arm64, linux-x86_64, macosx-x86_64, windows-x86_64] runs-on: ubuntu-20.04 steps: - - uses: ./.github/actions/redeploy + - uses: barrypitman/javacpp-presets/.github/actions/redeploy From da830fc06e5664ae5c7427df0d2595d0273bb693 Mon Sep 17 00:00:00 2001 From: barry Date: Fri, 16 Aug 2024 11:51:23 +0200 Subject: [PATCH 08/27] refer to our own version of the ubuntu build which will attach artifacts --- .github/workflows/tensorflow-lite.yml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/tensorflow-lite.yml b/.github/workflows/tensorflow-lite.yml index e18512db173..8755f786afc 100644 --- a/.github/workflows/tensorflow-lite.yml +++ b/.github/workflows/tensorflow-lite.yml @@ -20,31 +20,31 @@ jobs: # android-arm: # runs-on: ubuntu-20.04 # steps: -# - uses: bytedeco/javacpp-presets/.github/actions/deploy-ubuntu +# - uses: bytedeco/javacpp-presets/.github/actions/deploy-ubuntu@actions android-arm64: runs-on: ubuntu-20.04 steps: - - uses: barrypitman/javacpp-presets/.github/actions/deploy-ubuntu + - uses: bytedeco/javacpp-presets/.github/actions/deploy-ubuntu@actions # android-x86: # runs-on: ubuntu-20.04 # steps: -# - uses: barrypitman/javacpp-presets/.github/actions/deploy-ubuntu +# - uses: bytedeco/javacpp-presets/.github/actions/deploy-ubuntu@actions android-x86_64: runs-on: ubuntu-20.04 steps: - - uses: barrypitman/javacpp-presets/.github/actions/deploy-ubuntu + - uses: bytedeco/javacpp-presets/.github/actions/deploy-ubuntu@actions # linux-armhf: # runs-on: ubuntu-20.04 # steps: -# - uses: barrypitman/javacpp-presets/.github/actions/deploy-ubuntu +# - uses: bytedeco/javacpp-presets/.github/actions/deploy-ubuntu@actions linux-arm64: runs-on: ubuntu-20.04 steps: - - uses: barrypitman/javacpp-presets/.github/actions/deploy-ubuntu + - uses: bytedeco/javacpp-presets/.github/actions/deploy-ubuntu@actions # linux-x86: # runs-on: ubuntu-20.04 # steps: -# - uses: barrypitman/javacpp-presets/.github/actions/deploy-ubuntu +# - uses: bytedeco/javacpp-presets/.github/actions/deploy-ubuntu@actions linux-x86_64: runs-on: ubuntu-20.04 strategy: @@ -53,19 +53,19 @@ jobs: - '-gpu' - '' steps: - - uses: barrypitman/javacpp-presets/.github/actions/deploy-ubuntu + - uses: bytedeco/javacpp-presets/.github/actions/deploy-ubuntu@actions macosx-x86_64: runs-on: macos-11 steps: - - uses: barrypitman/javacpp-presets/.github/actions/deploy-macosx + - uses: bytedeco/javacpp-presets/.github/actions/deploy-macosx@actions windows-x86_64: runs-on: windows-2019 steps: - - uses: barrypitman/javacpp-presets/.github/actions/deploy-windows + - uses: bytedeco/javacpp-presets/.github/actions/deploy-windows@actions redeploy: # needs: [android-arm, android-arm64, android-x86, android-x86_64, linux-armhf, linux-arm64, linux-x86, linux-x86_64, macosx-x86_64, windows-x86_64] needs: [android-arm64, android-x86_64, linux-arm64, linux-x86_64, macosx-x86_64, windows-x86_64] runs-on: ubuntu-20.04 steps: - - uses: barrypitman/javacpp-presets/.github/actions/redeploy + - uses: bytedeco/javacpp-presets/.github/actions/redeploy@actions From b49f365875c9fefa26246ccbe99c5562fffc30ac Mon Sep 17 00:00:00 2001 From: barry Date: Fri, 16 Aug 2024 11:52:07 +0200 Subject: [PATCH 09/27] refer to our own version of the ubuntu build which will attach artifacts --- .github/workflows/tensorflow-lite.yml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/tensorflow-lite.yml b/.github/workflows/tensorflow-lite.yml index 8755f786afc..1a2e3c1ac9f 100644 --- a/.github/workflows/tensorflow-lite.yml +++ b/.github/workflows/tensorflow-lite.yml @@ -20,31 +20,31 @@ jobs: # android-arm: # runs-on: ubuntu-20.04 # steps: -# - uses: bytedeco/javacpp-presets/.github/actions/deploy-ubuntu@actions +# - uses: barrypitman/javacpp-presets/.github/actions/deploy-ubuntu@v1.5.10-GPU android-arm64: runs-on: ubuntu-20.04 steps: - - uses: bytedeco/javacpp-presets/.github/actions/deploy-ubuntu@actions + - uses: barrypitman/javacpp-presets/.github/actions/deploy-ubuntu@v1.5.10-GPU # android-x86: # runs-on: ubuntu-20.04 # steps: -# - uses: bytedeco/javacpp-presets/.github/actions/deploy-ubuntu@actions +# - uses: barrypitman/javacpp-presets/.github/actions/deploy-ubuntu@v1.5.10-GPU android-x86_64: runs-on: ubuntu-20.04 steps: - - uses: bytedeco/javacpp-presets/.github/actions/deploy-ubuntu@actions + - uses: barrypitman/javacpp-presets/.github/actions/deploy-ubuntu@v1.5.10-GPU # linux-armhf: # runs-on: ubuntu-20.04 # steps: -# - uses: bytedeco/javacpp-presets/.github/actions/deploy-ubuntu@actions +# - uses: barrypitman/javacpp-presets/.github/actions/deploy-ubuntu@v1.5.10-GPU linux-arm64: runs-on: ubuntu-20.04 steps: - - uses: bytedeco/javacpp-presets/.github/actions/deploy-ubuntu@actions + - uses: barrypitman/javacpp-presets/.github/actions/deploy-ubuntu@v1.5.10-GPU # linux-x86: # runs-on: ubuntu-20.04 # steps: -# - uses: bytedeco/javacpp-presets/.github/actions/deploy-ubuntu@actions +# - uses: barrypitman/javacpp-presets/.github/actions/deploy-ubuntu@v1.5.10-GPU linux-x86_64: runs-on: ubuntu-20.04 strategy: @@ -53,19 +53,19 @@ jobs: - '-gpu' - '' steps: - - uses: bytedeco/javacpp-presets/.github/actions/deploy-ubuntu@actions + - uses: barrypitman/javacpp-presets/.github/actions/deploy-ubuntu@v1.5.10-GPU macosx-x86_64: runs-on: macos-11 steps: - - uses: bytedeco/javacpp-presets/.github/actions/deploy-macosx@actions + - uses: barrypitman/javacpp-presets/.github/actions/deploy-macosx@v1.5.10-GPU windows-x86_64: runs-on: windows-2019 steps: - - uses: bytedeco/javacpp-presets/.github/actions/deploy-windows@actions + - uses: barrypitman/javacpp-presets/.github/actions/deploy-windows@v1.5.10-GPU redeploy: # needs: [android-arm, android-arm64, android-x86, android-x86_64, linux-armhf, linux-arm64, linux-x86, linux-x86_64, macosx-x86_64, windows-x86_64] needs: [android-arm64, android-x86_64, linux-arm64, linux-x86_64, macosx-x86_64, windows-x86_64] runs-on: ubuntu-20.04 steps: - - uses: bytedeco/javacpp-presets/.github/actions/redeploy@actions + - uses: barrypitman/javacpp-presets/.github/actions/redeploy@v1.5.10-GPU From 06608c0183475a231c1968a2cebd6e104caf8a30 Mon Sep 17 00:00:00 2001 From: barry Date: Fri, 16 Aug 2024 12:06:02 +0200 Subject: [PATCH 10/27] trigger rebuild --- tensorflow-lite/cppbuild.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/tensorflow-lite/cppbuild.sh b/tensorflow-lite/cppbuild.sh index b31c1a4eaca..4a77f5814b4 100755 --- a/tensorflow-lite/cppbuild.sh +++ b/tensorflow-lite/cppbuild.sh @@ -105,3 +105,4 @@ if which cygpath; then fi cd ../.. + From 000b538a44f4c11b00162d5dda0c50d9f65f7ede Mon Sep 17 00:00:00 2001 From: barry Date: Fri, 16 Aug 2024 12:30:27 +0200 Subject: [PATCH 11/27] provide different names for artifacts --- .github/actions/deploy-ubuntu/action.yml | 2 ++ tensorflow-lite/platform/gpu/pom.xml | 27 ++++++++++++------------ 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/.github/actions/deploy-ubuntu/action.yml b/.github/actions/deploy-ubuntu/action.yml index 0fe520b7d9d..5831857dab6 100644 --- a/.github/actions/deploy-ubuntu/action.yml +++ b/.github/actions/deploy-ubuntu/action.yml @@ -342,9 +342,11 @@ runs: df -h - name: Attach outputs + if: always() uses: actions/upload-artifact@v4 with: # attach the installed artifacts + name: "${{ env.CI_DEPLOY_MODULE }}-${{ env.CI_DEPLOY_PLATFORM }}-${{ matrix.ext }}" path: /home/runner/.m2/repository/org/bytedeco/${{ env.CI_DEPLOY_MODULE }}/ - name: Clean up diff --git a/tensorflow-lite/platform/gpu/pom.xml b/tensorflow-lite/platform/gpu/pom.xml index e108e0c23f9..6d3e0b5b7ad 100644 --- a/tensorflow-lite/platform/gpu/pom.xml +++ b/tensorflow-lite/platform/gpu/pom.xml @@ -7,17 +7,18 @@ org.bytedeco javacpp-presets 1.5.10 - ../../ + ../../../ org.bytedeco tensorflow-lite-platform-gpu 2.15.0-${project.parent.version} - JavaCPP Presets Platform for TensorFlow Lite + JavaCPP Presets Platform GPU for TensorFlow Lite tensorflow-lite tensorflowlite + -gpu @@ -98,7 +99,7 @@ - ${javacpp.moduleId}.jar ${javacpp.moduleId}-linux-armhf.jar ${javacpp.moduleId}-linux-arm64.jar ${javacpp.moduleId}-linux-x86.jar ${javacpp.moduleId}-linux-x86_64.jar ${javacpp.moduleId}-macosx-x86_64.jar ${javacpp.moduleId}-windows-x86_64.jar + ${javacpp.moduleId}.jar ${javacpp.moduleId}-linux-armhf-gpu.jar ${javacpp.moduleId}-linux-arm64-gpu.jar ${javacpp.moduleId}-linux-x86-gpu.jar ${javacpp.moduleId}-linux-x86_64-gpu.jar ${javacpp.moduleId}-macosx-x86_64-gpu.jar ${javacpp.moduleId}-windows-x86_64-gpu.jar @@ -143,16 +144,16 @@ ${project.build.directory}/${project.artifactId}.jar module org.bytedeco.${javacpp.packageName}.platform { -// requires static org.bytedeco.${javacpp.moduleId}.android.arm; -// requires static org.bytedeco.${javacpp.moduleId}.android.arm64; -// requires static org.bytedeco.${javacpp.moduleId}.android.x86; -// requires static org.bytedeco.${javacpp.moduleId}.android.x86_64; -// requires static org.bytedeco.${javacpp.packageName}.linux.armhf; - requires static org.bytedeco.${javacpp.packageName}.linux.arm64; -// requires static org.bytedeco.${javacpp.packageName}.linux.x86; - requires static org.bytedeco.${javacpp.packageName}.linux.x86_64; - requires static org.bytedeco.${javacpp.packageName}.macosx.x86_64; - requires static org.bytedeco.${javacpp.packageName}.windows.x86_64; +// requires static org.bytedeco.${javacpp.moduleId}.android.arm.gpu; +// requires static org.bytedeco.${javacpp.moduleId}.android.arm64.gpu; +// requires static org.bytedeco.${javacpp.moduleId}.android.x86.gpu; +// requires static org.bytedeco.${javacpp.moduleId}.android.x86_64.gpu; +// requires static org.bytedeco.${javacpp.packageName}.linux.armhf.gpu; + requires static org.bytedeco.${javacpp.packageName}.linux.arm64.gpu; +// requires static org.bytedeco.${javacpp.packageName}.linux.x86.gpu; + requires static org.bytedeco.${javacpp.packageName}.linux.x86_64.gpu; + requires static org.bytedeco.${javacpp.packageName}.macosx.x86_64.gpu; + requires static org.bytedeco.${javacpp.packageName}.windows.x86_64.gpu; } From b247282e80e318c84d96b3528c884e389b426be7 Mon Sep 17 00:00:00 2001 From: barry Date: Fri, 16 Aug 2024 13:32:18 +0200 Subject: [PATCH 12/27] try to generate GPU delegate --- .github/actions/deploy-ubuntu/action.yml | 2 +- .../org/bytedeco/tensorflowlite/presets/tensorflowlite.java | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/actions/deploy-ubuntu/action.yml b/.github/actions/deploy-ubuntu/action.yml index 5831857dab6..63daf4c888e 100644 --- a/.github/actions/deploy-ubuntu/action.yml +++ b/.github/actions/deploy-ubuntu/action.yml @@ -346,7 +346,7 @@ runs: uses: actions/upload-artifact@v4 with: # attach the installed artifacts - name: "${{ env.CI_DEPLOY_MODULE }}-${{ env.CI_DEPLOY_PLATFORM }}-${{ matrix.ext }}" + name: "${{ env.CI_DEPLOY_MODULE }}-${{ env.CI_DEPLOY_PLATFORM }}${{ matrix.ext }}" path: /home/runner/.m2/repository/org/bytedeco/${{ env.CI_DEPLOY_MODULE }}/ - name: Clean up diff --git a/tensorflow-lite/src/main/java/org/bytedeco/tensorflowlite/presets/tensorflowlite.java b/tensorflow-lite/src/main/java/org/bytedeco/tensorflowlite/presets/tensorflowlite.java index e0d38f01f3d..92978c80a3d 100644 --- a/tensorflow-lite/src/main/java/org/bytedeco/tensorflowlite/presets/tensorflowlite.java +++ b/tensorflow-lite/src/main/java/org/bytedeco/tensorflowlite/presets/tensorflowlite.java @@ -99,6 +99,8 @@ "tensorflow/lite/profiling/telemetry/c/telemetry_setting.h", "tensorflow/lite/profiling/telemetry/telemetry_status.h", "tensorflow/lite/profiling/telemetry/profiler.h", + "tensorflow/lite/delegates/gpu/delegate.h", + "tensorflow/lite/delegates/gpu/delegate_options.h", } // link = "tensorflowlite_c" ), From 0816ed0b80a358f15287ae4402bce1d73848c50b Mon Sep 17 00:00:00 2001 From: barry Date: Fri, 16 Aug 2024 14:26:42 +0200 Subject: [PATCH 13/27] try to generate GPU delegate --- .../tensorflowlite/presets/tensorflowlite.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/tensorflow-lite/src/main/java/org/bytedeco/tensorflowlite/presets/tensorflowlite.java b/tensorflow-lite/src/main/java/org/bytedeco/tensorflowlite/presets/tensorflowlite.java index 92978c80a3d..194ff6b3e91 100644 --- a/tensorflow-lite/src/main/java/org/bytedeco/tensorflowlite/presets/tensorflowlite.java +++ b/tensorflow-lite/src/main/java/org/bytedeco/tensorflowlite/presets/tensorflowlite.java @@ -99,14 +99,22 @@ "tensorflow/lite/profiling/telemetry/c/telemetry_setting.h", "tensorflow/lite/profiling/telemetry/telemetry_status.h", "tensorflow/lite/profiling/telemetry/profiler.h", - "tensorflow/lite/delegates/gpu/delegate.h", - "tensorflow/lite/delegates/gpu/delegate_options.h", } // link = "tensorflowlite_c" - ), + ), @Platform( + value = {"android", "linux"}, + extension = "-gpu", + define = "UNIQUE_PTR_NAMESPACE std", + include = { + "tensorflow/lite/delegates/gpu/delegate.h", +// "tensorflow/lite/delegates/gpu/delegate_options.h", + } +// link = "tensorflowlite_c" + ) }, target = "org.bytedeco.tensorflowlite", global = "org.bytedeco.tensorflowlite.global.tensorflowlite") + public class tensorflowlite implements InfoMapper { static { Loader.checkVersion("org.bytedeco", "tensorflow-lite"); } From 95590cc952d4a311e6f733483e9a1995fddb55ae Mon Sep 17 00:00:00 2001 From: barry Date: Fri, 16 Aug 2024 15:26:18 +0200 Subject: [PATCH 14/27] add missing delegate_options --- .../org/bytedeco/tensorflowlite/presets/tensorflowlite.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tensorflow-lite/src/main/java/org/bytedeco/tensorflowlite/presets/tensorflowlite.java b/tensorflow-lite/src/main/java/org/bytedeco/tensorflowlite/presets/tensorflowlite.java index 194ff6b3e91..5252263a22f 100644 --- a/tensorflow-lite/src/main/java/org/bytedeco/tensorflowlite/presets/tensorflowlite.java +++ b/tensorflow-lite/src/main/java/org/bytedeco/tensorflowlite/presets/tensorflowlite.java @@ -107,7 +107,7 @@ define = "UNIQUE_PTR_NAMESPACE std", include = { "tensorflow/lite/delegates/gpu/delegate.h", -// "tensorflow/lite/delegates/gpu/delegate_options.h", + "tensorflow/lite/delegates/gpu/delegate_options.h", } // link = "tensorflowlite_c" ) From 11023db5c1ef5901119cbc543a6da63a726ce695 Mon Sep 17 00:00:00 2001 From: barry Date: Fri, 16 Aug 2024 20:16:40 +0200 Subject: [PATCH 15/27] add other header files for gpu extension --- .../presets/tensorflowlite.java | 318 +++++++++++------- 1 file changed, 189 insertions(+), 129 deletions(-) diff --git a/tensorflow-lite/src/main/java/org/bytedeco/tensorflowlite/presets/tensorflowlite.java b/tensorflow-lite/src/main/java/org/bytedeco/tensorflowlite/presets/tensorflowlite.java index 5252263a22f..7090a072121 100644 --- a/tensorflow-lite/src/main/java/org/bytedeco/tensorflowlite/presets/tensorflowlite.java +++ b/tensorflow-lite/src/main/java/org/bytedeco/tensorflowlite/presets/tensorflowlite.java @@ -25,6 +25,7 @@ import java.io.File; import java.io.IOException; import java.util.Arrays; + import org.bytedeco.javacpp.Loader; import org.bytedeco.javacpp.annotation.NoException; import org.bytedeco.javacpp.annotation.Platform; @@ -34,156 +35,215 @@ import org.bytedeco.javacpp.tools.InfoMapper; /** - * * @author Samuel Audet */ @Properties( - value = { - @Platform( - value = {"android", "linux", "macosx", "windows"}, - compiler = "cpp17", - define = "UNIQUE_PTR_NAMESPACE std", - include = { + value = { + @Platform( + value = {"android", "linux", "macosx", "windows"}, + compiler = "cpp17", + define = "UNIQUE_PTR_NAMESPACE std", + include = { // "flatbuffers/base.h", // "flatbuffers/flatbuffers.h", // "tensorflow/lite/schema/schema_generated.h", - "tensorflow/lite/builtin_ops.h", - "tensorflow/lite/c/c_api_types.h", - "tensorflow/lite/core/c/c_api_types.h", - "tensorflow/lite/c/c_api.h", - "tensorflow/lite/core/c/c_api.h", - "tensorflow/lite/core/c/registration_external.h", - "tensorflow/lite/c/c_api_experimental.h", - "tensorflow/lite/core/c/c_api_experimental.h", - "tensorflow/lite/c/common.h", - "tensorflow/lite/core/c/common.h", - "tensorflow/lite/core/api/error_reporter.h", - "tensorflow/lite/core/api/op_resolver.h", - "tensorflow/lite/core/api/profiler.h", - "tensorflow/lite/core/api/verifier.h", - "tensorflow/lite/experimental/resource/initialization_status.h", - "tensorflow/lite/experimental/resource/resource_base.h", - "tensorflow/lite/allocation.h", - "tensorflow/lite/stderr_reporter.h", - "tensorflow/lite/graph_info.h", - "tensorflow/lite/interpreter_options.h", - "tensorflow/lite/memory_planner.h", - "tensorflow/lite/util.h", + "tensorflow/lite/builtin_ops.h", + "tensorflow/lite/c/c_api_types.h", + "tensorflow/lite/core/c/c_api_types.h", + "tensorflow/lite/c/c_api.h", + "tensorflow/lite/core/c/c_api.h", + "tensorflow/lite/core/c/registration_external.h", + "tensorflow/lite/c/c_api_experimental.h", + "tensorflow/lite/core/c/c_api_experimental.h", + "tensorflow/lite/c/common.h", + "tensorflow/lite/core/c/common.h", + "tensorflow/lite/core/api/error_reporter.h", + "tensorflow/lite/core/api/op_resolver.h", + "tensorflow/lite/core/api/profiler.h", + "tensorflow/lite/core/api/verifier.h", + "tensorflow/lite/experimental/resource/initialization_status.h", + "tensorflow/lite/experimental/resource/resource_base.h", + "tensorflow/lite/allocation.h", + "tensorflow/lite/stderr_reporter.h", + "tensorflow/lite/graph_info.h", + "tensorflow/lite/interpreter_options.h", + "tensorflow/lite/memory_planner.h", + "tensorflow/lite/util.h", // "tensorflow/lite/array.h", - "tensorflow/lite/core/macros.h", - "tensorflow/lite/core/subgraph.h", - "tensorflow/lite/external_cpu_backend_context.h", - "tensorflow/lite/portable_type_to_tflitetype.h", - "tensorflow/lite/profiling/root_profiler.h", - "tensorflow/lite/signature_runner.h", - "tensorflow/lite/core/signature_runner.h", - "tensorflow/lite/type_to_tflitetype.h", - "tensorflow/lite/string_type.h", - "tensorflow/lite/mutable_op_resolver.h", - "tensorflow/lite/interpreter.h", - "tensorflow/lite/core/interpreter.h", - "tensorflow/lite/model_builder.h", - "tensorflow/lite/core/model_builder.h", - "tensorflow/lite/interpreter_builder.h", - "tensorflow/lite/core/interpreter_builder.h", - "tensorflow/lite/model.h", - "tensorflow/lite/kernels/register.h", - "tensorflow/lite/core/kernels/register.h", - "tensorflow/lite/optional_debug_tools.h", + "tensorflow/lite/core/macros.h", + "tensorflow/lite/core/subgraph.h", + "tensorflow/lite/external_cpu_backend_context.h", + "tensorflow/lite/portable_type_to_tflitetype.h", + "tensorflow/lite/profiling/root_profiler.h", + "tensorflow/lite/signature_runner.h", + "tensorflow/lite/core/signature_runner.h", + "tensorflow/lite/type_to_tflitetype.h", + "tensorflow/lite/string_type.h", + "tensorflow/lite/mutable_op_resolver.h", + "tensorflow/lite/interpreter.h", + "tensorflow/lite/core/interpreter.h", + "tensorflow/lite/model_builder.h", + "tensorflow/lite/core/model_builder.h", + "tensorflow/lite/interpreter_builder.h", + "tensorflow/lite/core/interpreter_builder.h", + "tensorflow/lite/model.h", + "tensorflow/lite/kernels/register.h", + "tensorflow/lite/core/kernels/register.h", + "tensorflow/lite/optional_debug_tools.h", // "tensorflow/lite/core/async/c/types.h", // "tensorflow/lite/core/async/interop/c/types.h", // "tensorflow/lite/core/async/interop/c/attribute_map.h", // "tensorflow/lite/core/async/async_signature_runner.h", // "tensorflow/lite/core/async/c/async_signature_runner.h", - "tensorflow/lite/profiling/telemetry/c/profiler.h", - "tensorflow/lite/profiling/telemetry/c/telemetry_setting.h", - "tensorflow/lite/profiling/telemetry/telemetry_status.h", - "tensorflow/lite/profiling/telemetry/profiler.h", - } + "tensorflow/lite/profiling/telemetry/c/profiler.h", + "tensorflow/lite/profiling/telemetry/c/telemetry_setting.h", + "tensorflow/lite/profiling/telemetry/telemetry_status.h", + "tensorflow/lite/profiling/telemetry/profiler.h", + } // link = "tensorflowlite_c" - ), @Platform( - value = {"android", "linux"}, - extension = "-gpu", - define = "UNIQUE_PTR_NAMESPACE std", - include = { - "tensorflow/lite/delegates/gpu/delegate.h", - "tensorflow/lite/delegates/gpu/delegate_options.h", - } + ), @Platform( + value = {"android", "linux"}, + extension = "-gpu", + define = "UNIQUE_PTR_NAMESPACE std", + include = { + + + "tensorflow/lite/builtin_ops.h", + "tensorflow/lite/c/c_api_types.h", + "tensorflow/lite/core/c/c_api_types.h", + "tensorflow/lite/c/c_api.h", + "tensorflow/lite/core/c/c_api.h", + "tensorflow/lite/core/c/registration_external.h", + "tensorflow/lite/c/c_api_experimental.h", + "tensorflow/lite/core/c/c_api_experimental.h", + "tensorflow/lite/c/common.h", + "tensorflow/lite/core/c/common.h", + "tensorflow/lite/core/api/error_reporter.h", + "tensorflow/lite/core/api/op_resolver.h", + "tensorflow/lite/core/api/profiler.h", + "tensorflow/lite/core/api/verifier.h", + "tensorflow/lite/experimental/resource/initialization_status.h", + "tensorflow/lite/experimental/resource/resource_base.h", + "tensorflow/lite/allocation.h", + "tensorflow/lite/stderr_reporter.h", + "tensorflow/lite/graph_info.h", + "tensorflow/lite/interpreter_options.h", + "tensorflow/lite/memory_planner.h", + "tensorflow/lite/util.h", +// "tensorflow/lite/array.h", + "tensorflow/lite/core/macros.h", + "tensorflow/lite/core/subgraph.h", + "tensorflow/lite/external_cpu_backend_context.h", + "tensorflow/lite/portable_type_to_tflitetype.h", + "tensorflow/lite/profiling/root_profiler.h", + "tensorflow/lite/signature_runner.h", + "tensorflow/lite/core/signature_runner.h", + "tensorflow/lite/type_to_tflitetype.h", + "tensorflow/lite/string_type.h", + "tensorflow/lite/mutable_op_resolver.h", + "tensorflow/lite/interpreter.h", + "tensorflow/lite/core/interpreter.h", + "tensorflow/lite/model_builder.h", + "tensorflow/lite/core/model_builder.h", + "tensorflow/lite/interpreter_builder.h", + "tensorflow/lite/core/interpreter_builder.h", + "tensorflow/lite/model.h", + "tensorflow/lite/kernels/register.h", + "tensorflow/lite/core/kernels/register.h", + "tensorflow/lite/optional_debug_tools.h", +// "tensorflow/lite/core/async/c/types.h", +// "tensorflow/lite/core/async/interop/c/types.h", +// "tensorflow/lite/core/async/interop/c/attribute_map.h", +// "tensorflow/lite/core/async/async_signature_runner.h", +// "tensorflow/lite/core/async/c/async_signature_runner.h", + "tensorflow/lite/profiling/telemetry/c/profiler.h", + "tensorflow/lite/profiling/telemetry/c/telemetry_setting.h", + "tensorflow/lite/profiling/telemetry/telemetry_status.h", + "tensorflow/lite/profiling/telemetry/profiler.h", + + + + "tensorflow/lite/delegates/gpu/delegate.h", + "tensorflow/lite/delegates/gpu/delegate_options.h", + } + // link = "tensorflowlite_c" - ) - }, - target = "org.bytedeco.tensorflowlite", - global = "org.bytedeco.tensorflowlite.global.tensorflowlite") + ) + }, + target = "org.bytedeco.tensorflowlite", + global = "org.bytedeco.tensorflowlite.global.tensorflowlite") public class tensorflowlite implements InfoMapper { - static { Loader.checkVersion("org.bytedeco", "tensorflow-lite"); } + static { + Loader.checkVersion("org.bytedeco", "tensorflow-lite"); + } public void map(InfoMap infoMap) { infoMap.put(new Info("TFLITE_ATTRIBUTE_WEAK", "TFL_CAPI_EXPORT", "TFLITE_NOINLINE").cppTypes().annotations()) - .put(new Info("FLATBUFFERS_LITTLEENDIAN == 0").define(false)) - .put(new Info("TfLiteIntArray", "TfLiteFloatArray").purify()) - .put(new Info("tflite::ops::builtin::BuiltinOpResolver").pointerTypes("BuiltinOpResolver")) - .put(new Info("tflite::ops::builtin::BuiltinOpResolverWithoutDefaultDelegates").pointerTypes("BuiltinOpResolverWithoutDefaultDelegates")) - .put(new Info("std::initializer_list", "tflite::BuildTfLiteTensor", "tflite::typeToTfLiteType", "TfLiteContext::ReportError", "tflite::MMAPAllocation", - "tflite::OpResolver::GetOpaqueDelegateCreators", "tflite::MutableOpResolver::GetOpaqueDelegateCreators", "IntArrayUniquePtr", - "tflite::InterpreterBuilder::PreserveAllTensorsExperimental", "tflite::async::AsyncSignatureRunner", "TfLiteAsyncKernel").skip()) - .put(new Info("kTfLiteInplaceOpMaxValue").translate(false)) - .put(new Info("tflite::Model", "tflite::ModelT", "tflite::OperatorCode", "tflite::OpResolver::TfLiteDelegateCreators", - "tflite::internal::SignatureDef").cast().pointerTypes("Pointer")) - .put(new Info("tflite::Subgraph").valueTypes("@StdMove Subgraph").pointerTypes("Subgraph")) - .put(new Info("std::int32_t", "std::uint32_t", "tflite::BuiltinOperator", - "tflite::profiling::RootProfiler::EventType").cast().valueTypes("int").pointerTypes("IntPointer", "IntBuffer", "int[]")) - .put(new Info("std::string").annotations("@StdString").valueTypes("String", "BytePointer").pointerTypes("@Cast({\"char*\", \"std::string*\"}) BytePointer")) - .put(new Info("std::vector").pointerTypes("StringVector").define()) - .put(new Info("std::map").pointerTypes("StringIntMap").define()) - .put(new Info("std::map").pointerTypes("StringStringMap").define()) - .put(new Info("std::unique_ptr").annotations("@UniquePtr(\"TfLiteDelegate,void(*)(TfLiteDelegate*)\")").pointerTypes("TfLiteDelegate")) - .put(new Info("std::unique_ptr").annotations("@UniquePtr(\"TfLiteIntArray,tflite::TfLiteArrayDeleter\")").pointerTypes("TfLiteIntArray")) - .put(new Info("std::unique_ptr").annotations("@UniquePtr").pointerTypes("Subgraph") - .valueTypes("@Cast({\"\", \"std::unique_ptr&&\"}) Subgraph")) - .put(new Info("std::unique_ptr").annotations("@UniquePtr").pointerTypes("ResourceBase") - .valueTypes("@Cast({\"\", \"std::unique_ptr&&\"}) ResourceBase")) - .put(new Info("std::pair", "tflite::ControlEdge").cast().pointerTypes("IntIntPair").define()) - .put(new Info("std::pair").pointerTypes("RegistrationNodePair").define()) - .put(new Info("std::vector").pointerTypes("NodeSubsetVector").define()) - .put(new Info("std::vector >").valueTypes("@StdMove SubgraphVector").pointerTypes("SubgraphVector").define()) - .put(new Info("std::vector >", "tflite::ControlEdges").cast().pointerTypes("IntIntPairVector").define()) - .put(new Info("std::vector >").valueTypes("@StdMove RegistrationNodePairVector").pointerTypes("RegistrationNodePairVector").define()) - .put(new Info("const std::vector >", "tflite::OpResolver::TfLiteDelegatePtrVector").pointerTypes("TfLiteDelegatePtrVector").define()) - .put(new Info("std::unordered_map >").valueTypes("@StdMove IntResourceBaseMap").pointerTypes("IntResourceBaseMap").define()) - .put(new Info("const TfLiteRegistrationExternal* (*)(void*, int, int)").pointerTypes("Find_builtin_op_external_Pointer_int_int")) - .put(new Info("const TfLiteRegistrationExternal* (*)(void*, const char*, int)").pointerTypes("Find_custom_op_external_Pointer_String_int")) - - .put(new Info("tflite::impl::Interpreter::typed_tensor").javaNames("typed_tensor_byte")) - .put(new Info("tflite::impl::Interpreter::typed_tensor").javaNames("typed_tensor_short")) - .put(new Info("tflite::impl::Interpreter::typed_tensor").javaNames("typed_tensor_int")) - .put(new Info("tflite::impl::Interpreter::typed_tensor").javaNames("typed_tensor_long")) - .put(new Info("tflite::impl::Interpreter::typed_tensor").javaNames("typed_tensor_float")) - .put(new Info("tflite::impl::Interpreter::typed_tensor").javaNames("typed_tensor_double")) - .put(new Info("tflite::impl::Interpreter::typed_tensor").javaNames("typed_tensor_bool")) - .put(new Info("tflite::impl::Interpreter::typed_tensor").javaNames("typed_tensor_float16")) - - .put(new Info("tflite::impl::Interpreter::typed_input_tensor").javaNames("typed_input_tensor_byte")) - .put(new Info("tflite::impl::Interpreter::typed_input_tensor").javaNames("typed_input_tensor_short")) - .put(new Info("tflite::impl::Interpreter::typed_input_tensor").javaNames("typed_input_tensor_int")) - .put(new Info("tflite::impl::Interpreter::typed_input_tensor").javaNames("typed_input_tensor_long")) - .put(new Info("tflite::impl::Interpreter::typed_input_tensor").javaNames("typed_input_tensor_float")) - .put(new Info("tflite::impl::Interpreter::typed_input_tensor").javaNames("typed_input_tensor_double")) - .put(new Info("tflite::impl::Interpreter::typed_input_tensor").javaNames("typed_input_tensor_bool")) - .put(new Info("tflite::impl::Interpreter::typed_input_tensor").javaNames("typed_input_tensor_float16")) - - .put(new Info("tflite::impl::Interpreter::typed_output_tensor").javaNames("typed_output_tensor_byte")) - .put(new Info("tflite::impl::Interpreter::typed_output_tensor").javaNames("typed_output_tensor_short")) - .put(new Info("tflite::impl::Interpreter::typed_output_tensor").javaNames("typed_output_tensor_int")) - .put(new Info("tflite::impl::Interpreter::typed_output_tensor").javaNames("typed_output_tensor_long")) - .put(new Info("tflite::impl::Interpreter::typed_output_tensor").javaNames("typed_output_tensor_float")) - .put(new Info("tflite::impl::Interpreter::typed_output_tensor").javaNames("typed_output_tensor_double")) - .put(new Info("tflite::impl::Interpreter::typed_output_tensor").javaNames("typed_output_tensor_bool")) - .put(new Info("tflite::impl::Interpreter::typed_output_tensor").javaNames("typed_input_tensor_float16")) + .put(new Info("FLATBUFFERS_LITTLEENDIAN == 0").define(false)) + .put(new Info("TfLiteIntArray", "TfLiteFloatArray").purify()) + .put(new Info("tflite::ops::builtin::BuiltinOpResolver").pointerTypes("BuiltinOpResolver")) + .put(new Info("tflite::ops::builtin::BuiltinOpResolverWithoutDefaultDelegates").pointerTypes("BuiltinOpResolverWithoutDefaultDelegates")) + .put(new Info("std::initializer_list", "tflite::BuildTfLiteTensor", "tflite::typeToTfLiteType", "TfLiteContext::ReportError", "tflite::MMAPAllocation", + "tflite::OpResolver::GetOpaqueDelegateCreators", "tflite::MutableOpResolver::GetOpaqueDelegateCreators", "IntArrayUniquePtr", + "tflite::InterpreterBuilder::PreserveAllTensorsExperimental", "tflite::async::AsyncSignatureRunner", "TfLiteAsyncKernel").skip()) + .put(new Info("kTfLiteInplaceOpMaxValue").translate(false)) + .put(new Info("tflite::Model", "tflite::ModelT", "tflite::OperatorCode", "tflite::OpResolver::TfLiteDelegateCreators", + "tflite::internal::SignatureDef").cast().pointerTypes("Pointer")) + .put(new Info("tflite::Subgraph").valueTypes("@StdMove Subgraph").pointerTypes("Subgraph")) + .put(new Info("std::int32_t", "std::uint32_t", "tflite::BuiltinOperator", + "tflite::profiling::RootProfiler::EventType").cast().valueTypes("int").pointerTypes("IntPointer", "IntBuffer", "int[]")) + .put(new Info("std::string").annotations("@StdString").valueTypes("String", "BytePointer").pointerTypes("@Cast({\"char*\", \"std::string*\"}) BytePointer")) + .put(new Info("std::vector").pointerTypes("StringVector").define()) + .put(new Info("std::map").pointerTypes("StringIntMap").define()) + .put(new Info("std::map").pointerTypes("StringStringMap").define()) + .put(new Info("std::unique_ptr").annotations("@UniquePtr(\"TfLiteDelegate,void(*)(TfLiteDelegate*)\")").pointerTypes("TfLiteDelegate")) + .put(new Info("std::unique_ptr").annotations("@UniquePtr(\"TfLiteIntArray,tflite::TfLiteArrayDeleter\")").pointerTypes("TfLiteIntArray")) + .put(new Info("std::unique_ptr").annotations("@UniquePtr").pointerTypes("Subgraph") + .valueTypes("@Cast({\"\", \"std::unique_ptr&&\"}) Subgraph")) + .put(new Info("std::unique_ptr").annotations("@UniquePtr").pointerTypes("ResourceBase") + .valueTypes("@Cast({\"\", \"std::unique_ptr&&\"}) ResourceBase")) + .put(new Info("std::pair", "tflite::ControlEdge").cast().pointerTypes("IntIntPair").define()) + .put(new Info("std::pair").pointerTypes("RegistrationNodePair").define()) + .put(new Info("std::vector").pointerTypes("NodeSubsetVector").define()) + .put(new Info("std::vector >").valueTypes("@StdMove SubgraphVector").pointerTypes("SubgraphVector").define()) + .put(new Info("std::vector >", "tflite::ControlEdges").cast().pointerTypes("IntIntPairVector").define()) + .put(new Info("std::vector >").valueTypes("@StdMove RegistrationNodePairVector").pointerTypes("RegistrationNodePairVector").define()) + .put(new Info("const std::vector >", "tflite::OpResolver::TfLiteDelegatePtrVector").pointerTypes("TfLiteDelegatePtrVector").define()) + .put(new Info("std::unordered_map >").valueTypes("@StdMove IntResourceBaseMap").pointerTypes("IntResourceBaseMap").define()) + .put(new Info("const TfLiteRegistrationExternal* (*)(void*, int, int)").pointerTypes("Find_builtin_op_external_Pointer_int_int")) + .put(new Info("const TfLiteRegistrationExternal* (*)(void*, const char*, int)").pointerTypes("Find_custom_op_external_Pointer_String_int")) + + .put(new Info("tflite::impl::Interpreter::typed_tensor").javaNames("typed_tensor_byte")) + .put(new Info("tflite::impl::Interpreter::typed_tensor").javaNames("typed_tensor_short")) + .put(new Info("tflite::impl::Interpreter::typed_tensor").javaNames("typed_tensor_int")) + .put(new Info("tflite::impl::Interpreter::typed_tensor").javaNames("typed_tensor_long")) + .put(new Info("tflite::impl::Interpreter::typed_tensor").javaNames("typed_tensor_float")) + .put(new Info("tflite::impl::Interpreter::typed_tensor").javaNames("typed_tensor_double")) + .put(new Info("tflite::impl::Interpreter::typed_tensor").javaNames("typed_tensor_bool")) + .put(new Info("tflite::impl::Interpreter::typed_tensor").javaNames("typed_tensor_float16")) + + .put(new Info("tflite::impl::Interpreter::typed_input_tensor").javaNames("typed_input_tensor_byte")) + .put(new Info("tflite::impl::Interpreter::typed_input_tensor").javaNames("typed_input_tensor_short")) + .put(new Info("tflite::impl::Interpreter::typed_input_tensor").javaNames("typed_input_tensor_int")) + .put(new Info("tflite::impl::Interpreter::typed_input_tensor").javaNames("typed_input_tensor_long")) + .put(new Info("tflite::impl::Interpreter::typed_input_tensor").javaNames("typed_input_tensor_float")) + .put(new Info("tflite::impl::Interpreter::typed_input_tensor").javaNames("typed_input_tensor_double")) + .put(new Info("tflite::impl::Interpreter::typed_input_tensor").javaNames("typed_input_tensor_bool")) + .put(new Info("tflite::impl::Interpreter::typed_input_tensor").javaNames("typed_input_tensor_float16")) + + .put(new Info("tflite::impl::Interpreter::typed_output_tensor").javaNames("typed_output_tensor_byte")) + .put(new Info("tflite::impl::Interpreter::typed_output_tensor").javaNames("typed_output_tensor_short")) + .put(new Info("tflite::impl::Interpreter::typed_output_tensor").javaNames("typed_output_tensor_int")) + .put(new Info("tflite::impl::Interpreter::typed_output_tensor").javaNames("typed_output_tensor_long")) + .put(new Info("tflite::impl::Interpreter::typed_output_tensor").javaNames("typed_output_tensor_float")) + .put(new Info("tflite::impl::Interpreter::typed_output_tensor").javaNames("typed_output_tensor_double")) + .put(new Info("tflite::impl::Interpreter::typed_output_tensor").javaNames("typed_output_tensor_bool")) + .put(new Info("tflite::impl::Interpreter::typed_output_tensor").javaNames("typed_input_tensor_float16")) // Classes passed to some native functions as unique_ptr and that can be allocated Java-side - .put(new Info("tflite::impl::Interpreter::Interpreter").annotations("@UniquePtr", "@Name(\"std::make_unique\")")) - .put(new Info("tflite::Subgraph::Subgraph").annotations("@UniquePtr", "@Name(\"std::make_unique\")")) + .put(new Info("tflite::impl::Interpreter::Interpreter").annotations("@UniquePtr", "@Name(\"std::make_unique\")")) + .put(new Info("tflite::Subgraph::Subgraph").annotations("@UniquePtr", "@Name(\"std::make_unique\")")) ; } } From 2de3669c55ceff959a2830cdcca6112711d01286 Mon Sep 17 00:00:00 2001 From: barry Date: Sat, 17 Aug 2024 10:42:42 +0200 Subject: [PATCH 16/27] try suggestions from https://github.com/bytedeco/javacpp-presets/issues/1529#issuecomment-2294494948 --- .../presets/tensorflowlite.java | 84 ++++--------------- 1 file changed, 15 insertions(+), 69 deletions(-) diff --git a/tensorflow-lite/src/main/java/org/bytedeco/tensorflowlite/presets/tensorflowlite.java b/tensorflow-lite/src/main/java/org/bytedeco/tensorflowlite/presets/tensorflowlite.java index 7090a072121..5dfc03e66af 100644 --- a/tensorflow-lite/src/main/java/org/bytedeco/tensorflowlite/presets/tensorflowlite.java +++ b/tensorflow-lite/src/main/java/org/bytedeco/tensorflowlite/presets/tensorflowlite.java @@ -99,77 +99,12 @@ "tensorflow/lite/profiling/telemetry/c/telemetry_setting.h", "tensorflow/lite/profiling/telemetry/telemetry_status.h", "tensorflow/lite/profiling/telemetry/profiler.h", - } -// link = "tensorflowlite_c" - ), @Platform( - value = {"android", "linux"}, - extension = "-gpu", - define = "UNIQUE_PTR_NAMESPACE std", - include = { - - - "tensorflow/lite/builtin_ops.h", - "tensorflow/lite/c/c_api_types.h", - "tensorflow/lite/core/c/c_api_types.h", - "tensorflow/lite/c/c_api.h", - "tensorflow/lite/core/c/c_api.h", - "tensorflow/lite/core/c/registration_external.h", - "tensorflow/lite/c/c_api_experimental.h", - "tensorflow/lite/core/c/c_api_experimental.h", - "tensorflow/lite/c/common.h", - "tensorflow/lite/core/c/common.h", - "tensorflow/lite/core/api/error_reporter.h", - "tensorflow/lite/core/api/op_resolver.h", - "tensorflow/lite/core/api/profiler.h", - "tensorflow/lite/core/api/verifier.h", - "tensorflow/lite/experimental/resource/initialization_status.h", - "tensorflow/lite/experimental/resource/resource_base.h", - "tensorflow/lite/allocation.h", - "tensorflow/lite/stderr_reporter.h", - "tensorflow/lite/graph_info.h", - "tensorflow/lite/interpreter_options.h", - "tensorflow/lite/memory_planner.h", - "tensorflow/lite/util.h", -// "tensorflow/lite/array.h", - "tensorflow/lite/core/macros.h", - "tensorflow/lite/core/subgraph.h", - "tensorflow/lite/external_cpu_backend_context.h", - "tensorflow/lite/portable_type_to_tflitetype.h", - "tensorflow/lite/profiling/root_profiler.h", - "tensorflow/lite/signature_runner.h", - "tensorflow/lite/core/signature_runner.h", - "tensorflow/lite/type_to_tflitetype.h", - "tensorflow/lite/string_type.h", - "tensorflow/lite/mutable_op_resolver.h", - "tensorflow/lite/interpreter.h", - "tensorflow/lite/core/interpreter.h", - "tensorflow/lite/model_builder.h", - "tensorflow/lite/core/model_builder.h", - "tensorflow/lite/interpreter_builder.h", - "tensorflow/lite/core/interpreter_builder.h", - "tensorflow/lite/model.h", - "tensorflow/lite/kernels/register.h", - "tensorflow/lite/core/kernels/register.h", - "tensorflow/lite/optional_debug_tools.h", -// "tensorflow/lite/core/async/c/types.h", -// "tensorflow/lite/core/async/interop/c/types.h", -// "tensorflow/lite/core/async/interop/c/attribute_map.h", -// "tensorflow/lite/core/async/async_signature_runner.h", -// "tensorflow/lite/core/async/c/async_signature_runner.h", - "tensorflow/lite/profiling/telemetry/c/profiler.h", - "tensorflow/lite/profiling/telemetry/c/telemetry_setting.h", - "tensorflow/lite/profiling/telemetry/telemetry_status.h", - "tensorflow/lite/profiling/telemetry/profiler.h", - - - - "tensorflow/lite/delegates/gpu/delegate.h", - "tensorflow/lite/delegates/gpu/delegate_options.h", - } + "tensorflow/lite/delegates/gpu/delegate.h", + "tensorflow/lite/delegates/gpu/delegate_options.h", + } // link = "tensorflowlite_c" - ) - }, + ) }, target = "org.bytedeco.tensorflowlite", global = "org.bytedeco.tensorflowlite.global.tensorflowlite") @@ -244,6 +179,17 @@ public void map(InfoMap infoMap) { // Classes passed to some native functions as unique_ptr and that can be allocated Java-side .put(new Info("tflite::impl::Interpreter::Interpreter").annotations("@UniquePtr", "@Name(\"std::make_unique\")")) .put(new Info("tflite::Subgraph::Subgraph").annotations("@UniquePtr", "@Name(\"std::make_unique\")")) + + // GPU support + // skip lines + .put(new Info("delegate_options.h").linePatterns("#ifdef TFLITE_DEBUG_DELEGATE", "#endif").skip()) + + // skip variables +// .put(new Info("FFI_SYSV", "FFI_THISCALL", "FFI_FASTCALL", "FFI_STDCALL", "FFI_PASCAL", "FFI_REGISTER", "FFI_MS_CDECL").skip()) + + .put(new Info("#ifdef TFLITE_DEBUG_DELEGATE").define(false)) + .put(new Info("#if defined(__ANDROID__)").define(false)) + ; } } From ff22226d3acfc6ef002dcfc86fd8da61ef6f8b7c Mon Sep 17 00:00:00 2001 From: barry Date: Sat, 17 Aug 2024 16:08:20 +0200 Subject: [PATCH 17/27] remove the exclusion of android --- .../org/bytedeco/tensorflowlite/presets/tensorflowlite.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tensorflow-lite/src/main/java/org/bytedeco/tensorflowlite/presets/tensorflowlite.java b/tensorflow-lite/src/main/java/org/bytedeco/tensorflowlite/presets/tensorflowlite.java index 5dfc03e66af..8b999e086e8 100644 --- a/tensorflow-lite/src/main/java/org/bytedeco/tensorflowlite/presets/tensorflowlite.java +++ b/tensorflow-lite/src/main/java/org/bytedeco/tensorflowlite/presets/tensorflowlite.java @@ -188,7 +188,8 @@ public void map(InfoMap infoMap) { // .put(new Info("FFI_SYSV", "FFI_THISCALL", "FFI_FASTCALL", "FFI_STDCALL", "FFI_PASCAL", "FFI_REGISTER", "FFI_MS_CDECL").skip()) .put(new Info("#ifdef TFLITE_DEBUG_DELEGATE").define(false)) - .put(new Info("#if defined(__ANDROID__)").define(false)) +// .put(new Info("#if defined(__ANDROID__)").define(false)) + ; } From 5e0d80e01eeea7533d2af07ee99b8482a382cc16 Mon Sep 17 00:00:00 2001 From: barry Date: Sat, 17 Aug 2024 17:06:01 +0200 Subject: [PATCH 18/27] define #if defined(__ANDROID__) --- .../org/bytedeco/tensorflowlite/presets/tensorflowlite.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tensorflow-lite/src/main/java/org/bytedeco/tensorflowlite/presets/tensorflowlite.java b/tensorflow-lite/src/main/java/org/bytedeco/tensorflowlite/presets/tensorflowlite.java index 8b999e086e8..967728f5c62 100644 --- a/tensorflow-lite/src/main/java/org/bytedeco/tensorflowlite/presets/tensorflowlite.java +++ b/tensorflow-lite/src/main/java/org/bytedeco/tensorflowlite/presets/tensorflowlite.java @@ -188,7 +188,7 @@ public void map(InfoMap infoMap) { // .put(new Info("FFI_SYSV", "FFI_THISCALL", "FFI_FASTCALL", "FFI_STDCALL", "FFI_PASCAL", "FFI_REGISTER", "FFI_MS_CDECL").skip()) .put(new Info("#ifdef TFLITE_DEBUG_DELEGATE").define(false)) -// .put(new Info("#if defined(__ANDROID__)").define(false)) + .put(new Info("#if defined(__ANDROID__)").define()) ; From 8bc91df8a2d96e3543b9a8e9d7083c506e7a3ecd Mon Sep 17 00:00:00 2001 From: barry Date: Sat, 17 Aug 2024 20:29:49 +0200 Subject: [PATCH 19/27] copy approach from tensorflow (full) --- .../tensorflowlite/presets/tensorflowlite.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/tensorflow-lite/src/main/java/org/bytedeco/tensorflowlite/presets/tensorflowlite.java b/tensorflow-lite/src/main/java/org/bytedeco/tensorflowlite/presets/tensorflowlite.java index 967728f5c62..2033889cead 100644 --- a/tensorflow-lite/src/main/java/org/bytedeco/tensorflowlite/presets/tensorflowlite.java +++ b/tensorflow-lite/src/main/java/org/bytedeco/tensorflowlite/presets/tensorflowlite.java @@ -30,9 +30,7 @@ import org.bytedeco.javacpp.annotation.NoException; import org.bytedeco.javacpp.annotation.Platform; import org.bytedeco.javacpp.annotation.Properties; -import org.bytedeco.javacpp.tools.Info; -import org.bytedeco.javacpp.tools.InfoMap; -import org.bytedeco.javacpp.tools.InfoMapper; +import org.bytedeco.javacpp.tools.*; /** * @author Samuel Audet @@ -108,11 +106,18 @@ target = "org.bytedeco.tensorflowlite", global = "org.bytedeco.tensorflowlite.global.tensorflowlite") -public class tensorflowlite implements InfoMapper { +public class tensorflowlite implements InfoMapper, BuildEnabled { static { Loader.checkVersion("org.bytedeco", "tensorflow-lite"); } + private boolean android; + + @Override + public void init(Logger logger, java.util.Properties properties, String encoding) { + this.android = properties.getProperty("platform").startsWith("android-"); + } + public void map(InfoMap infoMap) { infoMap.put(new Info("TFLITE_ATTRIBUTE_WEAK", "TFL_CAPI_EXPORT", "TFLITE_NOINLINE").cppTypes().annotations()) .put(new Info("FLATBUFFERS_LITTLEENDIAN == 0").define(false)) @@ -188,7 +193,7 @@ public void map(InfoMap infoMap) { // .put(new Info("FFI_SYSV", "FFI_THISCALL", "FFI_FASTCALL", "FFI_STDCALL", "FFI_PASCAL", "FFI_REGISTER", "FFI_MS_CDECL").skip()) .put(new Info("#ifdef TFLITE_DEBUG_DELEGATE").define(false)) - .put(new Info("#if defined(__ANDROID__)").define()) + .put(new Info("__ANDROID__").define(android)) ; From e12b7b3d21fc2d365f1e8dccebb12668975f6662 Mon Sep 17 00:00:00 2001 From: barry Date: Sat, 17 Aug 2024 23:38:22 +0200 Subject: [PATCH 20/27] don't define TfLiteGpuDelegateV2CreateAsync --- .../org/bytedeco/tensorflowlite/presets/tensorflowlite.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tensorflow-lite/src/main/java/org/bytedeco/tensorflowlite/presets/tensorflowlite.java b/tensorflow-lite/src/main/java/org/bytedeco/tensorflowlite/presets/tensorflowlite.java index 2033889cead..17539247208 100644 --- a/tensorflow-lite/src/main/java/org/bytedeco/tensorflowlite/presets/tensorflowlite.java +++ b/tensorflow-lite/src/main/java/org/bytedeco/tensorflowlite/presets/tensorflowlite.java @@ -188,12 +188,14 @@ public void map(InfoMap infoMap) { // GPU support // skip lines .put(new Info("delegate_options.h").linePatterns("#ifdef TFLITE_DEBUG_DELEGATE", "#endif").skip()) + .put(new Info("delegate.h").linePatterns("#if defined(__ANDROID__)", "#endif").skip()) // skip variables // .put(new Info("FFI_SYSV", "FFI_THISCALL", "FFI_FASTCALL", "FFI_STDCALL", "FFI_PASCAL", "FFI_REGISTER", "FFI_MS_CDECL").skip()) .put(new Info("#ifdef TFLITE_DEBUG_DELEGATE").define(false)) - .put(new Info("__ANDROID__").define(android)) +// .put(new Info("__ANDROID__").define(android)) + .put(new Info("defined(__ANDROID__)").define(true)) ; From af595d410878be6d393e0d80d5849e7e35176b9e Mon Sep 17 00:00:00 2001 From: barry Date: Sun, 18 Aug 2024 07:35:50 +0200 Subject: [PATCH 21/27] skip based on linePatterns --- .../org/bytedeco/tensorflowlite/presets/tensorflowlite.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tensorflow-lite/src/main/java/org/bytedeco/tensorflowlite/presets/tensorflowlite.java b/tensorflow-lite/src/main/java/org/bytedeco/tensorflowlite/presets/tensorflowlite.java index 17539247208..846ffedbc30 100644 --- a/tensorflow-lite/src/main/java/org/bytedeco/tensorflowlite/presets/tensorflowlite.java +++ b/tensorflow-lite/src/main/java/org/bytedeco/tensorflowlite/presets/tensorflowlite.java @@ -188,14 +188,14 @@ public void map(InfoMap infoMap) { // GPU support // skip lines .put(new Info("delegate_options.h").linePatterns("#ifdef TFLITE_DEBUG_DELEGATE", "#endif").skip()) - .put(new Info("delegate.h").linePatterns("#if defined(__ANDROID__)", "#endif").skip()) + .put(new Info("delegate.h").linePatterns("#if defined\\(__ANDROID__\\)", "#endif").skip()) // skip variables // .put(new Info("FFI_SYSV", "FFI_THISCALL", "FFI_FASTCALL", "FFI_STDCALL", "FFI_PASCAL", "FFI_REGISTER", "FFI_MS_CDECL").skip()) - .put(new Info("#ifdef TFLITE_DEBUG_DELEGATE").define(false)) +// .put(new Info("#ifdef TFLITE_DEBUG_DELEGATE").define(false)) // .put(new Info("__ANDROID__").define(android)) - .put(new Info("defined(__ANDROID__)").define(true)) +// .put(new Info("defined(__ANDROID__)").define(true)) ; From 4aaa421a2208eeffeb6862980a5cc1b09b2bcc43 Mon Sep 17 00:00:00 2001 From: barry Date: Sun, 18 Aug 2024 20:36:13 +0200 Subject: [PATCH 22/27] sync with main --- .../presets/tensorflowlite.java | 26 +++++++++++++++---- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/tensorflow-lite/src/main/java/org/bytedeco/tensorflowlite/presets/tensorflowlite.java b/tensorflow-lite/src/main/java/org/bytedeco/tensorflowlite/presets/tensorflowlite.java index 637b65893fc..fa746a9ed55 100644 --- a/tensorflow-lite/src/main/java/org/bytedeco/tensorflowlite/presets/tensorflowlite.java +++ b/tensorflow-lite/src/main/java/org/bytedeco/tensorflowlite/presets/tensorflowlite.java @@ -29,9 +29,7 @@ import org.bytedeco.javacpp.annotation.NoException; import org.bytedeco.javacpp.annotation.Platform; import org.bytedeco.javacpp.annotation.Properties; -import org.bytedeco.javacpp.tools.Info; -import org.bytedeco.javacpp.tools.InfoMap; -import org.bytedeco.javacpp.tools.InfoMapper; +import org.bytedeco.javacpp.tools.*; /** * @@ -99,15 +97,24 @@ "tensorflow/lite/profiling/telemetry/c/telemetry_setting.h", "tensorflow/lite/profiling/telemetry/telemetry_status.h", "tensorflow/lite/profiling/telemetry/profiler.h", + "tensorflow/lite/delegates/gpu/delegate.h", + "tensorflow/lite/delegates/gpu/delegate_options.h", } // link = "tensorflowlite_c" ), }, target = "org.bytedeco.tensorflowlite", global = "org.bytedeco.tensorflowlite.global.tensorflowlite") -public class tensorflowlite implements InfoMapper { +public class tensorflowlite implements InfoMapper, BuildEnabled { static { Loader.checkVersion("org.bytedeco", "tensorflow-lite"); } + private boolean android; + + @Override + public void init(Logger logger, java.util.Properties properties, String encoding) { + this.android = properties.getProperty("platform").startsWith("android-"); + } + public void map(InfoMap infoMap) { infoMap.put(new Info("TFLITE_ATTRIBUTE_WEAK", "TFL_CAPI_EXPORT", "TFLITE_NOINLINE").cppTypes().annotations()) .put(new Info("DOYXGEN_SKIP").define(true)) @@ -176,6 +183,15 @@ public void map(InfoMap infoMap) { // Classes passed to some native functions as unique_ptr and that can be allocated Java-side .put(new Info("tflite::impl::Interpreter::Interpreter").annotations("@UniquePtr", "@Name(\"std::make_unique\")")) .put(new Info("tflite::Subgraph::Subgraph").annotations("@UniquePtr", "@Name(\"std::make_unique\")")) - ; + + // GPU support + // skip lines + .put(new Info("delegate_options.h").linePatterns("#ifdef TFLITE_DEBUG_DELEGATE", "#endif").skip() + + ); + + if (!android) { + infoMap.put(new Info("delegate.h").linePatterns("#if defined\\(__ANDROID__\\)", "#endif").skip()); + } } } From a0c311df7344e877c2c9a71dad05b6f756814290 Mon Sep 17 00:00:00 2001 From: barry Date: Sun, 18 Aug 2024 20:38:14 +0200 Subject: [PATCH 23/27] sync with main --- .../org/bytedeco/tensorflowlite/presets/tensorflowlite.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/tensorflow-lite/src/main/java/org/bytedeco/tensorflowlite/presets/tensorflowlite.java b/tensorflow-lite/src/main/java/org/bytedeco/tensorflowlite/presets/tensorflowlite.java index fa746a9ed55..48e3520c35f 100644 --- a/tensorflow-lite/src/main/java/org/bytedeco/tensorflowlite/presets/tensorflowlite.java +++ b/tensorflow-lite/src/main/java/org/bytedeco/tensorflowlite/presets/tensorflowlite.java @@ -22,11 +22,7 @@ package org.bytedeco.tensorflowlite.presets; -import java.io.File; -import java.io.IOException; -import java.util.Arrays; import org.bytedeco.javacpp.Loader; -import org.bytedeco.javacpp.annotation.NoException; import org.bytedeco.javacpp.annotation.Platform; import org.bytedeco.javacpp.annotation.Properties; import org.bytedeco.javacpp.tools.*; From 7fef1bcf58609e41c6e9627d3c4cc251e08ee16d Mon Sep 17 00:00:00 2001 From: barry Date: Sun, 18 Aug 2024 22:06:41 +0200 Subject: [PATCH 24/27] gpu_invoke_loop_times --- .../bytedeco/tensorflowlite/presets/tensorflowlite.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tensorflow-lite/src/main/java/org/bytedeco/tensorflowlite/presets/tensorflowlite.java b/tensorflow-lite/src/main/java/org/bytedeco/tensorflowlite/presets/tensorflowlite.java index 48e3520c35f..edabb41543c 100644 --- a/tensorflow-lite/src/main/java/org/bytedeco/tensorflowlite/presets/tensorflowlite.java +++ b/tensorflow-lite/src/main/java/org/bytedeco/tensorflowlite/presets/tensorflowlite.java @@ -182,9 +182,14 @@ public void map(InfoMap infoMap) { // GPU support // skip lines - .put(new Info("delegate_options.h").linePatterns("#ifdef TFLITE_DEBUG_DELEGATE", "#endif").skip() + .put(new Info("delegate_options.h").linePatterns("#ifdef TFLITE_DEBUG_DELEGATE", "#endif").skip()) - ); + // Define the macro to include the guarded code +// .put(new Info("TFLITE_GPU_ENABLE_INVOKE_LOOP").define(true)) + + // Map the field to make sure it is included in the generated JNI code + .put(new Info("gpu_invoke_loop_times").javaText("public int gpu_invoke_loop_times;")) + ; if (!android) { infoMap.put(new Info("delegate.h").linePatterns("#if defined\\(__ANDROID__\\)", "#endif").skip()); From c3693912aa8b352e15b6007a0f4157122a5a7457 Mon Sep 17 00:00:00 2001 From: barry Date: Tue, 20 Aug 2024 09:37:16 +0200 Subject: [PATCH 25/27] cleanup --- .github/actions/deploy-ubuntu/action.yml | 10 +------ .github/workflows/tensorflow-lite.yml | 27 +++++++++---------- tensorflow-lite/cppbuild.sh | 1 - .../presets/tensorflowlite.java | 18 ++++--------- 4 files changed, 18 insertions(+), 38 deletions(-) diff --git a/.github/actions/deploy-ubuntu/action.yml b/.github/actions/deploy-ubuntu/action.yml index cbfc0b9e2c8..f7247aeabe8 100644 --- a/.github/actions/deploy-ubuntu/action.yml +++ b/.github/actions/deploy-ubuntu/action.yml @@ -333,16 +333,8 @@ runs: fi df -h - - name: Attach outputs - if: always() - uses: actions/upload-artifact@v4 - with: - # attach the installed artifacts - name: "${{ env.CI_DEPLOY_MODULE }}-${{ env.CI_DEPLOY_PLATFORM }}${{ matrix.ext }}" - path: /home/runner/.m2/repository/org/bytedeco/${{ env.CI_DEPLOY_MODULE }}/ - - name: Clean up shell: bash run: | cd $HOME - rm -Rf $(find .m2/repository/ -name '*SNAPSHOT*') + rm -Rf $(find .m2/repository/ -name '*SNAPSHOT*') \ No newline at end of file diff --git a/.github/workflows/tensorflow-lite.yml b/.github/workflows/tensorflow-lite.yml index b3225e5bd1a..ca980e833df 100644 --- a/.github/workflows/tensorflow-lite.yml +++ b/.github/workflows/tensorflow-lite.yml @@ -20,52 +20,49 @@ jobs: # android-arm: # runs-on: ubuntu-20.04 # steps: -# - uses: barrypitman/javacpp-presets/.github/actions/deploy-ubuntu@v1.5.10-GPU +# - uses: bytedeco/javacpp-presets/.github/actions/deploy-ubuntu@actions android-arm64: runs-on: ubuntu-20.04 steps: - - uses: barrypitman/javacpp-presets/.github/actions/deploy-ubuntu@v1.5.10-GPU + - uses: bytedeco/javacpp-presets/.github/actions/deploy-ubuntu@actions # android-x86: # runs-on: ubuntu-20.04 # steps: -# - uses: barrypitman/javacpp-presets/.github/actions/deploy-ubuntu@v1.5.10-GPU +# - uses: bytedeco/javacpp-presets/.github/actions/deploy-ubuntu@actions android-x86_64: runs-on: ubuntu-20.04 steps: - - uses: barrypitman/javacpp-presets/.github/actions/deploy-ubuntu@v1.5.10-GPU + - uses: bytedeco/javacpp-presets/.github/actions/deploy-ubuntu@actions # linux-armhf: # runs-on: ubuntu-20.04 # steps: -# - uses: barrypitman/javacpp-presets/.github/actions/deploy-ubuntu@v1.5.10-GPU +# - uses: bytedeco/javacpp-presets/.github/actions/deploy-ubuntu@actions linux-arm64: runs-on: ubuntu-20.04 steps: - - uses: barrypitman/javacpp-presets/.github/actions/deploy-ubuntu@v1.5.10-GPU + - uses: bytedeco/javacpp-presets/.github/actions/deploy-ubuntu@actions # linux-x86: # runs-on: ubuntu-20.04 # steps: -# - uses: barrypitman/javacpp-presets/.github/actions/deploy-ubuntu@v1.5.10-GPU +# - uses: bytedeco/javacpp-presets/.github/actions/deploy-ubuntu@actions linux-x86_64: runs-on: ubuntu-20.04 strategy: matrix: - ext: - - '-gpu' - - '' + ext: ["", -gpu] steps: - - uses: barrypitman/javacpp-presets/.github/actions/deploy-ubuntu@v1.5.10-GPU + - uses: bytedeco/javacpp-presets/.github/actions/deploy-ubuntu@actions macosx-x86_64: runs-on: macos-12 steps: - - uses: barrypitman/javacpp-presets/.github/actions/deploy-macosx@v1.5.10-GPU + - uses: bytedeco/javacpp-presets/.github/actions/deploy-macosx@actions windows-x86_64: runs-on: windows-2019 steps: - - uses: barrypitman/javacpp-presets/.github/actions/deploy-windows@v1.5.10-GPU + - uses: bytedeco/javacpp-presets/.github/actions/deploy-windows@actions redeploy: # needs: [android-arm, android-arm64, android-x86, android-x86_64, linux-armhf, linux-arm64, linux-x86, linux-x86_64, macosx-x86_64, windows-x86_64] needs: [android-arm64, android-x86_64, linux-arm64, linux-x86_64, macosx-x86_64, windows-x86_64] runs-on: ubuntu-20.04 steps: - - uses: barrypitman/javacpp-presets/.github/actions/redeploy@v1.5.10-GPU - + - uses: bytedeco/javacpp-presets/.github/actions/redeploy@actions \ No newline at end of file diff --git a/tensorflow-lite/cppbuild.sh b/tensorflow-lite/cppbuild.sh index 066e202713a..bfa42559ca8 100755 --- a/tensorflow-lite/cppbuild.sh +++ b/tensorflow-lite/cppbuild.sh @@ -105,4 +105,3 @@ if which cygpath; then fi cd ../.. - diff --git a/tensorflow-lite/src/main/java/org/bytedeco/tensorflowlite/presets/tensorflowlite.java b/tensorflow-lite/src/main/java/org/bytedeco/tensorflowlite/presets/tensorflowlite.java index edabb41543c..2c6f440fa0a 100644 --- a/tensorflow-lite/src/main/java/org/bytedeco/tensorflowlite/presets/tensorflowlite.java +++ b/tensorflow-lite/src/main/java/org/bytedeco/tensorflowlite/presets/tensorflowlite.java @@ -179,20 +179,12 @@ public void map(InfoMap infoMap) { // Classes passed to some native functions as unique_ptr and that can be allocated Java-side .put(new Info("tflite::impl::Interpreter::Interpreter").annotations("@UniquePtr", "@Name(\"std::make_unique\")")) .put(new Info("tflite::Subgraph::Subgraph").annotations("@UniquePtr", "@Name(\"std::make_unique\")")) - - // GPU support - // skip lines - .put(new Info("delegate_options.h").linePatterns("#ifdef TFLITE_DEBUG_DELEGATE", "#endif").skip()) - - // Define the macro to include the guarded code -// .put(new Info("TFLITE_GPU_ENABLE_INVOKE_LOOP").define(true)) - - // Map the field to make sure it is included in the generated JNI code - .put(new Info("gpu_invoke_loop_times").javaText("public int gpu_invoke_loop_times;")) + .put(new Info("delegate_options.h").linePatterns("#ifdef TFLITE_DEBUG_DELEGATE", "#endif").skip()) + .put(new Info("gpu_invoke_loop_times").javaText("public int gpu_invoke_loop_times;")) ; - if (!android) { - infoMap.put(new Info("delegate.h").linePatterns("#if defined\\(__ANDROID__\\)", "#endif").skip()); - } + if (!android) { + infoMap.put(new Info("delegate.h").linePatterns("#if defined\\(__ANDROID__\\)", "#endif").skip()); + } } } From 13c95d5ec919a76157c2872b1974f82e12df30c4 Mon Sep 17 00:00:00 2001 From: barry Date: Tue, 20 Aug 2024 10:27:47 +0200 Subject: [PATCH 26/27] define TfLiteGpuDelegateV2CreateAsync function for android --- .github/actions/deploy-ubuntu/action.yml | 2 +- .../org/bytedeco/tensorflowlite/presets/tensorflowlite.java | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/actions/deploy-ubuntu/action.yml b/.github/actions/deploy-ubuntu/action.yml index f7247aeabe8..d094d11d5a9 100644 --- a/.github/actions/deploy-ubuntu/action.yml +++ b/.github/actions/deploy-ubuntu/action.yml @@ -337,4 +337,4 @@ runs: shell: bash run: | cd $HOME - rm -Rf $(find .m2/repository/ -name '*SNAPSHOT*') \ No newline at end of file + rm -Rf $(find .m2/repository/ -name '*SNAPSHOT*') diff --git a/tensorflow-lite/src/main/java/org/bytedeco/tensorflowlite/presets/tensorflowlite.java b/tensorflow-lite/src/main/java/org/bytedeco/tensorflowlite/presets/tensorflowlite.java index 2c6f440fa0a..4bb5224c480 100644 --- a/tensorflow-lite/src/main/java/org/bytedeco/tensorflowlite/presets/tensorflowlite.java +++ b/tensorflow-lite/src/main/java/org/bytedeco/tensorflowlite/presets/tensorflowlite.java @@ -185,6 +185,12 @@ public void map(InfoMap infoMap) { if (!android) { infoMap.put(new Info("delegate.h").linePatterns("#if defined\\(__ANDROID__\\)", "#endif").skip()); + } else { + infoMap.put(new Info("TfLiteGpuDelegateV2CreateAsync").cppTypes("TfLiteDelegate*").javaText( + "#if defined(__ANDROID__)\n" + + "public static native @ByVal Pointer TfLiteGpuDelegateV2CreateAsync(@Const @ByRef TfLiteGpuDelegateOptionsV2 options);\n" + + "#endif" + )); } } } From 589082312d491eeaef65b5a71dc70f99e737362b Mon Sep 17 00:00:00 2001 From: barry Date: Tue, 20 Aug 2024 11:10:21 +0200 Subject: [PATCH 27/27] define TfLiteGpuDelegateV2CreateAsync function for android --- .../org/bytedeco/tensorflowlite/presets/tensorflowlite.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tensorflow-lite/src/main/java/org/bytedeco/tensorflowlite/presets/tensorflowlite.java b/tensorflow-lite/src/main/java/org/bytedeco/tensorflowlite/presets/tensorflowlite.java index 4bb5224c480..2516d185bd3 100644 --- a/tensorflow-lite/src/main/java/org/bytedeco/tensorflowlite/presets/tensorflowlite.java +++ b/tensorflow-lite/src/main/java/org/bytedeco/tensorflowlite/presets/tensorflowlite.java @@ -187,9 +187,7 @@ public void map(InfoMap infoMap) { infoMap.put(new Info("delegate.h").linePatterns("#if defined\\(__ANDROID__\\)", "#endif").skip()); } else { infoMap.put(new Info("TfLiteGpuDelegateV2CreateAsync").cppTypes("TfLiteDelegate*").javaText( - "#if defined(__ANDROID__)\n" + - "public static native @ByVal Pointer TfLiteGpuDelegateV2CreateAsync(@Const @ByRef TfLiteGpuDelegateOptionsV2 options);\n" + - "#endif" + "public static native @ByVal Pointer TfLiteGpuDelegateV2CreateAsync(@Const @ByRef TfLiteGpuDelegateOptionsV2 options);" )); } }