openvino.runtime.serialize#
- openvino.runtime.serialize(model: ov::Model, xml_path: object, bin_path: object = '', version: str = 'UNSPECIFIED') None #
Serialize given model into IR. The generated .xml and .bin files will be saved into provided paths. This method serializes model “as-is” that means no weights compression is applied. It is recommended to use ov::save_model function instead of ov::serialize in all cases when it is not related to debugging.
- Parameters:
model (openvino.runtime.Model) – model which will be converted to IR representation
xml_path (Union[str, bytes, pathlib.Path]) – path where .xml file will be saved
bin_path (Union[str, bytes, pathlib.Path]) – path where .bin file will be saved (optional), the same name as for xml_path will be used by default.
version (str) – version of the generated IR (optional).
Supported versions are: - “UNSPECIFIED” (default) : Use the latest or model version - “IR_V10” : v10 IR - “IR_V11” : v11 IR
- Examples:
Default IR version:
shape = [2, 2] parameter_a = ov.parameter(shape, dtype=np.float32, name="A") parameter_b = ov.parameter(shape, dtype=np.float32, name="B") parameter_c = ov.parameter(shape, dtype=np.float32, name="C") op = (parameter_a + parameter_b) * parameter_c model = Model(op, [parameter_a, parameter_b, parameter_c], "Model") # IR generated with default version serialize(model, xml_path="./serialized.xml", bin_path="./serialized.bin")
IR version 11:
parameter_a = ov.parameter(shape, dtype=np.float32, name="A") parameter_b = ov.parameter(shape, dtype=np.float32, name="B") parameter_c = ov.parameter(shape, dtype=np.float32, name="C") op = (parameter_a + parameter_b) * parameter_c model = Model(ops, [parameter_a, parameter_b, parameter_c], "Model") # IR generated with default version serialize(model, xml_path="./serialized.xml", bin_path="./serialized.bin", version="IR_V11")