إذا كانت عملية تنفيذ التفويض يحتوي على موارد أو ذاكرة إضافية يجب إخلاءها
صراحةً، تكون أفضل الممارسات هي إضافة طريقة close() إلى التنفيذ وطلب استدعاء العميل الذي
يظهر بشكل صريح عندما لا يعود مثيل التفويض قيد الاستخدام. يسمح هذا النهج من الناحية الفنية بمشاركة مثيل مفوَّض واحد على مستوى عدة مثيلات للترجمة الفورية، إلا أنّ تنفيذ التفويض يجب أن يتيح ذلك بشكل صريح.
لعرض اسم معرِّف أصلي إلى تنفيذ تفويض TensorFlow Lite.
الطرق المكتسَبة
من الواجهة
java.io.Closeable
تجريدي
باطل
CLOSE()
من الواجهة
java.lang.AutoCloseable
تجريدي
باطل
CLOSE()
الطرق العامة
عامة
باطل
إغلاق()
يتم إغلاق المفوَّض وإطلاق أي موارد مرتبطة به.
وعلى عكس الطريقة المذكورة في واجهة Closeable الأساسية، لا تعرض هذه الطريقة الاستثناءات المحددة.
public
تجريدي
طويل
getNativeHandle()
لعرض اسم معرِّف أصلي إلى تنفيذ تفويض 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,["# Delegate\n\npublic interface **Delegate** \n\n|---|---|---|\n| Known Indirect Subclasses [GpuDelegate](/edge/api/tflite/java/org/tensorflow/lite/gpu/GpuDelegate) |--------------------------------------------------------------------------|-----------------------------------------------------------------------------------| | [GpuDelegate](/edge/api/tflite/java/org/tensorflow/lite/gpu/GpuDelegate) | [Delegate](/edge/api/tflite/java/org/tensorflow/lite/Delegate) for GPU inference. | |||\n\nWrapper for a native TensorFlow Lite Delegate.\n\nIf a delegate implementation holds additional resources or memory that should be explicitly\nfreed, then best practice is to add a `close()` method to the implementation and have the\nclient call that explicitly when the delegate instance is no longer in use. While this approach\ntechnically allows sharing of a single delegate instance across multiple interpreter instances,\nthe delegate implementation must explicitly support this.\n\n\u003cbr /\u003e\n\n### Public Methods\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\n### Inherited Methods\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 Methods\n--------------\n\n#### public void\n**close**\n()\n\nCloses the delegate and releases any resources associated with it.\n\nIn contrast to the method declared in the base [Closeable](https://developer.android.com/reference/java/io/Closeable.html) interface, this method\ndoes not throw checked exceptions.\n\n\u003cbr /\u003e\n\n#### public abstract 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'. \n\n##### Throws\n\n| [IllegalStateException](https://developer.android.com/reference/java/lang/IllegalStateException.html) | if called before the native delegate instance has been constructed. |\n|-------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------|"]]