Skip to content
This repository has been archived by the owner on Nov 6, 2024. It is now read-only.

Manual updates 20240725 fix for issue 754 #896

Merged
merged 7 commits into from
Jul 29, 2024

Conversation

moljac
Copy link
Member

@moljac moljac commented Jul 27, 2024

Does this change any of the generated binding API's?

Yes. Methods surfaced and renamed

Describe your contribution

Fixes for issue #754

Error:

./generated/org.tensorflow.tensorflow-lite-support-api/obj/Debug/net8.0-android/generated/src/Xamarin.TensorFlow.Lite.Support.Common.TensorProcessor.cs(163,20): error CS0102: The type 'TensorProcessor.Builder' already contains a definition for 'cb_build' [./generated/org.tensorflow.tensorflow-lite-support-api/org.tensorflow.tensorflow-lite-support-api.csproj::TargetFramework=net8.0-android]
./generated/org.tensorflow.tensorflow-lite-support-api/obj/Debug/net8.0-android/generated/src/Xamarin.TensorFlow.Lite.Support.Image.ImageProcessor.cs(196,20): error CS0102: The type 'ImageProcessor.Builder' already contains a definition for 'cb_build' [./generated/org.tensorflow.tensorflow-lite-support-api/org.tensorflow.tensorflow-lite-support-api.csproj::TargetFramework=net8.0-android]

Error is caused by multiple (2) versions of one method (Build()) that returns different covariant types. Renaming the method does not work, because variable names for Delegates and other are generated based on java method names, not managed, so the managed method name gets changed, but variables cause conflicts.

So, as workaround,

  1. generated code was copied copied
  2. method was removed,
  3. generated code was added to additions
  4. variable names were changed (managedName suffix)

Maybe variable name generation based on managedName could prevent this in the future.

Check: issue java.interop

@moljac moljac requested a review from jpobst July 29, 2024 08:39
path="/api/package[@name='org.tensorflow.lite.support.common']/class[@name='TensorProcessor.Builder']/method[@name='build' and count(parameter)=0 and @return='org.tensorflow.lite.support.common.TensorProcessor']"
name="managedName"
>
BuildTensorProcessor
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why doesn't setting managedName work? What error are you trying to work around by manually defining BuildTensorProcessor()?

@moljac
Copy link
Member Author

moljac commented Jul 29, 2024

api.xml snippet

    <class abstract="false" deprecated="not deprecated" extends="org.tensorflow.lite.support.common.SequentialProcessor.Builder" extends-generic-aware="org.tensorflow.lite.support.common.SequentialProcessor.Builder&lt;org.tensorflow.lite.support.image.TensorImage&gt;" jni-extends="Lorg/tensorflow/lite/support/common/SequentialProcessor$Builder;" final="false" name="ImageProcessor.Builder" static="true" visibility="public" jni-signature="Lorg/tensorflow/lite/support/image/ImageProcessor$Builder;">
      <constructor deprecated="not deprecated" final="false" name="ImageProcessor.Builder" jni-signature="()V" bridge="false" static="false" type="org.tensorflow.lite.support.image.ImageProcessor.Builder" synthetic="false" visibility="public" />
      <method abstract="false" deprecated="not deprecated" final="false" name="add" jni-signature="(Lorg/tensorflow/lite/support/common/Operator;)Lorg/tensorflow/lite/support/common/SequentialProcessor$Builder;" bridge="true" native="false" return="java.lang.Object" jni-return="Lorg/tensorflow/lite/support/common/SequentialProcessor$Builder;" static="false" synchronized="false" synthetic="true" visibility="public">
        <parameter name="op" type="org.tensorflow.lite.support.common.Operator" jni-type="Lorg/tensorflow/lite/support/common/Operator;" />
      </method>
      <method abstract="false" deprecated="not deprecated" final="false" name="add" jni-signature="(Lorg/tensorflow/lite/support/common/TensorOperator;)Lorg/tensorflow/lite/support/image/ImageProcessor$Builder;" bridge="false" native="false" return="org.tensorflow.lite.support.image.ImageProcessor.Builder" jni-return="Lorg/tensorflow/lite/support/image/ImageProcessor$Builder;" static="false" synchronized="false" synthetic="false" visibility="public">
        <parameter name="op" type="org.tensorflow.lite.support.common.TensorOperator" jni-type="Lorg/tensorflow/lite/support/common/TensorOperator;" />
      </method>
      <method abstract="false" deprecated="not deprecated" final="false" name="add" jni-signature="(Lorg/tensorflow/lite/support/image/ImageOperator;)Lorg/tensorflow/lite/support/image/ImageProcessor$Builder;" bridge="false" native="false" return="org.tensorflow.lite.support.image.ImageProcessor.Builder" jni-return="Lorg/tensorflow/lite/support/image/ImageProcessor$Builder;" static="false" synchronized="false" synthetic="false" visibility="public">
        <parameter name="op" type="org.tensorflow.lite.support.image.ImageOperator" jni-type="Lorg/tensorflow/lite/support/image/ImageOperator;" />
      </method>
      <method abstract="false" deprecated="not deprecated" final="false" name="build" jni-signature="()Lorg/tensorflow/lite/support/image/ImageProcessor;" bridge="false" native="false" return="org.tensorflow.lite.support.image.ImageProcessor" jni-return="Lorg/tensorflow/lite/support/image/ImageProcessor;" static="false" synchronized="false" synthetic="false" visibility="public" />
      <method abstract="false" deprecated="not deprecated" final="false" name="build" jni-signature="()Lorg/tensorflow/lite/support/common/SequentialProcessor;" bridge="true" native="false" return="org.tensorflow.lite.support.common.SequentialProcessor" jni-return="Lorg/tensorflow/lite/support/common/SequentialProcessor;" static="false" synchronized="false" synthetic="true" visibility="public" />
    </class>

@moljac moljac merged commit 3b0d874 into main Jul 29, 2024
2 of 5 checks passed
@moljac moljac deleted the mu-20240725-fix-issue-754-tensorflow-missing-build branch July 29, 2024 18:10
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ImageProcessor.Builder.Build() method is missing from TensorFlow.Lite.Support library
3 participants