[SAMPLES] Add GNA library version log to speech_sample (#12411)

* [SAMPLES] Add GNA library version log to speech_sample

* [GNA] Add OV version to TLV export file

Co-authored-by: Szymon Irzabek <szymon.jakub.irzabek@intel.com>
This commit is contained in:
Krzysztof Bruniecki 2022-08-30 09:45:51 +02:00 committed by GitHub
parent 1afd8460e3
commit bc00e8885a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 53 additions and 2 deletions

View File

@ -85,6 +85,12 @@ int main(int argc, char* argv[]) {
// --------------------------- Step 1. Initialize OpenVINO Runtime core and read model
// -------------------------------------
ov::Core core;
try {
const auto& gnaLibraryVersion = core.get_property("GNA", ov::intel_gna::library_full_version);
slog::info << "Detected GNA Library: " << gnaLibraryVersion << slog::endl;
} catch (std::exception& e) {
slog::info << "Cannot detect GNA Library version, exception: " << e.what() << slog::endl;
}
slog::info << "Loading model files:" << slog::endl << FLAGS_m << slog::endl;
uint32_t batchSize = (FLAGS_cw_r > 0 || FLAGS_cw_l > 0 || !FLAGS_bs) ? 1 : (uint32_t)FLAGS_bs;
std::shared_ptr<ov::Model> model;

View File

@ -0,0 +1,23 @@
// Copyright (C) 2022 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#include "versioning.hpp"
#include <sstream>
#include <string>
#include "openvino/core/version.hpp"
namespace ov {
namespace intel_gna {
namespace common {
std::string get_openvino_version_string() {
std::stringstream s;
s << ov::get_openvino_version();
return s.str();
}
} // namespace common
} // namespace intel_gna
} // namespace ov

View File

@ -0,0 +1,14 @@
// Copyright (C) 2022 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#pragma once
#include <string>
namespace ov {
namespace intel_gna {
namespace common {
// Returns string representing current version of OpenVINO
std::string get_openvino_version_string();
} // namespace common
} // namespace intel_gna
} // namespace ov

View File

@ -10,6 +10,7 @@
#include "gna2-device-api.h"
#include "gna/gna_config.hpp"
#include "common/gna_target.hpp"
#include "common/versioning.hpp"
#include "gna2-tlv-writer.h"
@ -59,6 +60,7 @@ void * ExportSueLegacyUsingGnaApi2(
#define Gna2TlvTypeOVInputScaleFactor GNA2_TLV_IMPL_CHAR_TO_TYPE("OVIS")
#define Gna2TlvTypeOVOutputScaleFactor GNA2_TLV_IMPL_CHAR_TO_TYPE("OVOS")
#define Gna2TlvTypeOVString GNA2_TLV_IMPL_CHAR_TO_TYPE("OVSS")
#define Gna2TlvTypeOVVersion GNA2_TLV_IMPL_CHAR_TO_TYPE("OVVR")
#define Gna2ExportTlv(...) 1
static_assert(std::numeric_limits<float>::is_iec559, "Float is not IEC 559 compatible");
@ -149,6 +151,11 @@ std::string WriteAllEndpoints(std::ostream& outStream,
return stream.str();
}
void WriteStringToTlv(std::ostream& outStream, const Gna2TlvType tlvType, const std::string& value) {
const auto& valueTlv = GetStringAsTlv(tlvType, value);
outStream.write(valueTlv.data(), valueTlv.size());
}
} // namespace
void ExportTlvModel(uint32_t modelId,
@ -254,8 +261,9 @@ void ExportTlvModel(uint32_t modelId,
outStream.write(outTlv, outTlvSize);
auto metadata = WriteAllEndpoints(outStream, allInputs, Gna2TlvTypeOVInputScaleFactor, allAllocations.Get(Gna2MemoryTagInput));
metadata += WriteAllEndpoints(outStream, allOutputs, Gna2TlvTypeOVOutputScaleFactor, allAllocations.Get(Gna2MemoryTagOutput));
auto metadataTlv = GetStringAsTlv(Gna2TlvTypeOVString, metadata);
outStream.write(metadataTlv.data(), metadataTlv.size());
WriteStringToTlv(outStream, Gna2TlvTypeOVString, metadata);
const auto& ovVersionString = ov::intel_gna::common::get_openvino_version_string();
WriteStringToTlv(outStream, Gna2TlvTypeOVVersion, ovVersionString);
}
gnaUserFree(outTlv);