Separation Static and Dynamic operations in Subgraph Dumper serialization (#13420)

This commit is contained in:
Irina Efode 2022-10-14 12:31:00 +04:00 committed by GitHub
parent c8050d017b
commit 22d08de791
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 8 deletions

View File

@ -63,8 +63,9 @@ std::vector<SubgraphsDumper::Model> findModelsInDirs(const std::vector<std::stri
std::sort(models.begin(), models.end());
std::reverse(models.begin(), models.end());
if (!CommonTestUtils::directoryExists(FLAGS_output_folder)) {
std::string msg = "Output directory (" + FLAGS_output_folder + ") doesn't not exist!";
throw std::runtime_error(msg);
std::string msg = "Output directory (" + FLAGS_output_folder + ") doesn't not exist! The directory will be created.";
std::cout << msg << std::endl;
CommonTestUtils::createDirectoryRecursive(FLAGS_output_folder);
}
return models;
}
@ -138,7 +139,7 @@ int main(int argc, char *argv[]) {
try {
models = findModelsInDirs(dirs);
} catch (std::runtime_error& e) {
std::cout << "Try 'subgraphdumper -h' for more information" << std::endl;
std::cout << "Try 'subgraphdumper -h' for more information. \nException: " << e.what() << std::endl;
return 1;
}

View File

@ -163,17 +163,18 @@ OPCache::SerializationStatus
OPCache::serialize_function(const std::pair<std::shared_ptr<ov::Node>, LayerTestsUtils::OPInfo> &op,
const std::string &serialization_dir) {
try {
if (op.first->get_friendly_name() == "Relu_8793_cached") {
std::cout << std::endl;
}
std::cout << "Serializing function wrapping op " << op.first << std::endl;
std::cout << "Taken from model: " << op.second.source_model << std::endl;
ov::ParameterVector params;
bool is_dynamic = false;
for (size_t i = 0; i < op.first->get_input_size(); ++i) {
if (ov::op::util::is_parameter(op.first->get_input_node_ptr(i))) {
auto param = std::dynamic_pointer_cast<ov::op::v0::Parameter>(
op.first->get_input_node_shared_ptr(i));
if (param->get_partial_shape().is_dynamic()) {
is_dynamic = true;
}
params.push_back(param);
}
}
@ -186,12 +187,13 @@ OPCache::serialize_function(const std::pair<std::shared_ptr<ov::Node>, LayerTest
// TODO: How to define element type for multi-output ops
auto op_el_type = op.first->get_output_element_type(0).get_type_name();
auto current_op_folder = serialization_dir + CommonTestUtils::FileSeparator +
(is_dynamic ? "dynamic" : "static") + CommonTestUtils::FileSeparator +
op.first->get_type_info().name + CommonTestUtils::FileSeparator + op_el_type;
std::cout << current_op_folder << std::endl;
auto op_name = op.first->get_name();
std::cout << op_name << " will be serialized to " << current_op_folder << std::endl;
if (!CommonTestUtils::directoryExists(current_op_folder)) {
CommonTestUtils::createDirectoryRecursive(current_op_folder);
}
auto op_name = op.first->get_name();
std::replace(op_name.begin(), op_name.end(), '/', '_');
std::replace(op_name.begin(), op_name.end(), '\\', '_');
// TODO: Possible names collision