|
4 | 4 |
|
5 | 5 | #include "model_serializer.hpp" |
6 | 6 |
|
| 7 | +#include <chrono> |
7 | 8 | #include <cstdint> |
8 | 9 | #include <istream> |
9 | 10 | #include <regex> |
@@ -578,26 +579,41 @@ SerializedIR serializeIR( |
578 | 579 | const std::function<bool(const std::string&, const std::optional<std::string>&)>& isOptionValueSupportedByCompiler, |
579 | 580 | const bool computeModelHash, |
580 | 581 | const bool storeWeightlessCacheAttributeFlag) { |
| 582 | + const Logger& logger = Logger("serializeIR", Logger::global().level()); |
| 583 | + std::chrono::steady_clock::time_point start_time; |
| 584 | + if (logger.level() >= ov::log::Level::INFO) { |
| 585 | + start_time = std::chrono::steady_clock::now(); |
| 586 | + } |
| 587 | + |
581 | 588 | // The current instance is already a clone (or should be one), we are not modifying the original model |
582 | 589 | const std::shared_ptr<ov::Model> nonConstantModel = std::const_pointer_cast<ov::Model>(model); |
583 | | - const Logger& logger = Logger("serializeIR", Logger::global().level()); |
584 | 590 | const ov::intel_npu::ModelSerializerVersion version = |
585 | 591 | determineModelSerializerVersion(serializerVersion, isOptionValueSupportedByCompiler, nonConstantModel, logger); |
586 | 592 |
|
587 | 593 | logger.info("Model serializer version chosen by the NPU plugin: %s", |
588 | 594 | MODEL_SERIALIZER_VERSION::toString(version).c_str()); |
589 | 595 |
|
| 596 | + SerializedIR serializedIR; |
590 | 597 | switch (version) { |
591 | 598 | case ov::intel_npu::ModelSerializerVersion::NO_WEIGHTS_COPY: |
592 | | - return VCLSerializerWithoutWeightsCopy(compilerVersion, supportedOpsetVersion) |
593 | | - .serialize(nonConstantModel, computeModelHash, storeWeightlessCacheAttributeFlag); |
| 599 | + serializedIR = VCLSerializerWithoutWeightsCopy(compilerVersion, supportedOpsetVersion) |
| 600 | + .serialize(nonConstantModel, computeModelHash, storeWeightlessCacheAttributeFlag); |
| 601 | + break; |
594 | 602 | case ov::intel_npu::ModelSerializerVersion::ALL_WEIGHTS_COPY: |
595 | | - return VCLSerializerWithWeightsCopy(compilerVersion, supportedOpsetVersion) |
596 | | - .serialize(nonConstantModel, computeModelHash, storeWeightlessCacheAttributeFlag); |
| 603 | + serializedIR = VCLSerializerWithWeightsCopy(compilerVersion, supportedOpsetVersion) |
| 604 | + .serialize(nonConstantModel, computeModelHash, storeWeightlessCacheAttributeFlag); |
| 605 | + break; |
597 | 606 | default: |
598 | 607 | OPENVINO_THROW("Invalid version of model serializer determined by the utility function. Obtained the version: ", |
599 | 608 | MODEL_SERIALIZER_VERSION::toString(version)); |
600 | 609 | } |
| 610 | + |
| 611 | + logger.info( |
| 612 | + "Model serialization duration: %.2f ms", |
| 613 | + std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::steady_clock::now() - start_time).count() / |
| 614 | + 1000.0); |
| 615 | + |
| 616 | + return serializedIR; |
601 | 617 | } |
602 | 618 |
|
603 | 619 | std::string serializeIOInfo(const std::shared_ptr<const ov::Model>& model, const bool useIndices) { |
|
0 commit comments