Skip to content

Commit

Permalink
Explicitly cast incorrect output type
Browse files Browse the repository at this point in the history
  • Loading branch information
sovrasov committed Apr 24, 2024
1 parent 0192d26 commit 55af470
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/otx/algorithms/common/utils/ir.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
"""Collections of IR-related utils for common OTX algorithms."""

# Copyright (C) 2022 Intel Corporation
# Copyright (C) 2022-2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
#

from pathlib import Path
from typing import Any, Dict, Tuple

from openvino import Type
from openvino.preprocess import PrePostProcessor
from openvino.runtime import Core, save_model

from otx.algorithms.common.utils.utils import is_xpu_available


def check_if_quantized(model: Any) -> bool:
"""Checks if OpenVINO model is already quantized."""
Expand All @@ -32,6 +36,14 @@ def embed_ir_model_data(xml_file: str, data_items: Dict[Tuple[str, str], Any]) -
for k, data in data_items.items():
model.set_rt_info(data, list(k))

# workaround for CVS-138901
if is_xpu_available():
ppp = PrePostProcessor(model)
for o in model.outputs:
if "labels" in o.get_names() and o.get_element_type() == Type.f32:
ppp.output("labels").tensor().set_element_type(Type.i64)
model = ppp.build()

Check warning on line 45 in src/otx/algorithms/common/utils/ir.py

View check run for this annotation

Codecov / codecov/patch

src/otx/algorithms/common/utils/ir.py#L40-L45

Added lines #L40 - L45 were not covered by tests

# workaround for CVS-110054
tmp_xml_path = Path(Path(xml_file).parent) / "tmp.xml"
save_model(model, str(tmp_xml_path), compress_to_fp16=False)
Expand Down

0 comments on commit 55af470

Please sign in to comment.