You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
var compatList = new CompatibilityList();
if (compatList.IsDelegateSupportedOnThisDevice)
{
var bestOptions = compatList.BestOptionsForThisDevice; //<- no BestOptionsForThisDevice
var gpuDelegate = new GpuDelegate(bestOptions); //<- constructor not accepting parameters
options.AddDelegate(gpuDelegate);
}
The c# code above started working for me after i implemented the solution described below.
The cause of this is that is either:
a - tensorflow-lite-gpu-api was not included at all
b - both gpu-related aar's where processed is same project: both tensorflow-lite-gpu-api-2.13.0.aar and tensorflow-lite-gpu-2.13.0.aar define classes absolutely for same package tensorflow/lite/gpu, that creates a conflict for bindings generator and it just skips one of them (tensorflow-lite-gpu-api in our case).
This makes GpuDelegateFactory.Options not to be available and bindings are not generated for CompatibilityList.BestOptionsForThisDevice and the second constructor GpuDelegate(GpuDelegate.Options options)
The solution
To bind tensorflow-lite-gpu-api-2.13.0.aar and tensorflow-lite-gpu-2.13.0.aar in different projects, the latter would reference the first one with "-api"
This issue has been ongoing since 2.5.0 (xamarin/XamarinComponents#1319) and seems to affect every version I have tried since up to and including the very latest currently available (2.14.0). I have some older Xamarin projects that use monoandroid so I can't use the modified NuGet from @taublast sadly (but it could be useful after migrating to MAUI if this issue is still not fixed).
@taublast Could you perhaps open a PR to this repo with a fix?
The GPU bindings are also not the only missing bindings in the current Xamarin.Tensorflow.Lite packages as there is a similar issue with the processor builders (#754)
@wollac11 unfortunately won't be able to work on a PR here, but could help you with older droid if you provide more details on what sdk level you need bindings to support.
The issue
Inside
Xamarin.TensorFlow.Lite.Gpu" Version="2.12.0.1"
we are missingCompatibilityList.BestOptionsForThisDevice
andconstructor
GpuDelegate(GpuDelegate.Options options)
to be able to to implement gpu acceleration as described here:
https://www.tensorflow.org/lite/android/delegates/gpu?hl=en#enable_gpu_acceleration_2
and in .net maui like that:
The c# code above started working for me after i implemented the solution described below.
The cause of this is that is either:
a -
tensorflow-lite-gpu-api
was not included at allb - both gpu-related aar's where processed is same project: both
tensorflow-lite-gpu-api-2.13.0.aar
andtensorflow-lite-gpu-2.13.0.aar
define classes absolutely for same packagetensorflow/lite/gpu
, that creates a conflict for bindings generator and it just skips one of them (tensorflow-lite-gpu-api
in our case).This makes
GpuDelegateFactory.Options
not to be available and bindings are not generated forCompatibilityList.BestOptionsForThisDevice
and the second constructorGpuDelegate(GpuDelegate.Options options)
The solution
To bind
tensorflow-lite-gpu-api-2.13.0.aar
andtensorflow-lite-gpu-2.13.0.aar
in different projects, the latter would reference the first one with "-api"https://github.com/taublast/AppoMobi.Maui.TensorFlow.Lite
Context
This was all about a .net maui 7.0 for android, trying to use
<PackageReference Include="Xamarin.TensorFlow.Lite.Gpu" Version="2.12.0.1" />
The text was updated successfully, but these errors were encountered: