-
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?
Conversation
src/modelinstance.cpp
Outdated
try { | ||
OV_LOGGER("ov::Output<ov::Node> output: {}, output.get_any_name()", reinterpret_cast<const void*>(&output)); | ||
if (output.get_names().size() == 0) { | ||
std::unordered_set<std::string> dummy_name{"OUT_" + std::to_string(outputIndex)}; |
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.
Shouldn't we use lowercase? Isn't it a standard in input/output naming?
# 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 comment
The 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 comment
The 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.
tests/models/no_name_output.py
Outdated
|
||
input_data = np.ones((1, 10),dtype=np.int8)*10 | ||
results = compiled_model({"INPUT1": input_data, "INPUT2": input_data}) | ||
|
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.
Maybe we could have some assertion here instead of prints?
I suppose the goal of this script is to generate a model and check if it's valid. In such case checking if output looks as expected would be good.
src/modelinstance.cpp
Outdated
try { | ||
OV_LOGGER("ov::Output<ov::Node> output: {}, output.get_any_name()", reinterpret_cast<const void*>(&output)); | ||
if (output.get_names().size() == 0) { | ||
std::unordered_set<std::string> dummy_name{"OUT_" + std::to_string(outputIndex)}; | ||
output.add_names(dummy_name); |
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.
This is not logic related to "applyLayoutConfiguration". Move those changes outside of this method.
tests/models/no_name_output.py
Outdated
@@ -0,0 +1,55 @@ | |||
# | |||
# Copyright (c) 2020 Intel Corporation |
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.
Change year
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.
How does it look like for inputs without names?
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
This will likely not work on windows, see usage of getGenericFullPathForSrcTest
above
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.
the tests on windows are passing
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.
That's strange. This new variable seems to have the same purpose as all the above and yet it works without wrapping in getGenericFullPathForSrcTest
function? @rasapala can you take a look? Because to me, they all should be constructed in the same manner. Either with or without wrapper function.
<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"> |
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.
Can we use name "input_1" and "input_2" to follow the convention?
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.
yes, but this is barely a test model ;-)
@@ -305,7 +306,7 @@ static Status applyLayoutConfiguration(const ModelConfig& config, std::shared_pt | |||
} | |||
|
|||
OV_LOGGER("ov::Model: {}, model->outputs()", reinterpret_cast<void*>(model.get())); | |||
for (const ov::Output<ov::Node>& output : model->outputs()) { | |||
for (ov::Output<ov::Node>& output : model->outputs()) { |
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?
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.
yes, we are changing the outputs by adding name
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.
but not in this for loop, i dont think we need to remove const in this for loop
@@ -413,6 +414,29 @@ Status ModelInstance::loadTensors(const ModelConfig& config, bool needsToApplyLa | |||
SPDLOG_LOGGER_ERROR(modelmanager_logger, "Error during configuration validation against model"); | |||
return status; | |||
} | |||
// add output names if not present in the model |
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.
Remove comment and make function
adjustForEmptyOutputNames/addOutputNamesIfNotPresent or sth similar to operate on similar level of abstraction inthis function - see loadInputTensors/applyLayoutConfiguration etc
🛠 Summary
CVS-159002
When models have outputs without assigned names, add the name in the model initialization. The following format will be applied OUT_
🧪 Checklist
``