Interface Core#

Core represents an OpenVINO runtime Core entity. User applications can create several Core class instances, but in this case, the underlying plugins are created multiple times and not shared between several Core instances. It is recommended to have a single Core instance per application.

interface Core {
    addExtension(libraryPath): void;
    compileModel(model, deviceName, config?): Promise<CompiledModel>;
    compileModel(modelPath, deviceName, config?): Promise<CompiledModel>;
    compileModelSync(model, deviceName, config?): CompiledModel;
    compileModelSync(modelPath, deviceName, config?): CompiledModel;
    getAvailableDevices(): string[];
    getProperty(propertyName): string | number | boolean;
    getProperty(deviceName, propertyName): string | number | boolean;
    getVersions(deviceName): {
        [deviceName: string]: {
            buildNumber: string;
            description: string;
        };
    };
    importModel(modelStream, device, config?): Promise<CompiledModel>
    importModelSync(modelStream, device, config?): CompiledModel;
    readModel(modelPath, weightsPath?): Promise<Model>;
    readModel(model, weights): Promise<Model>;
    readModel(modelBuffer, weightsBuffer?): Promise<Model>;
    readModelSync(modelPath, weightsPath?): Model;
    readModelSync(model, weights): Model;
    readModelSync(modelBuffer, weightsBuffer?): Model;
    setProperty(properties): void;
    setProperty(deviceName, properties): void;
}

Methods#

addExtension

  • addExtension(libraryPath): void
    

    Registers extensions to a Core object.

    • Parameters:

      • libraryPath: string

        A path to the library with ov::Extension

    • Defined in: addon.ts:37

compileModel

  • compileModel(model, deviceName, config?): Promise<CompiledModel>
    

    Asynchronously creates a compiled model from a source Model object. You can create as many compiled models as needed and use them simultaneously (up to the limitation of the hardware resources).

    • Parameters:

      • model: Model

        The Model object acquired from Core.readModel

      • deviceName: string

        The name of a device, to which the model is loaded.

      • Optional

        An object with the key-value pairs (property name, property value): relevant only for this load operation.

        config: {
            [propertyName: string]: string;
        }
        
      • [propertyName: string]:string

    • Returns: Promise<CompiledModel >

    • Defined in: addon.ts:48

    compileModel(modelPath, deviceName, config?): Promise<CompiledModel>
    

    Asynchronously reads a model and creates a compiled model from the IR/ONNX/PDPD file. This can be more efficient than using Core.readModel + core.compileModel(Model) flow especially for cases when caching is enabled and a cached model is available. You can create as many compiled models as needed and use them simultaneously (up to the limitation of the hardware resources).

    • Parameters:

      • model: Model

        The path to a model.is i

      • deviceName: string

        The name of a device, to which a model is loaded.

      • Optional

        config: {
            [propertyName: string]: string;
        }
        

        An object with the key-value pairs (property name, property value): relevant only for this load operation.

        • [propertyName: string]:string

    • Returns: Promise<CompiledModel >

    • Defined in: addon.ts:67

compileModelSync

  • compileModelSync(model, deviceName, config?): CompiledModel
    

    A synchronous version of Core.compileModel. It creates a compiled model from a source model object.

    • Parameters:

      • model: Model

      • deviceName: string

      • Optional

        config: {
                  [propertyName: string]: string;
         }
        
      • [propertyName: string]:string

    • Returns: CompiledModel

    • Defined in: addon.ts:76

    compileModelSync(modelPath, deviceName, config?): CompiledModel
    

    A synchronous version of Core.compileModel. It reads a model and creates a compiled model from the IR/ONNX/PDPD file.

    • Parameters:

      • modelPath: string

      • deviceName: string

      • Optional

        config: {
                  [propertyName: string]: string;
         }
        
      • [propertyName: string]:string

    • Returns: CompiledModel

    • Defined in: addon.ts:85

getAvailableDevices

  • getAvailableDevices(): string[]
    

    It returns a list of available inference devices. Core objects go over all registered plugins.

    • Returns: string[]

      The list of devices may include any of the following: CPU, GPU.0, GPU.1, NPU… If there is more than one device of a specific type, they are enumerated with .# suffix. Such enumerated devices can later be used as a device name in all Core methods, like compile_model, query_model, set_property and so on.

    • Defined in: addon.ts:99

getProperty

  • getProperty(propertyName): string | number | boolean
    

    It gets the properties dedicated to device behavior.

    • Parameters:

      • propertyName: string

        A property name.

    • Returns: string | number | boolean

    • Defined in: addon.ts:104

  • getProperty(deviceName, propertyName): string | number | boolean
    

    It gets the properties dedicated to device behavior.

    • Parameters:

      • deviceName: string

        The name of a device, the properties of which you get.

      • propertyName: string

        A property name.

    • Returns: string | number | boolean

    • Defined in: addon.ts:111

