Delegate for GPU inference.

Note: When calling Interpreter.Options.addDelegate() and Interpreter.run(), the caller must have an EGLContext in the current thread and Interpreter.run() must be called from the same EGLContext. If an EGLContext does not exist, the delegate will internally create one, but then the developer must ensure that Interpreter.run() is always called from the same thread in which Interpreter.Options.addDelegate() was called.

Nested Classes

Public Constructors

Public Methods

void

close()

Frees TFLite resources in C runtime.

long

getNativeHandle()

Returns a native handle to the TensorFlow Lite delegate implementation.

Inherited Methods

From class java.lang.Object

boolean

equals(Object arg0)

final Class<?>

getClass()

int

hashCode()

final void

notify()

final void

notifyAll()

String

toString()

final void

wait(long arg0, int arg1)

final void

wait(long arg0)

final void

wait()

From interface java.io.Closeable

From interface java.lang.AutoCloseable

Public Constructors

public GpuDelegate ()

Public Methods

public void close ()

Frees TFLite resources in C runtime.

User is expected to call this method explicitly.

public long getNativeHandle ()

Returns a native handle to the TensorFlow Lite delegate implementation.

Note: The Java Delegate maintains ownership of the native delegate instance, and must ensure its existence for the duration of usage with any InterpreterApi instance.

Note: the native delegate instance may not be created until the delegate has been attached to an interpreter, so this method should not be called until after an interpreter has been constructed with this delegate.

Returns
  • The native delegate handle. In C/C++, this should be a pointer to 'TfLiteOpaqueDelegate'.

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2024-05-10 UTC.