Nota: Cuando se llama a Interpreter.Options.addDelegate() y Interpreter.run(), el llamador debe tener un EGLContext en el subproceso actual, y se debe llamar a Interpreter.run() desde el mismo EGLContext. Si un EGLContext no existe, el delegado creará uno internamente, pero el desarrollador debe asegurarse de que siempre se llame a Interpreter.run() desde el mismo subproceso en el que se llamó a Interpreter.Options.addDelegate().
Libera los recursos de TFLite en el entorno de ejecución C.
Se espera que el usuario llame a este método de forma explícita.
public
long
getNativeHandle()
Muestra un controlador nativo para la implementación delegada de TensorFlow Lite.
Nota: El Delegate de Java conserva la propiedad de la instancia delegada nativa y debe garantizar su existencia durante el uso con cualquier instancia InterpreterApi.
Nota: Es posible que la instancia de delegado nativo no se cree hasta que el delegado se haya adjuntado a un intérprete, por lo que no se debe llamar a este método hasta que se haya construido un intérprete con este delegado.
Devuelve
Controlador del delegado nativo. En C/C++, debería ser un puntero a "TfLiteOpaqueDelegate".
[[["Fácil de comprender","easyToUnderstand","thumb-up"],["Resolvió mi problema","solvedMyProblem","thumb-up"],["Otro","otherUp","thumb-up"]],[["Falta la información que necesito","missingTheInformationINeed","thumb-down"],["Muy complicado o demasiados pasos","tooComplicatedTooManySteps","thumb-down"],["Desactualizado","outOfDate","thumb-down"],["Problema de traducción","translationIssue","thumb-down"],["Problema con las muestras o los códigos","samplesCodeIssue","thumb-down"],["Otro","otherDown","thumb-down"]],["Última actualización: 2025-07-24 (UTC)"],[],[],null,["# GpuDelegate\n\npublic class **GpuDelegate** \n[Delegate](/edge/api/tflite/java/org/tensorflow/lite/Delegate) for GPU inference.\n\nNote: When calling `Interpreter.Options.addDelegate()` and `Interpreter.run()`,\nthe caller must have an `EGLContext` in the **current thread** and `Interpreter.run()` must be called from the same `EGLContext`. If an `EGLContext` does\nnot exist, the delegate will internally create one, but then the developer must ensure that\n`Interpreter.run()` is always called from the same thread in which `Interpreter.Options.addDelegate()` was called.\n\n\u003cbr /\u003e\n\n### Nested Classes\n\n|-------|---|---|-------------------------------------------------------------------------------------------------------------------------------------------------|\n| class | [GpuDelegate.Options](/edge/api/tflite/java/org/tensorflow/lite/gpu/GpuDelegate.Options) || *This class is deprecated. Use [GpuDelegateFactory.Options](/edge/api/tflite/java/org/tensorflow/lite/gpu/GpuDelegateFactory.Options) instead.* |\n\n### Public Constructors\n\n|---|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| | [GpuDelegate](/edge/api/tflite/java/org/tensorflow/lite/gpu/GpuDelegate#GpuDelegate(org.tensorflow.lite.gpu.GpuDelegateFactory.Options))([GpuDelegateFactory.Options](/edge/api/tflite/java/org/tensorflow/lite/gpu/GpuDelegateFactory.Options) options) |\n| | [GpuDelegate](/edge/api/tflite/java/org/tensorflow/lite/gpu/GpuDelegate#GpuDelegate())() |\n\n### Public Methods\n\n|------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| void | [close](/edge/api/tflite/java/org/tensorflow/lite/gpu/GpuDelegate#close())() Frees TFLite resources in C runtime. |\n| long | [getNativeHandle](/edge/api/tflite/java/org/tensorflow/lite/gpu/GpuDelegate#getNativeHandle())() Returns a native handle to the TensorFlow Lite delegate implementation. |\n\n### Inherited Methods\n\nFrom class java.lang.Object \n\n|----------------------------------------------------------------------------------|--------------------------------------------------------------------------------------|\n| boolean | equals([Object](https://developer.android.com/reference/java/lang/Object.html) arg0) |\n| final [Class](https://developer.android.com/reference/java/lang/Class.html)\\\u003c?\\\u003e | getClass() |\n| int | hashCode() |\n| final void | notify() |\n| final void | notifyAll() |\n| [String](https://developer.android.com/reference/java/lang/String.html) | toString() |\n| final void | wait(long arg0, int arg1) |\n| final void | wait(long arg0) |\n| final void | wait() |\n\nFrom interface [org.tensorflow.lite.Delegate](/edge/api/tflite/java/org/tensorflow/lite/Delegate) \n\n|---------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| void | [close](/edge/api/tflite/java/org/tensorflow/lite/Delegate#close())() Closes the delegate and releases any resources associated with it. |\n| abstract long | [getNativeHandle](/edge/api/tflite/java/org/tensorflow/lite/Delegate#getNativeHandle())() Returns a native handle to the TensorFlow Lite delegate implementation. |\n\nFrom interface java.io.Closeable \n\n|---------------|---------|\n| abstract void | close() |\n\nFrom interface java.lang.AutoCloseable \n\n|---------------|---------|\n| abstract void | close() |\n\nPublic Constructors\n-------------------\n\n#### public\n**GpuDelegate**\n([GpuDelegateFactory.Options](/edge/api/tflite/java/org/tensorflow/lite/gpu/GpuDelegateFactory.Options) options)\n\n\u003cbr /\u003e\n\n##### Parameters\n\n| options | |\n|---------|---|\n\n#### public\n**GpuDelegate**\n()\n\n\u003cbr /\u003e\n\nPublic Methods\n--------------\n\n#### public void\n**close**\n()\n\nFrees TFLite resources in C runtime.\n\nUser is expected to call this method explicitly.\n\n\u003cbr /\u003e\n\n#### public long\n**getNativeHandle**\n()\n\nReturns a native handle to the TensorFlow Lite delegate implementation.\n\nNote: The Java [Delegate](/edge/api/tflite/java/org/tensorflow/lite/Delegate) maintains ownership of the native delegate instance, and\nmust ensure its existence for the duration of usage with any [InterpreterApi](/edge/api/tflite/java/org/tensorflow/lite/InterpreterApi) instance.\n\nNote: the native delegate instance may not be created until the delegate has been attached\nto an interpreter, so this method should not be called until after an interpreter has been\nconstructed with this delegate.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n##### Returns\n\n- The native delegate handle. In C/C++, this should be a pointer to 'TfLiteOpaqueDelegate'."]]