enum cuối cùng tĩnh công khai InterpreterApi.Options.TfLiteRuntime
Enum biểu thị nơi triển khai môi trường thời gian chạy TensorFlow Lite.
Sự khác biệt giữa lớp này và lớp RuntimeFlavor: Lớp này chỉ định một lựa chọn ưu tiên về thời gian chạy sẽ sử dụng, trong khi RuntimeFlavor chỉ định thời gian chạy chính xác nào đang đang được sử dụng.
công khai
tĩnh
cuối cùng
Phiên dịchApi.Options.TfLiteRuntime
FROM_APPLICATION_ONLY
Sử dụng triển khai thời gian chạy TF Lite được liên kết với ứng dụng. Nếu không có phương thức triển khai thời gian chạy TF Lite phù hợp nào được liên kết với ứng dụng, thì việc cố gắng tạo một thực thể Phiên dịchApi bằng chế độ cài đặt TfLiteRuntime này sẽ gửi ra ngoại lệ IllegalStateException (ngay cả khi hệ điều hành hoặc dịch vụ hệ thống có thể cung cấp phương thức triển khai thời gian chạy TF Lite).
Đây là cài đặt mặc định. Chế độ cài đặt này cũng phù hợp với các ứng dụng phải chạy trên các hệ thống không cung cấp phương thức triển khai thời gian chạy TF Lite.
công khai
tĩnh
cuối cùng
Phiên dịchApi.Options.TfLiteRuntime
FROM_SYSTEM_ONLY
Sử dụng phương thức triển khai thời gian chạy TF Lite do hệ điều hành hoặc dịch vụ hệ thống cung cấp. Dữ liệu này sẽ được lấy từ một thư viện hệ thống / đối tượng dùng chung / dịch vụ, chẳng hạn như Dịch vụ Google Play. Phiên bản này có thể mới hơn phiên bản được liên kết với ứng dụng (nếu có). Nếu hệ thống không cung cấp phương thức triển khai thời gian chạy TF Lite phù hợp, thì việc cố gắng tạo một thực thể VarianterApi bằng chế độ cài đặt TfLiteRuntime này sẽ gửi ra một ngoại lệ IllegalStateException (ngay cả khi có phương thức triển khai thời gian chạy TF Lite được liên kết với ứng dụng).
Chế độ cài đặt này phù hợp với mã sẽ sử dụng môi trường thời gian chạy TF Lite do hệ thống cung cấp. Tính năng này có thể giảm kích thước tệp nhị phân của ứng dụng và có thể được cập nhật thường xuyên hơn.
công khai
tĩnh
cuối cùng
Phiên dịchApi.Options.TfLiteRuntime
PREFER_SYSTEM_OVER_APPLICATION
Sử dụng phương thức triển khai thời gian chạy TF Lite do hệ thống cung cấp, nếu có, nếu không, hãy sử dụng phương thức triển khai thời gian chạy TF Lite được liên kết với ứng dụng (nếu có). Nếu không tìm thấy thời gian chạy TF Lite phù hợp ở bất kỳ vị trí nào, thì việc cố gắng tạo một thực thể Phiên dịchApi bằng chế độ cài đặt TFLiteRuntime này sẽ gửi một IllegalStateException. Nếu có cả một môi trường thời gian chạy TF Lite phù hợp được liên kết với ứng dụng và một môi trường thời gian chạy TF Lite phù hợp do hệ thống cung cấp, thì mô hình thời gian chạy do hệ thống cung cấp sẽ được sử dụng.
Chế độ cài đặt này phù hợp để sử dụng trong mã không quan tâm đến nguồn thời gian chạy TF Lite (ví dụ: các lớp phần mềm trung gian).
[[["Dễ hiểu","easyToUnderstand","thumb-up"],["Giúp tôi giải quyết được vấn đề","solvedMyProblem","thumb-up"],["Khác","otherUp","thumb-up"]],[["Thiếu thông tin tôi cần","missingTheInformationINeed","thumb-down"],["Quá phức tạp/quá nhiều bước","tooComplicatedTooManySteps","thumb-down"],["Đã lỗi thời","outOfDate","thumb-down"],["Vấn đề về bản dịch","translationIssue","thumb-down"],["Vấn đề về mẫu/mã","samplesCodeIssue","thumb-down"],["Khác","otherDown","thumb-down"]],["Cập nhật lần gần đây nhất: 2025-07-24 UTC."],[],[],null,["# InterpreterApi.Options.TfLiteRuntime\n\npublic static final enum **InterpreterApi.Options.TfLiteRuntime** \nEnum to represent where to get the TensorFlow Lite runtime implementation from.\n\nThe difference between this class and the RuntimeFlavor class: This class specifies a\n*preference* which runtime to use, whereas [RuntimeFlavor](/edge/api/tflite/java/org/tensorflow/lite/RuntimeFlavor) specifies which exact\nruntime *is* being used.\n\n\u003cbr /\u003e\n\n### Inherited Methods\n\nFrom class java.lang.Enum \n\n|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| final int | compareTo([InterpreterApi.Options.TfLiteRuntime](/edge/api/tflite/java/org/tensorflow/lite/InterpreterApi.Options.TfLiteRuntime) arg0) |\n| int | compareTo([Object](https://developer.android.com/reference/java/lang/Object.html) arg0) |\n| final 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[InterpreterApi.Options.TfLiteRuntime](/edge/api/tflite/java/org/tensorflow/lite/InterpreterApi.Options.TfLiteRuntime)\\\u003e | getDeclaringClass() |\n| final int | hashCode() |\n| final [String](https://developer.android.com/reference/java/lang/String.html) | name() |\n| final int | ordinal() |\n| [String](https://developer.android.com/reference/java/lang/String.html) | toString() |\n| static \\\u003cT extends [Enum](https://developer.android.com/reference/java/lang/Enum.html)\\\u003cT\\\u003e\\\u003e T | valueOf([Class](https://developer.android.com/reference/java/lang/Class.html)\\\u003cT\\\u003e arg0, [String](https://developer.android.com/reference/java/lang/String.html) arg1) |\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 java.lang.Comparable \n\n|--------------|----------------------------------------------------------------------------------------------------------------------------------------|\n| abstract int | compareTo([InterpreterApi.Options.TfLiteRuntime](/edge/api/tflite/java/org/tensorflow/lite/InterpreterApi.Options.TfLiteRuntime) arg0) |\n\nEnum Values\n-----------\n\n#### public static final InterpreterApi.Options.TfLiteRuntime\n**FROM_APPLICATION_ONLY**\n\nUse a TF Lite runtime implementation that is linked into the application. If there is no\nsuitable TF Lite runtime implementation linked into the application, then attempting to\ncreate an InterpreterApi instance with this TfLiteRuntime setting will throw an\nIllegalStateException exception (even if the OS or system services could provide a TF Lite\nruntime implementation).\n\nThis is the default setting. This setting is also appropriate for apps that must run on\nsystems that don't provide a TF Lite runtime implementation.\n\n\u003cbr /\u003e\n\n#### public static final InterpreterApi.Options.TfLiteRuntime\n**FROM_SYSTEM_ONLY**\n\nUse a TF Lite runtime implementation provided by the OS or system services. This will be\nobtained from a system library / shared object / service, such as Google Play Services. It\nmay be newer than the version linked into the application (if any). If there is no suitable\nTF Lite runtime implementation provided by the system, then attempting to create an\nInterpreterApi instance with this TfLiteRuntime setting will throw an IllegalStateException\nexception (even if there is a TF Lite runtime implementation linked into the application).\n\nThis setting is appropriate for code that will use a system-provided TF Lite runtime,\nwhich can reduce app binary size and can be updated more frequently.\n\n\u003cbr /\u003e\n\n#### public static final InterpreterApi.Options.TfLiteRuntime\n**PREFER_SYSTEM_OVER_APPLICATION**\n\nUse a system-provided TF Lite runtime implementation, if any, otherwise use the TF Lite\nruntime implementation linked into the application, if any. If no suitable TF Lite runtime\ncan be found in any location, then attempting to create an InterpreterApi instance with\nthis TFLiteRuntime setting will throw an IllegalStateException. If there is both a suitable\nTF Lite runtime linked into the application and also a suitable TF Lite runtime provided by\nthe system, the one provided by the system will be used.\n\nThis setting is suitable for use in code that doesn't care where the TF Lite runtime is\ncoming from (e.g. middleware layers).\n\n\u003cbr /\u003e"]]