-
Notifications
You must be signed in to change notification settings - Fork 213
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
add support for model outputs without names #2850
base: main
Are you sure you want to change the base?
Changes from all commits
0c8fc87
d62b6d9
69c201c
ceaf202
90f5ca8
5fed196
19c8928
aea68a9
5a84efa
5b9a3df
2dae97c
173efc8
698c871
4f02072
028a2e4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
<?xml version="1.0"?> | ||
<net name="no_name_output" version="11"> | ||
<layers> | ||
<layer id="1" name="input1" type="Parameter" version="opset1"> | ||
<data shape="1,10" element_type="i8" /> | ||
<output> | ||
<port id="0" precision="I8" names="input1"> | ||
<dim>1</dim> | ||
<dim>10</dim> | ||
</port> | ||
</output> | ||
</layer> | ||
<layer id="0" name="input2" type="Parameter" version="opset1"> | ||
Comment on lines
+4
to
+13
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we use name "input_1" and "input_2" to follow the convention? |
||
<data shape="1,10" element_type="i8" /> | ||
<output> | ||
<port id="0" precision="I8" names="input2"> | ||
<dim>1</dim> | ||
<dim>10</dim> | ||
</port> | ||
</output> | ||
</layer> | ||
<layer id="2" name="ADD" type="Add" version="opset1"> | ||
<data auto_broadcast="numpy" /> | ||
<input> | ||
<port id="0" precision="I8"> | ||
<dim>1</dim> | ||
<dim>10</dim> | ||
</port> | ||
<port id="1" precision="I8"> | ||
<dim>1</dim> | ||
<dim>10</dim> | ||
</port> | ||
</input> | ||
<output> | ||
<port id="2" precision="I8"> | ||
<dim>1</dim> | ||
<dim>10</dim> | ||
</port> | ||
</output> | ||
</layer> | ||
<layer id="4" name="MULTIPLY" type="Multiply" version="opset1"> | ||
<data auto_broadcast="numpy" /> | ||
<input> | ||
<port id="0" precision="I8"> | ||
<dim>1</dim> | ||
<dim>10</dim> | ||
</port> | ||
<port id="1" precision="I8"> | ||
<dim>1</dim> | ||
<dim>10</dim> | ||
</port> | ||
</input> | ||
<output> | ||
<port id="2" precision="I8"> | ||
<dim>1</dim> | ||
<dim>10</dim> | ||
</port> | ||
</output> | ||
</layer> | ||
<layer id="5" name="Result_5" type="Result" version="opset1"> | ||
<input> | ||
<port id="0" precision="I8"> | ||
<dim>1</dim> | ||
<dim>10</dim> | ||
</port> | ||
</input> | ||
</layer> | ||
<layer id="3" name="Result_6" type="Result" version="opset1"> | ||
<input> | ||
<port id="0" precision="I8"> | ||
<dim>1</dim> | ||
<dim>10</dim> | ||
</port> | ||
</input> | ||
</layer> | ||
</layers> | ||
<edges> | ||
<edge from-layer="0" from-port="0" to-layer="2" to-port="0" /> | ||
<edge from-layer="0" from-port="0" to-layer="4" to-port="0" /> | ||
<edge from-layer="1" from-port="0" to-layer="2" to-port="1" /> | ||
<edge from-layer="1" from-port="0" to-layer="4" to-port="1" /> | ||
<edge from-layer="2" from-port="2" to-layer="3" to-port="0" /> | ||
<edge from-layer="4" from-port="2" to-layer="5" to-port="0" /> | ||
</edges> | ||
<rt_info /> | ||
</net> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -79,6 +79,7 @@ const std::string passthrough_string_model_location = getGenericFullPathForSrcTe | |
const std::string dummy_saved_model_location = getGenericFullPathForSrcTest(std::filesystem::current_path().u8string() + "/src/test/dummy_saved_model", false); | ||
const std::string dummy_tflite_location = getGenericFullPathForSrcTest(std::filesystem::current_path().u8string() + "/src/test/dummy_tflite", false); | ||
const std::string scalar_model_location = getGenericFullPathForSrcTest(std::filesystem::current_path().u8string() + "/src/test/scalar", false); | ||
const std::string no_name_output_model_location = std::filesystem::current_path().u8string() + "/src/test/no_name_output"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will likely not work on windows, see usage of |
||
|
||
const ovms::ModelConfig DUMMY_MODEL_CONFIG{ | ||
"dummy", | ||
|
@@ -215,6 +216,21 @@ const ovms::ModelConfig SCALAR_MODEL_CONFIG{ | |
scalar_model_location, // local path | ||
}; | ||
|
||
const ovms::ModelConfig NO_NAME_MODEL_CONFIG{ | ||
"no_name_output", | ||
no_name_output_model_location, // base path | ||
"CPU", // target device | ||
"1", // batchsize | ||
1, // NIREQ | ||
false, // is stateful | ||
true, // idle sequence cleanup enabled | ||
false, // low latency transformation enabled | ||
500, // stateful sequence max number | ||
"", // cache directory | ||
1, // model_version unused since version are read from path | ||
no_name_output_model_location, // local path | ||
}; | ||
|
||
constexpr const char* DUMMY_MODEL_INPUT_NAME = "b"; | ||
constexpr const char* DUMMY_MODEL_OUTPUT_NAME = "a"; | ||
constexpr const int DUMMY_MODEL_INPUT_SIZE = 10; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# | ||
# Copyright (c) 2025 Intel Corporation | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this script meant to be used only manually by developers? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is a reference how the test model got created in case some changes should be applied. |
||
import openvino.runtime as ov | ||
import numpy as np | ||
import os | ||
|
||
batch_dim = [] | ||
shape = [1, 10] | ||
dtype = np.int8 | ||
model_name = "no_name_output" | ||
model_version_dir = model_name | ||
print(batch_dim + shape) | ||
in0 = ov.opset1.parameter(shape=batch_dim + shape, dtype=dtype, name="input1") | ||
in1 = ov.opset1.parameter(shape=batch_dim + shape, dtype=dtype, name="input2") | ||
op0 = ov.opset1.multiply(in1, in0, name="MULTIPLY") | ||
op1 = ov.opset1.add(in1, in0, name="ADD") | ||
|
||
model = ov.Model([op0, op1], [in0, in1], model_name) | ||
|
||
for idx, inp in enumerate(model.inputs): | ||
print(f"Input {idx}: {inp.get_names()} {inp.get_shape()} {inp.get_index()}") | ||
print(model.outputs) | ||
for idx, out in enumerate(model.outputs): | ||
print(f"Output {idx}: {out.get_names()} {out.get_shape()} {out.get_index()} ") | ||
assert len(out.get_names()) == 0, "number of output names should be 0" | ||
|
||
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") | ||
|
||
ov_model = ov.Core().read_model(model_version_dir + "/model.xml") | ||
compiled_model = ov.Core().compile_model(model, "CPU") | ||
|
||
input_data = np.ones((1, 10),dtype=np.int8)*10 | ||
results = compiled_model({"input1": input_data, "input2": input_data}) | ||
assert np.all(results[0] == 100), "for inputs np.ones((1, 10), the expected output is 100 in every element: 10*10" | ||
assert np.all(results[1] == 20), "for inputs np.ones((1, 10), the expected output is 20 in every element: 10+10" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this change required?