module

webdnn

Module WebDNN provides main features of WebDNN.

Type aliases
# BackendName: "webgpu" | "webgl" | "webassembly" | "fallback" [webdnn.ts:44]

Backend names supported in WebDNN

# DescriptorRunner: DescriptorRunnerGeneric<GraphDescriptor, any > [webdnn.ts:49]

Descriptor runner

Functions
#

getBackendAvailability

getBackendAvailability(): BackendAvailability [webdnn.ts:102]

Check each computing backend is available or not in this browser. The result will be returned as BackendAvailability structure.

Returns
BackendAvailability

backend availability

#

load

load(directory: string , initOption?: InitOption): Promise<DescriptorRunner> [webdnn.ts:282]

Initialize descriptor runner. This function performs follow things.

  1. Try to initialize computing backend. WebDNN will try to initialize each backend in order of the result of getBackendAvailability. If you want to modify this order, specify initOption.backendOrder option.

  2. Load model data based on initialized backend. Generally, DNN binary data is very large and it takes long time to load. initOption.progressCallback option provides the progress status of loading.

Examples

  • Basic usage

    let runner = await WebDNN.load('./model');
    
  • With initOption.progressCallback option

    let runner = await WebDNN.load('./model', {
        progressCallback: (loaded, total) => console.log(`${ (loaded/total*100).toFixed(1) }% Loaded`);
    });
    
Parameters
Name Type Default Description
directory string

URL of directory that contains graph descriptor files (e.g. graph_webgpu.json)

initOption InitOption {}

Initialize option

Returns
Promise<DescriptorRunner>

DescriptorRunner instance, which is the interface to input/output data and run the model.