ONNX Runtime JavaScript API
    Preparing search index...

    Interface WebGpuFlags

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

    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".

    It is no longer recommended to use this property. The latest WebGPU spec adds GPUDevice.adapterInfo (https://www.w3.org/TR/webgpu/#dom-gpudevice-adapterinfo), which allows to get the adapter information from the device. When it's available, there is no need to set/get the adapter property.

    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.

    undefined

    Create your own GPUAdapter, use it to create a GPUDevice instance and set device property if you want to use a specific fallback option.

    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.

    undefined

    Create your own GPUAdapter, use it to create a GPUDevice instance and set device property if you want to use a specific power preference.

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

    Set or get the profiling configuration.

    Type Declaration

    • Optionalmode?: "default" | "off"

      Set or get the profiling mode.

      'off'

    • Optionalondata?: (data: WebGpuProfilingDataV1) => void

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

    profilingMode?: "default" | "off"

    Set or get the profiling mode.

    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.

    false

    Accessors

    • get device(): Promise<unknown>

      Set or get the GPU device for WebGPU.

      There are 3 valid scenarios of accessing this property:

      • Set a value before the first WebGPU inference session is created. The value will be used by the WebGPU backend to perform calculations. If the value is not a GPUDevice object, an error will be thrown.
      • Get the value before the first WebGPU inference session is created. This will try to create a new GPUDevice instance. Returns a Promise that resolves to a GPUDevice object.
      • Get the value after the first WebGPU inference session is created. Returns a resolved Promise to the GPUDevice object used by the WebGPU backend.

      Returns Promise<unknown>

    • set device(value: unknown): void

      Parameters

      • value: unknown

      Returns void