Fixed fuzzer issues (#4553)

* Fixed code style

* Revert redundant code

* Fixed fuzzer issues
This commit is contained in:
Ilya Churaev 2021-03-02 21:07:53 +03:00 committed by GitHub
parent d4c5cb2375
commit 77e80ddbb3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 9 additions and 124 deletions

View File

@ -7,7 +7,6 @@
#include <details/ie_so_pointer.hpp>
#include <file_utils.h>
#include <ie_blob_stream.hpp>
#include <ie_reader.hpp>
#include <ie_ir_version.hpp>
@ -239,7 +238,6 @@ CNNNetwork details::ReadNetwork(const std::string& model, const Blob::CPtr& weig
// Register readers if it is needed
registerReaders();
std::istringstream modelStream(model);
details::BlobStream binStream(weights);
assertIfIRv7LikeModel(modelStream);

View File

@ -11,11 +11,8 @@ target_include_directories(${TARGET_NAME} INTERFACE
$<TARGET_PROPERTY:inference_engine,INTERFACE_INCLUDE_DIRECTORIES>)
file(GLOB_RECURSE reader_api_hpp "${CMAKE_CURRENT_SOURCE_DIR}/reader_api/*.hpp")
file(GLOB_RECURSE reader_api_src "${CMAKE_CURRENT_SOURCE_DIR}/reader_api/*.cpp")
set_target_properties(${TARGET_NAME} PROPERTIES INTERFACE_SOURCES ${reader_api_src})
add_cpplint_target(${TARGET_NAME}_cpplint FOR_SOURCES ${reader_api_hpp} ${reader_api_src})
add_cpplint_target(${TARGET_NAME}_cpplint FOR_SOURCES ${reader_api_hpp})
add_subdirectory(ir_reader)
add_subdirectory(ir_reader_v7)

View File

@ -29,7 +29,6 @@
#include <ie_ngraph_utils.hpp>
#include "blob_factory.hpp"
#include "caseless.hpp"
#include "ie_blob_stream.hpp"
#include "precision_utils.h"
using namespace XMLParseUtils;
@ -1041,4 +1040,4 @@ size_t V10Parser::GenericLayerParams::getRealOutputPortId(size_t id) const {
}
THROW_IE_EXCEPTION << "Can not find output port with id " << id << " in layer " << name;
}
} // namespace InferenceEngine
} // namespace InferenceEngine

View File

@ -45,4 +45,4 @@ size_t GetIRVersion(std::istream& model) {
}
} // namespace details
} // namespace InferenceEngine
} // namespace InferenceEngine

View File

@ -5,7 +5,6 @@
#include <file_utils.h>
#include <description_buffer.hpp>
#include <ie_cnn_net_reader_impl.h>
#include <ie_blob_stream.hpp>
#include <fstream>
#include <map>

View File

@ -4,7 +4,6 @@
#include "ie_reader.hpp"
#include "ie_ir_parser.hpp"
#include "ie_blob_stream.hpp"
#include "ie_cnn_net_reader_impl.h"
using namespace InferenceEngine;

View File

@ -1,66 +0,0 @@
// Copyright (C) 2018-2020 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#include "ie_blob_stream.hpp"
#include <ie_blob.h>
#include <istream>
InferenceEngine::details::BlobStream::BlobBuffer::BlobBuffer(const InferenceEngine::Blob::CPtr& blob) {
char* data = nullptr;
std::streampos size;
if (!blob) {
size = 0;
} else {
data = blob->cbuffer().as<char*>();
size = blob->byteSize();
}
setg(data, data, data + size);
}
InferenceEngine::details::BlobStream::BlobBuffer::~BlobBuffer() {}
std::streampos InferenceEngine::details::BlobStream::BlobBuffer::seekpos(std::streampos sp, std::ios_base::openmode which) {
if (!(which & ios_base::in))
return streampos(-1);
if (sp < 0 || sp > egptr() - eback())
return streampos(-1);
setg(eback(), eback() + sp, egptr());
return sp;
}
std::streampos InferenceEngine::details::BlobStream::BlobBuffer::seekoff(std::streamoff off, std::ios_base::seekdir way, std::ios_base::openmode which) {
if (!(which & std::ios_base::in))
return streampos(-1);
switch (way) {
default:
case std::ios_base::beg:
setg(eback(), eback() + off, egptr());
break;
case std::ios_base::cur:
gbump(static_cast<int>(off));
break;
case std::ios_base::end:
setg(eback(), egptr() + off, egptr());
break;
}
return gptr() - eback();
}
InferenceEngine::Blob::CPtr InferenceEngine::details::BlobStream::getBlob() {
return blob;
}
#if defined __GNUC__
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wreorder"
#endif
InferenceEngine::details::BlobStream::BlobStream(const InferenceEngine::Blob::CPtr& blob) :
buffer(blob), std::ios(0), std::istream(&buffer), blob(blob) {}
#if defined __GNUC__
# pragma GCC diagnostic pop
#endif
InferenceEngine::details::BlobStream::~BlobStream() {}

View File

@ -1,44 +0,0 @@
// Copyright (C) 2018-2020 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#pragma once
#include <ie_blob.h>
#include <istream>
namespace InferenceEngine {
namespace details {
class BlobStream: public std::istream {
private:
class BlobBuffer: public std::streambuf {
public:
BlobBuffer(const Blob::CPtr& blob);
~BlobBuffer() override;
std::streampos seekpos(std::streampos sp, std::ios_base::openmode which) override;
std::streampos seekoff(std::streamoff off, std::ios_base::seekdir way, std::ios_base::openmode which) override;
};
#if defined __GNUC__
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wreorder"
#endif
BlobBuffer buffer;
Blob::CPtr blob;
#if defined __GNUC__
# pragma GCC diagnostic pop
#endif
public:
BlobStream(const Blob::CPtr& blob);
~BlobStream() override;
Blob::CPtr getBlob();
};
} // namespace details
} // namespace InferenceEngine

View File

@ -351,6 +351,8 @@ namespace ngraph
std::vector<T> get_vector() const
{
const T* p = get_data_ptr<T>();
if (p == nullptr)
throw std::runtime_error("Cannot create vector! Buffer is not allocated.");
return std::vector<T>(p, p + shape_size(m_shape));
}

View File

@ -53,10 +53,11 @@ void op::Squeeze::pre_validate_and_infer_types()
bool data_has_dynamic_shape = data.get_partial_shape().is_dynamic();
auto axes_constant = get_constant_from_source(axes_node);
bool axes_is_empty_constant =
(axes_constant) ? axes_constant->cast_vector<int64_t>().empty() : false;
bool axes_is_empty_constant = (axes_constant && axes_constant->get_data_ptr() != nullptr)
? axes_constant->cast_vector<int64_t>().empty()
: false;
if (data_has_dynamic_rank || !axes_constant ||
if (data_has_dynamic_rank || !axes_constant || !axes_constant->get_data_ptr() ||
(data_has_dynamic_shape && axes_is_empty_constant))
{
set_output_type(0, get_input_element_type(0), PartialShape::dynamic());