Skip to content

Commit

Permalink
ci: Fix OpenVINO models (#7904)
Browse files Browse the repository at this point in the history
  • Loading branch information
yinggeh authored Jan 3, 2025
1 parent 997bb70 commit 48be9ce
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 51 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2024, NVIDIA CORPORATION. All rights reserved.
Copyright (c) 2025, NVIDIA CORPORATION. All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
Expand Down
20 changes: 19 additions & 1 deletion qa/common/gen_common.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2023-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# Copyright 2023-2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
Expand All @@ -24,6 +24,7 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

import os
from typing import List

# Common utilities for model generation scripts
Expand Down Expand Up @@ -168,3 +169,20 @@ def np_to_torch_dtype(np_dtype):
elif np_dtype == np_dtype_string:
return List[str]
return None


def openvino_save_model(model_version_dir, model):
import openvino as ov

# W/A for error moving to OpenVINO new APIs "Attempt to get a name for a Tensor without names".
# For more details, check https://github.com/triton-inference-server/openvino_backend/issues/89
if len(model.outputs) == 0:
model.outputs[0].get_tensor().set_names({"OUTPUT"})
else:
for idx, out in enumerate(model.outputs):
out.get_tensor().set_names({f"OUTPUT{idx}"})

os.makedirs(model_version_dir, exist_ok=True)
ov.serialize(
model, model_version_dir + "/model.xml", model_version_dir + "/model.bin"
)
13 changes: 3 additions & 10 deletions qa/common/gen_qa_dyna_sequence_models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python3

# Copyright 2019-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# Copyright 2019-2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
Expand Down Expand Up @@ -36,6 +36,7 @@
np_to_tf_dtype,
np_to_torch_dtype,
np_to_trt_dtype,
openvino_save_model,
)

FLAGS = None
Expand Down Expand Up @@ -1304,15 +1305,7 @@ def create_openvino_modelfile(models_dir, model_version, max_batch, dtype, shape
op0 = ov.opset1.multiply(tmp, ready, name="OUTPUT")

model = ov.Model([op0], [in0, start, end, ready, corrid], model_name)

try:
os.makedirs(model_version_dir)
except OSError as ex:
pass # ignore existing dir

ov.serialize(
model, model_version_dir + "/model.xml", model_version_dir + "/model.bin"
)
openvino_save_model(model_version_dir, model)


def create_openvino_modelconfig(models_dir, model_version, max_batch, dtype, shape):
Expand Down
10 changes: 3 additions & 7 deletions qa/common/gen_qa_identity_models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python3

# Copyright 2019-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# Copyright 2019-2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
Expand Down Expand Up @@ -37,6 +37,7 @@
np_to_onnx_dtype,
np_to_tf_dtype,
np_to_trt_dtype,
openvino_save_model,
)

FLAGS = None
Expand Down Expand Up @@ -581,12 +582,7 @@ def create_openvino_modelfile(
)

model = ov.Model(openvino_outputs, openvino_inputs, model_name)

os.makedirs(model_version_dir, exist_ok=True)

ov.serialize(
model, model_version_dir + "/model.xml", model_version_dir + "/model.bin"
)
openvino_save_model(model_version_dir, model)


def create_openvino_modelconfig(
Expand Down
4 changes: 2 additions & 2 deletions qa/common/gen_qa_model_repository
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
# Copyright 2018-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# Copyright 2018-2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
Expand Down Expand Up @@ -55,7 +55,7 @@ ONNX_VERSION=1.16.1
ONNX_OPSET=0

# OPENVINO version
OPENVINO_VERSION=2024.4.0
OPENVINO_VERSION=2024.5.0

UBUNTU_IMAGE=${UBUNTU_IMAGE:=ubuntu:22.04}
PYTORCH_IMAGE=${PYTORCH_IMAGE:=nvcr.io/nvidia/pytorch:$TRITON_VERSION-py3}
Expand Down
13 changes: 3 additions & 10 deletions qa/common/gen_qa_models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python3

# Copyright 2018-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# Copyright 2018-2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
Expand Down Expand Up @@ -39,6 +39,7 @@
np_to_tf_dtype,
np_to_torch_dtype,
np_to_trt_dtype,
openvino_save_model,
)

FLAGS = None
Expand Down Expand Up @@ -1826,15 +1827,7 @@ def create_openvino_modelfile(
op1 = ov.opset1.convert(result1, destination_type=output1_dtype, name="OUTPUT1")

model = ov.Model([op0, op1], [in0, in1], model_name)

try:
os.makedirs(model_version_dir)
except OSError as ex:
pass # ignore existing dir

ov.serialize(
model, model_version_dir + "/model.xml", model_version_dir + "/model.bin"
)
openvino_save_model(model_version_dir, model)


def create_openvino_modelconfig(
Expand Down
13 changes: 3 additions & 10 deletions qa/common/gen_qa_reshape_models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python3

# Copyright 2019-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# Copyright 2019-2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
Expand Down Expand Up @@ -38,6 +38,7 @@
np_to_tf_dtype,
np_to_torch_dtype,
np_to_trt_dtype,
openvino_save_model,
)

FLAGS = None
Expand Down Expand Up @@ -949,15 +950,7 @@ def create_openvino_modelfile(
)

model = ov.Model(openvino_outputs, openvino_inputs, model_name)

try:
os.makedirs(model_version_dir)
except OSError as ex:
pass # ignore existing dir

ov.serialize(
model, model_version_dir + "/model.xml", model_version_dir + "/model.bin"
)
openvino_save_model(model_version_dir, model)


def create_openvino_modelconfig(
Expand Down
13 changes: 3 additions & 10 deletions qa/common/gen_qa_sequence_models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python3

# Copyright 2019-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# Copyright 2019-2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
Expand Down Expand Up @@ -37,6 +37,7 @@
np_to_tf_dtype,
np_to_torch_dtype,
np_to_trt_dtype,
openvino_save_model,
)

FLAGS = None
Expand Down Expand Up @@ -1153,15 +1154,7 @@ def create_openvino_modelfile(models_dir, model_version, max_batch, dtype, shape
op0 = ov.opset1.multiply(tmp, ready, name="OUTPUT")

model = ov.Model([op0], [in0, start, ready], model_name)

try:
os.makedirs(model_version_dir)
except OSError as ex:
pass # ignore existing dir

ov.serialize(
model, model_version_dir + "/model.xml", model_version_dir + "/model.bin"
)
openvino_save_model(model_version_dir, model)


def create_openvino_modelconfig(models_dir, model_version, max_batch, dtype, shape):
Expand Down

0 comments on commit 48be9ce

Please sign in to comment.