# litert::EnvironmentOptions


`#include <litert_environment_options.h>`

Manages configuration options for a LiteRT [Environment](https://developers.google.com/edge/api/litert/c/classlitert/1-1-environment#classlitert_1_1_environment).

## Summary

This class provides methods to access various options related to the LiteRT environment, such as compiler settings, dispatch libraries, and hardware acceleration configurations (e.g., OpenCL, EGL, WebGPU, Metal, Vulkan).

| ### Constructors and Destructors ||
|---|---|
| `https://developers.google.com/edge/api/litert/c/classlitert/1-1-environment-options#classlitert_1_1_environment_options_1a5566a115ea47a595798f245a91a56cb2(absl::Span< const https://developers.google.com/edge/api/litert/c/structlitert/1-1-environment-options-1-1-option#structlitert_1_1_environment_options_1_1_option > options)` Constructs an `https://developers.google.com/edge/api/litert/c/classlitert/1-1-environment-options#classlitert_1_1_environment_options` object from a span of options. ||

| ### Public types ||
|---|---|
| `https://developers.google.com/edge/api/litert/c/classlitert/1-1-environment-options#classlitert_1_1_environment_options_1ae3ae0b076adcc94af38ca59ae3ef24ab{ https://developers.google.com/edge/api/litert/c/classlitert/1-1-environment-options#classlitert_1_1_environment_options_1ae3ae0b076adcc94af38ca59ae3ef24abaff3fd260f15c09772868fd2932162f68 = kLiteRtEnvOptionTagCompilerPluginLibraryDir, https://developers.google.com/edge/api/litert/c/classlitert/1-1-environment-options#classlitert_1_1_environment_options_1ae3ae0b076adcc94af38ca59ae3ef24abafe3f183268f672393df71ec00892600e = kLiteRtEnvOptionTagDispatchLibraryDir, https://developers.google.com/edge/api/litert/c/classlitert/1-1-environment-options#classlitert_1_1_environment_options_1ae3ae0b076adcc94af38ca59ae3ef24aba9850d9dfa45bfa1fd259e6642d139da8 = kLiteRtEnvOptionTagOpenClDeviceId, https://developers.google.com/edge/api/litert/c/classlitert/1-1-environment-options#classlitert_1_1_environment_options_1ae3ae0b076adcc94af38ca59ae3ef24abae74df678ab6c11e3ae6bbf5c0a1472f2 = kLiteRtEnvOptionTagOpenClPlatformId, https://developers.google.com/edge/api/litert/c/classlitert/1-1-environment-options#classlitert_1_1_environment_options_1ae3ae0b076adcc94af38ca59ae3ef24aba8c0f25dcd5fe9bbb69558331841bc0b0 = kLiteRtEnvOptionTagOpenClContext, https://developers.google.com/edge/api/litert/c/classlitert/1-1-environment-options#classlitert_1_1_environment_options_1ae3ae0b076adcc94af38ca59ae3ef24aba60aeef43b72c881c9b81f292df99c12c = kLiteRtEnvOptionTagOpenClCommandQueue, https://developers.google.com/edge/api/litert/c/classlitert/1-1-environment-options#classlitert_1_1_environment_options_1ae3ae0b076adcc94af38ca59ae3ef24abab4b454fade9542b0c54392e3e1c3773e = kLiteRtEnvOptionTagEglDisplay, https://developers.google.com/edge/api/litert/c/classlitert/1-1-environment-options#classlitert_1_1_environment_options_1ae3ae0b076adcc94af38ca59ae3ef24aba8378393dcb09570b84d828ab40937e8b = kLiteRtEnvOptionTagEglContext, https://developers.google.com/edge/api/litert/c/classlitert/1-1-environment-options#classlitert_1_1_environment_options_1ae3ae0b076adcc94af38ca59ae3ef24abab2a51bf0b588309caf93a7ace4f0192b = kLiteRtEnvOptionTagWebGpuDevice, https://developers.google.com/edge/api/litert/c/classlitert/1-1-environment-options#classlitert_1_1_environment_options_1ae3ae0b076adcc94af38ca59ae3ef24aba2fda69b03a8a6c2831f8bfaef5b8d084 = kLiteRtEnvOptionTagWebGpuQueue, https://developers.google.com/edge/api/litert/c/classlitert/1-1-environment-options#classlitert_1_1_environment_options_1ae3ae0b076adcc94af38ca59ae3ef24abade66c985df0aa76e42bcb7f064b2cf37 = kLiteRtEnvOptionTagMetalDevice, https://developers.google.com/edge/api/litert/c/classlitert/1-1-environment-options#classlitert_1_1_environment_options_1ae3ae0b076adcc94af38ca59ae3ef24aba5a7d719e129112bc71d41f2db708e714 = kLiteRtEnvOptionTagMetalCommandQueue, https://developers.google.com/edge/api/litert/c/classlitert/1-1-environment-options#classlitert_1_1_environment_options_1ae3ae0b076adcc94af38ca59ae3ef24aba3ec6ecb50c7fd20466da403ac72f56eb = kLiteRtEnvOptionTagVulkanEnvironment, https://developers.google.com/edge/api/litert/c/classlitert/1-1-environment-options#classlitert_1_1_environment_options_1ae3ae0b076adcc94af38ca59ae3ef24abac84abdbb6730784142f84a970f08583c = kLiteRtEnvOptionTagCallbackOnGpuEnvDestroy, https://developers.google.com/edge/api/litert/c/classlitert/1-1-environment-options#classlitert_1_1_environment_options_1ae3ae0b076adcc94af38ca59ae3ef24abade8ece22b24bb9d648ee5bc9df92d1d7 = kLiteRtEnvOptionTagCallbackUserDataOnGpuEnvDestroy, https://developers.google.com/edge/api/litert/c/classlitert/1-1-environment-options#classlitert_1_1_environment_options_1ae3ae0b076adcc94af38ca59ae3ef24abab18f37255d2502c8e65da7abb596f539 = kLiteRtEnvOptionTagMagicNumberConfigs, https://developers.google.com/edge/api/litert/c/classlitert/1-1-environment-options#classlitert_1_1_environment_options_1ae3ae0b076adcc94af38ca59ae3ef24aba955eda16440809b1b7a21a407fcaf1b5 = kLiteRtEnvOptionTagMagicNumberVerifications, https://developers.google.com/edge/api/litert/c/classlitert/1-1-environment-options#classlitert_1_1_environment_options_1ae3ae0b076adcc94af38ca59ae3ef24aba84ab842a2cc405090eaa1087e9a784ff = kLiteRtEnvOptionTagCompilerCacheDir, https://developers.google.com/edge/api/litert/c/classlitert/1-1-environment-options#classlitert_1_1_environment_options_1ae3ae0b076adcc94af38ca59ae3ef24abad3cf9da39f8226a84a3fa4b665760ee7 = kLiteRtEnvOptionTagWebGpuInstance, https://developers.google.com/edge/api/litert/c/classlitert/1-1-environment-options#classlitert_1_1_environment_options_1ae3ae0b076adcc94af38ca59ae3ef24aba538a3fdcc1d84e56a1d2f5ecf87bd027 = kLiteRtEnvOptionTagWebGpuProcs, https://developers.google.com/edge/api/litert/c/classlitert/1-1-environment-options#classlitert_1_1_environment_options_1ae3ae0b076adcc94af38ca59ae3ef24aba30a84e3a32591e5f0ed9653bd559e264 = kLiteRtEnvOptionTagRuntimeLibraryDir, https://developers.google.com/edge/api/litert/c/classlitert/1-1-environment-options#classlitert_1_1_environment_options_1ae3ae0b076adcc94af38ca59ae3ef24aba6bb57c2a3086a40002d8f015e52776c3 = kLiteRtEnvOptionTagSystemRuntimeHandle, https://developers.google.com/edge/api/litert/c/classlitert/1-1-environment-options#classlitert_1_1_environment_options_1ae3ae0b076adcc94af38ca59ae3ef24aba751e242c7157797fb5264dc6d1eec2b7 = kLiteRtEnvOptionTagAutoRegisterAccelerators, https://developers.google.com/edge/api/litert/c/classlitert/1-1-environment-options#classlitert_1_1_environment_options_1ae3ae0b076adcc94af38ca59ae3ef24aba2b86c06a9cd886dc39cfaf1466881c0f = kLiteRtEnvOptionTagMinLoggerSeverity }` | enumTags for environment options. |

| ### Public functions ||
|---|---|
| `https://developers.google.com/edge/api/litert/c/classlitert/1-1-environment-options#classlitert_1_1_environment_options_1a30cbd945b1d93ab4dbacb975838d1cce(https://developers.google.com/edge/api/litert/c/classlitert/1-1-environment-options#classlitert_1_1_environment_options_1ae3ae0b076adcc94af38ca59ae3ef24ab tag) const ` | `https://developers.google.com/edge/api/litert/c/classlitert/1-1-expected#classlitert_1_1_expected< const LiteRtVariant >` Retrieves the value of an option specified by a tag. |
| `https://developers.google.com/edge/api/litert/c/classlitert/1-1-environment-options#classlitert_1_1_environment_options_1a6dbdd83479e0f7d9dc139faa3db452f8(LiteRtEnvOptionTag tag) const ` | `https://developers.google.com/edge/api/litert/c/classlitert/1-1-expected#classlitert_1_1_expected< const LiteRtVariant >` **[Deprecated.](https://developers.google.com/edge/api/litert/c/deprecated/deprecated)** Use `GetOption(Tag)` instead. |
| `https://developers.google.com/edge/api/litert/c/classlitert/1-1-environment-options#classlitert_1_1_environment_options_1a228c5be6baf28d93812782cbb2dd39d9() const ` | `absl::Span< const https://developers.google.com/edge/api/litert/c/structlitert/1-1-environment-options-1-1-option#structlitert_1_1_environment_options_1_1_option >` Retrieves all options. |

| ### Structs ||
|---|---|
| [litert::EnvironmentOptions::Option](https://developers.google.com/edge/api/litert/c/structlitert/1-1-environment-options-1-1-option) |   |

## Public types

### Tag

```
 Tag
```
Tags for environment options.

These tags are used to identify and retrieve specific configuration settings.

| Properties ||
|---|---|
| `kAutoRegisterAccelerators` | Bitmask of LiteRtHwAccelerators to auto-register during environment creation. If unset, LiteRT auto-registers all supported accelerators. |
| `kCallbackOnGpuEnvDestroy` | Callback to be invoked on GPU environment destruction. |
| `kCallbackUserDataOnGpuEnvDestroy` | User data for the GPU environment destruction callback. |
| `kCompilerCacheDir` | Directory for the compiler cache. |
| `kCompilerPluginLibraryDir` | Directory for compiler plugin libraries. |
| `kDispatchLibraryDir` | Directory for dispatch libraries. |
| `kEglContext` | EGL context. |
| `kEglDisplay` | EGL display. |
| `kMagicNumberConfigs` | Magic number configurations. |
| `kMagicNumberVerifications` | Magic number verifications. |
| `kMetalCommandQueue` | Metal command queue. |
| `kMetalDevice` | Metal device. |
| `kMinLoggerSeverity` | Minimum logger severity for the environment. |
| `kOpenClCommandQueue` | OpenCL command queue. |
| `kOpenClContext` | OpenCL context. |
| `kOpenClDeviceId` | OpenCL device ID. |
| `kOpenClPlatformId` | OpenCL platform ID. |
| `kRuntimeLibraryDir` | Directory for the runtime library. |
| `kSystemRuntimeHandle` | \\internal This is for internal use only. |
| `kVulkanEnvironment` | Vulkan environment (experimental). |
| `kWebGpuDevice` | WebGPU device. |
| `kWebGpuInstance` | Singleton ML Drift WebGPU/Dawn instance. Required for shared libraries to prevent them from creating their own instances. |
| `kWebGpuProcs` | Dawn procedure table pointer. This allows shared libraries to use the shared procedures instead of their own. |
| `kWebGpuQueue` | WebGPU queue. |

## Public functions

### EnvironmentOptions

```
 EnvironmentOptions(
  absl::Span< const Option > options
)
```
Constructs an `https://developers.google.com/edge/api/litert/c/classlitert/1-1-environment-options#classlitert_1_1_environment_options` object from a span of options.

<br />

Details Parameters `options` A span of `https://developers.google.com/edge/api/litert/c/structlitert/1-1-environment-options-1-1-option#structlitert_1_1_environment_options_1_1_option` objects to initialize the environment options with.

### GetOption

```
Expected< const LiteRtVariant > GetOption(
  Tag tag
) const 
```
Retrieves the value of an option specified by a tag.

<br />

Details Parameters `tag` The tag of the option to retrieve. **Returns** An `https://developers.google.com/edge/api/litert/c/classlitert/1-1-expected#classlitert_1_1_expected` object containing the option value if successful, or an error if the option is not found or the handle is null.

### GetOption

```
Expected< const LiteRtVariant > GetOption(
  LiteRtEnvOptionTag tag
) const 
```
**[Deprecated.](https://developers.google.com/edge/api/litert/c/deprecated/deprecated)** Use `GetOption(Tag)` instead.

### GetOptions

```
absl::Span< const Option > GetOptions() const 
```
Retrieves all options.

<br />

| Details ||
|---|---|
| **Returns** | A span of all options. |