getVersions

  • getVersions(deviceName): {
        [deviceName: string]: {
            buildNumber: string;
            description: string;
        };
    }
    

    It returns information on the version of device plugins.

    • Parameters:

      • deviceName: string

        A device name to identify a plugin.

    • Returns:

      {
          [deviceName: string]: {
              buildNumber: string;
              description: string;
          };
      }
      
      • buildNumber: string

      • description: string

    • Defined in: addon.ts:119

importModel

  • importModel(modelStream, device, config?): Promise<CompiledModel>
    

    It asynchronously imports a previously exported compiled model.

    • Parameters:

      • modelStream: Buffer

        The input stream that contains a model, previously exported with the CompiledModel.exportModelSync method.

      • device: string

        The name of a device, for which you import a compiled model. Note, if the device name was not used to compile the original model, an exception is thrown.

      • Optional

        config: {
                  [key: string]: string | number | boolean;
         }
        

        An object with the key-value pairs (property name, property value): relevant only for this load operation.

        • [key: string]: string | number | boolean

    • Returns: Promise<CompiledModel>

    • Defined in: addon.ts:135

importModelSync

  • importModelSync(modelStream, device, config?): CompiledModel
    

    A synchronous version of Core.importModel. It imports a previously exported compiled model.

    • Parameters:

      • modelStream: Buffer

        The input stream that contains a model, previously exported with the CompiledModel.exportModelSync method.

      • device: string

        The name of a device, for which you import a compiled model. Note, if the device name was not used to compile the original model, an exception is thrown.

      • Optional

        config: {
                  [key: string]: string | number | boolean;
         }
        

        An object with the key-value pairs (property name, property value): relevant only for this load operation.

        • [key: string]: string | number | boolean

    • Returns: CompiledModel

    • Defined in: addon.ts:144

readModel

  • readModel(modelPath, weightsPath?): Promise<Model>
    

    It reads models from the IR / ONNX / PDPD / TF and TFLite formats.

    • Parameters:

      • modelPath: string

        The path to a model in the IR / ONNX / PDPD / TF or TFLite format.

      • Optional

        weightsPath: string
        

        The path to a data file for the IR format (.bin): if the path is empty, it tries to read the bin file with the same name as xml and if the bin file with the same name was not found, it loads IR without weights.

        For the ONNX format (.onnx), the weights parameter is not used.
        For the PDPD format (.pdmodel), the weights parameter is not used.
        For the TF format (.pb), the weights parameter is not used.
        For the TFLite format (.tflite), the weights parameter is not used.
    • Returns: Promise<Model>

    • Defined in: addon.ts:162

    readModel(modelPath, weights): Promise<Model>
    

    It reads models from the IR / ONNX / PDPD / TF and TFLite formats.

    • Parameters:

      • modelPath: string

        A string with model in the IR / ONNX / PDPD / TF and TFLite format.

      • weights: Tensor

        Tensor with weights. Reading ONNX / PDPD / TF and TFLite models does not support loading weights from weights tensors.

    • Returns: Promise<Model>

    • Defined in: addon.ts:170

    readModel(modelBuffer, weightsBuffer?): Promise<Model>
    

    It reads models from the IR / ONNX / PDPD / TF and TFLite formats.

    • Parameters:

      • modelBuffer: Uint8Array

        Binary data with a model in the IR / ONNX / PDPD / TF or TFLite format.

      • Optional

        weightsBuffer: Uint8Array
        

        Binary data with tensor data.

    • Returns: Promise<Model>

    • Defined in: addon.ts:177

readModelSync

  • readModelSync(modelPath, weightsPath?): Model
    

    It reads models from the IR / ONNX / PDPD / TF and TFLite formats.

    • Parameters:

      • modelPath: string

        The path to a model in the IR / ONNX / PDPD / TF or TFLite format.

      • Optional

        weightsPath: string
        
    • Returns: Promise<Model>

    • Defined in: addon.ts:183

    readModelSync(modelPath, weights): Model
    

    A synchronous version of Core.readModel. It reads models from the IR / ONNX / PDPD / TF and TFLite formats.

    • Parameters:

      • modelPath: string

      • weights: Tensor

    • Returns: Model

    • Defined in: addon.ts:188

    readModelSync(modelBuffer, weightsBuffer?): Model
    
    • Parameters:

      • modelBuffer: Uint8Array

      • Optional

        weightsBuffer: Uint8Array
        
    • Returns: Model

    • Defined in: addon.ts:193

setProperty

  • setProperty(properties): void
    

    It sets the properties.

    • Parameters:

      • properties: {
                 [key: string]: string | number | boolean;
        }
        

        An object with the property name - property value pairs.

        • [key: string]: string | number | boolean

    • Returns: void

    • Defined in: addon.ts:198

    setProperty(deviceName, properties): void
    

    It sets the properties for a device.

    • Parameters:

      • deviceName: string

      • properties: {
                 [key: string]: string | number | boolean;
        }
        
        • [key: string]: string | number | boolean

    • Returns: string | number | boolean

    • Defined in: addon.ts:204