asus4 / tf-lite-unity-sample

TensorFlow Lite Samples on Unity

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

how to use Metal Delegate Accelerator for ios device

duc99hust opened this issue · comments

how to use Metal Delegate Accelerator for ios device

Sorry I haven't documented it.

It's probably easier to understand if you look at the BaseImagePredictor.cs and the inherited classes such as SSD.cs or PoseNet.cs

If you want to use a low-level method, you can use InterpreterOptions.AddDelegate() when creating the Interpreter.

Here's a pseudo-code of how to use a MetalDelegate.

// Create a Metal delegate
var options = new InterpreterOptions();
options.AddDelegate(new MetalDelegate(new MetalDelegate.Options()
{
    allowPrecisionLoss = false,
    waitType = MetalDelegate.WaitType.Passive,
    enableQuantization = true,
}));

// Create interpreter with the Metal delegate
var interpreter = new Interpreter(modelBytes, options);

// Do something with the interpreter
interpreter.SetInputTensorData(0, inputBytes);
interpreter.Invoke();
interpreter.GetOutputTensorData(0, outputBytes);

// Clean up
interpreter?.Dispose();
commented

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.