OpenVINO™ is an open source toolkit for optimizing and deploying AI inference
C++ aicomputer-visiondeep-learningdeploy-aidiffusion-modelsgenerative-aigood-first-issueinferencellm-inferencenatural-language-processingnlpopenvinooptimize-aiperformance-boostrecommendation-systemspeech-recognitionstable-diffusiontransformersyolo
[SIT] Add asserts for tensor size casting from unsigned to signed (#32436)
Vigh Sebastian40b3806cc46e
diff --git a/src/plugins/intel_npu/tools/single-image-test/main.cpp b/src/plugins/intel_npu/tools/single-image-test/main.cppindex 1929a9b0b5a..ede6d8ba228 100644--- a/src/plugins/intel_npu/tools/single-image-test/main.cpp+++ b/src/plugins/intel_npu/tools/single-image-test/main.cpp@@ -896,6 +896,8 @@ void loadBinary(const std::string& filePath, const BatchIndexer &fileSourceInBat}} else {if (fileBytes == reqTensorBytes) {+ OPENVINO_ASSERT(reqTensorBytes <= static_cast<size_t>(std::numeric_limits<std::streamsize>::max()),+ "Requested tensor size is too big to convert to signed streamsize: ", reqTensorBytes);binaryFile.read(reinterpret_cast<char*>(requestedTensor.data()),static_cast<std::streamsize>(reqTensorBytes));} else {@@ -974,6 +976,10 @@ ov::Tensor loadTensor(const ov::element::Type& precision, const ov::Shape& shapeOPENVINO_ASSERT(file.is_open(), "Can't open file ", filePath, " for read");const auto dataBuffer = reinterpret_cast<char*>(tensor.data());++ OPENVINO_ASSERT(tensor.get_byte_size() <= static_cast<size_t>(std::numeric_limits<std::streamsize>::max()),+ "Tensor size is too big to convert to signed streamsize: ", tensor.get_byte_size());+file.read(dataBuffer, static_cast<std::streamsize>(tensor.get_byte_size()));return tensor;@@ -984,6 +990,10 @@ void dumpTensor(const ov::Tensor& tensor, const std::string& filePath) {OPENVINO_ASSERT(file.is_open(), "Can't open file ", filePath, " for write");const auto dataBuffer = reinterpret_cast<const char*>(tensor.data());++ OPENVINO_ASSERT(tensor.get_byte_size() <= static_cast<size_t>(std::numeric_limits<std::streamsize>::max()),+ "Tensor size is too big to convert to signed streamsize: ", tensor.get_byte_size());+file.write(dataBuffer, static_cast<std::streamsize>(tensor.get_byte_size()));}