Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: Update OpenVINO model generation version #7811

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Update APIs
  • Loading branch information
yinggeh committed Nov 15, 2024
commit df25637bb2cd52163c841013f35c6476d542624a
30 changes: 16 additions & 14 deletions qa/common/gen_qa_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1809,28 +1809,31 @@ def create_openvino_modelfile(
)
model_version_dir = models_dir + "/" + model_name + "/" + str(model_version)

in0 = ng.parameter(shape=batch_dim + input_shape, dtype=input_dtype, name="INPUT0")
in1 = ng.parameter(shape=batch_dim + input_shape, dtype=input_dtype, name="INPUT1")
in0 = ov.opset8.parameter(
shape=batch_dim + input_shape, dtype=input_dtype, name="INPUT0"
)
in1 = ov.opset8.parameter(
shape=batch_dim + input_shape, dtype=input_dtype, name="INPUT1"
)

r0 = ng.add(in0, in1) if not swap else ng.subtract(in0, in1)
r1 = ng.subtract(in0, in1) if not swap else ng.add(in0, in1)
r0 = ov.opset1.add(in0, in1) if not swap else ov.opset1.subtract(in0, in1)
r1 = ov.opset1.subtract(in0, in1) if not swap else ov.opset1.add(in0, in1)

result0 = ng.reshape(r0, batch_dim + output0_shape, special_zero=False)
result1 = ng.reshape(r1, batch_dim + output1_shape, special_zero=False)
result0 = ov.opset1.reshape(r0, batch_dim + output0_shape, special_zero=False)
result1 = ov.opset1.reshape(r1, batch_dim + output1_shape, special_zero=False)

op0 = ng.convert(result0, destination_type=output0_dtype, name="OUTPUT0")
op1 = ng.convert(result1, destination_type=output1_dtype, name="OUTPUT1")
op0 = ov.opset1.convert(result0, destination_type=output0_dtype, name="OUTPUT0")
op1 = ov.opset1.convert(result1, destination_type=output1_dtype, name="OUTPUT1")

function = ng.impl.Function([op0, op1], [in0, in1], model_name)
ie_network = IENetwork(ng.impl.Function.to_capsule(function))
model = ov.Model([op0, op1], [in0, in1], model_name)

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

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


Expand Down Expand Up @@ -2486,8 +2489,7 @@ def create_fixed_models(
import torch
from torch import nn
if FLAGS.openvino:
from openvino.inference_engine import IENetwork
import ngraph as ng
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The nGraph API is deprecated and will be removed in the 2024.0 release. See opencv/opencv#24589

import openvino.runtime as ov

import test_util as tu

Expand Down
Loading