ملاحظة: عند الاتصال بالرقمَين Interpreter.Options.addDelegate() وInterpreter.run()،
يجب أن يحصل المتصل على EGLContext في سلسلة المحادثات الحالية، ويجب أن يتم الاتصال من خلال رقم EGLContext نفسه.Interpreter.run() وفي حال عدم توفّر EGLContext، سينشئ المفوَّض نطاقًا داخليًا، ولكن يجب على مطوّر البرامج التأكّد من أنّه يتم دائمًا طلب Interpreter.run() من سلسلة المحادثات نفسها التي تم استدعاء Interpreter.Options.addDelegate() فيها.
لعرض اسم معرِّف أصلي إلى تنفيذ تفويض TensorFlow Lite.
ملاحظة: تحتفظ Java Delegate بملكية مثيل المفوَّض الأصلي،
ويجب أن تضمن توفُّرها طوال مدة الاستخدام مع أي مثيل InterpreterApi.
ملاحظة: قد لا يتم إنشاء مثيل المستخدم المفوَّض إلى أن يتم إرفاق المستخدم المفوَّض بمترجم فوري، وبالتالي لا يجب استدعاء هذه الطريقة إلا بعد إنشاء مترجم فوري مع هذا المفوَّض.
المرتجعات
الاسم المعرِّف للمفوَّض الأصلي. في C/C++ ، من المفترض أن يشير هذا الحقل إلى "TfLiteOpaqueDelegate".
تاريخ التعديل الأخير: 2025-07-24 (حسب التوقيت العالمي المتفَّق عليه)
[[["يسهُل فهم المحتوى.","easyToUnderstand","thumb-up"],["ساعَدني المحتوى في حلّ مشكلتي.","solvedMyProblem","thumb-up"],["غير ذلك","otherUp","thumb-up"]],[["لا يحتوي على المعلومات التي أحتاج إليها.","missingTheInformationINeed","thumb-down"],["الخطوات معقدة للغاية / كثيرة جدًا.","tooComplicatedTooManySteps","thumb-down"],["المحتوى قديم.","outOfDate","thumb-down"],["ثمة مشكلة في الترجمة.","translationIssue","thumb-down"],["مشكلة في العيّنات / التعليمات البرمجية","samplesCodeIssue","thumb-down"],["غير ذلك","otherDown","thumb-down"]],["تاريخ التعديل الأخير: 2025-07-24 (حسب التوقيت العالمي المتفَّق عليه)"],[],[],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'."]]