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): OVAny;
getProperty(deviceName, propertyName): OVAny;
getVersions(deviceName): {
[deviceName: string]: {
buildNumber: string;
description: string;
};
};
importModel(modelStream, device, config?): Promise<CompiledModel>
importModelSync(modelStream, device, config?): CompiledModel;
queryModel(model, deviceName, properties?): string[];
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;
}
Defined in: addon.ts:34
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:39
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: Record<string, OVAny>,
Record<string,OVAny>
Returns: Promise<CompiledModel>
Defined in: addon.ts:50
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:
Returns: Promise<CompiledModel>
Defined in: addon.ts:69
compileModelSync
compileModelSync(model, deviceName, config?): CompiledModel
A synchronous version of Core.compileModel. It creates a compiled model from a source model object.
Parameters:
Returns: CompiledModel
Defined in: addon.ts:78
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: Record<string, OVAny>,
Record<string, OVAny>
Returns: CompiledModel
Defined in: addon.ts:87
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, likecompile_model
,query_model
,set_property
and so on.Defined in: addon.ts:101
getProperty
getProperty(propertyName): OVAny
It gets the properties dedicated to device behavior.
Parameters:
propertyName: string
A property name.
Returns: OVAny
Defined in: addon.ts:106
getProperty(deviceName, propertyName): OVAny
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: OVAny
Defined in: addon.ts:113
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:121
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: Record<string, OVAny>,
An object with the key-value pairs (property name, property value): relevant only for this load operation.
Record<string, OVAny>
Returns: Promise<CompiledModel>
Defined in: addon.ts:137
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: Record<string, OVAny>,
An object with the key-value pairs (property name, property value): relevant only for this load operation.
Record<string, OVAny>
Returns: CompiledModel
Defined in: addon.ts:146
queryModel
queryModel(model, deviceName, properties?): { [key: string]: string }
It queries the device if it supports specified model with the specified properties.
Parameters:
model: Model
The Model object acquired from Core.readModel
deviceName: string
The name of a device.
Optional
An object with the property name - property value pairs. (property name, property value).
properties: Record<string, OVAny>,
Record<string, OVAny>
Returns: [key: string]: string
Defined in: addon.ts:217
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:164
readModel(model, weights): Promise<Model>
It reads models from the IR / ONNX / PDPD / TF and TFLite formats.
Parameters:
model: 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:172
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:179
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:187
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:192
readModelSync(modelBuffer, weightsBuffer?): Model
Parameters:
modelBuffer: Uint8Array
Optional
weightsBuffer: Uint8Array
Returns: Model
Defined in: addon.ts:197
setProperty
setProperty(properties: Record<string, OVAny>): void
It sets the properties.
Parameters:
properties: Record<string, OVAny>,
An object with the property name - property value pairs.
Record<string, OVAny>
Returns: void
Defined in: addon.ts:202
setProperty(deviceName, properties: Record<string, OVAny>): void
It sets the properties for a device.
Parameters:
deviceName: string
properties: Record<string, OVAny>,
Record<string, OVAny>
Returns: OVAny
Defined in: addon.ts:204