interface WebGpuFlags {
    adapter: unknown;
    device: unknown;
    forceFallbackAdapter?: boolean;
    powerPreference?: "high-performance" | "low-power";
    profiling?: {
        mode?: "default" | "off";
        ondata?: ((data) => void);
    };
    profilingMode?: "default" | "off";
    validateInputContent?: boolean;
}

Properties

adapter: unknown

Set or get the adapter for WebGPU.

Setting this property only has effect before the first WebGPU inference session is created. The value will be used as the GPU adapter for the underlying WebGPU backend to create GPU device.

If this property is not set, it will be available to get after the first WebGPU inference session is created. The value will be the GPU adapter that created by the underlying WebGPU backend.

When use with TypeScript, the type of this property is GPUAdapter defined in "@webgpu/types". Use const adapter = env.webgpu.adapter as GPUAdapter; in TypeScript to access this property with correct type.

see comments on Tensor.GpuBufferType

device: unknown

Get the device for WebGPU.

This property is only available after the first WebGPU inference session is created.

When use with TypeScript, the type of this property is GPUDevice defined in "@webgpu/types". Use const device = env.webgpu.device as GPUDevice; in TypeScript to access this property with correct type.

see comments on Tensor.GpuBufferType for more details about why not use types defined in "@webgpu/types".

forceFallbackAdapter?: boolean

Set or get the force fallback adapter flag.

Setting this property only has effect before the first WebGPU inference session is created. The value will be used as options for navigator.gpu.requestAdapter().

See https://gpuweb.github.io/gpuweb/#dictdef-gpurequestadapteroptions for more details.

Default Value

undefined

powerPreference?: "high-performance" | "low-power"

Set or get the power preference.

Setting this property only has effect before the first WebGPU inference session is created. The value will be used as options for navigator.gpu.requestAdapter().

See https://gpuweb.github.io/gpuweb/#dictdef-gpurequestadapteroptions for more details.

Default Value

undefined

profiling?: {
    mode?: "default" | "off";
    ondata?: ((data) => void);
}

Set or get the profiling configuration.

Type declaration

  • Optional mode?: "default" | "off"

    Set or get the profiling mode.

    Default Value

    'off'

  • Optional ondata?: ((data) => void)

    Set or get a callback function when a profiling data is received. If not set, the profiling data will be printed to console.

      • (data): void
      • Set or get a callback function when a profiling data is received. If not set, the profiling data will be printed to console.

        Parameters

        Returns void

profilingMode?: "default" | "off"

Set or get the profiling mode.

Deprecated

Use env.webgpu.profiling.mode instead. If env.webgpu.profiling.mode is set, this property will be ignored.

validateInputContent?: boolean

Set or get whether validate input content.

Default Value

false

Generated using TypeDoc