Fixed fuzzer issues (#4553)
* Fixed code style * Revert redundant code * Fixed fuzzer issues
This commit is contained in:
parent
d4c5cb2375
commit
77e80ddbb3
@ -7,7 +7,6 @@
|
|||||||
|
|
||||||
#include <details/ie_so_pointer.hpp>
|
#include <details/ie_so_pointer.hpp>
|
||||||
#include <file_utils.h>
|
#include <file_utils.h>
|
||||||
#include <ie_blob_stream.hpp>
|
|
||||||
#include <ie_reader.hpp>
|
#include <ie_reader.hpp>
|
||||||
#include <ie_ir_version.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
|
// Register readers if it is needed
|
||||||
registerReaders();
|
registerReaders();
|
||||||
std::istringstream modelStream(model);
|
std::istringstream modelStream(model);
|
||||||
details::BlobStream binStream(weights);
|
|
||||||
|
|
||||||
assertIfIRv7LikeModel(modelStream);
|
assertIfIRv7LikeModel(modelStream);
|
||||||
|
|
||||||
|
@ -11,11 +11,8 @@ target_include_directories(${TARGET_NAME} INTERFACE
|
|||||||
$<TARGET_PROPERTY:inference_engine,INTERFACE_INCLUDE_DIRECTORIES>)
|
$<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_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})
|
||||||
|
|
||||||
add_cpplint_target(${TARGET_NAME}_cpplint FOR_SOURCES ${reader_api_hpp} ${reader_api_src})
|
|
||||||
|
|
||||||
add_subdirectory(ir_reader)
|
add_subdirectory(ir_reader)
|
||||||
add_subdirectory(ir_reader_v7)
|
add_subdirectory(ir_reader_v7)
|
||||||
|
@ -29,7 +29,6 @@
|
|||||||
#include <ie_ngraph_utils.hpp>
|
#include <ie_ngraph_utils.hpp>
|
||||||
#include "blob_factory.hpp"
|
#include "blob_factory.hpp"
|
||||||
#include "caseless.hpp"
|
#include "caseless.hpp"
|
||||||
#include "ie_blob_stream.hpp"
|
|
||||||
#include "precision_utils.h"
|
#include "precision_utils.h"
|
||||||
|
|
||||||
using namespace XMLParseUtils;
|
using namespace XMLParseUtils;
|
||||||
|
@ -5,7 +5,6 @@
|
|||||||
#include <file_utils.h>
|
#include <file_utils.h>
|
||||||
#include <description_buffer.hpp>
|
#include <description_buffer.hpp>
|
||||||
#include <ie_cnn_net_reader_impl.h>
|
#include <ie_cnn_net_reader_impl.h>
|
||||||
#include <ie_blob_stream.hpp>
|
|
||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
|
|
||||||
#include "ie_reader.hpp"
|
#include "ie_reader.hpp"
|
||||||
#include "ie_ir_parser.hpp"
|
#include "ie_ir_parser.hpp"
|
||||||
#include "ie_blob_stream.hpp"
|
|
||||||
#include "ie_cnn_net_reader_impl.h"
|
#include "ie_cnn_net_reader_impl.h"
|
||||||
|
|
||||||
using namespace InferenceEngine;
|
using namespace InferenceEngine;
|
||||||
|
@ -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() {}
|
|
@ -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
|
|
@ -351,6 +351,8 @@ namespace ngraph
|
|||||||
std::vector<T> get_vector() const
|
std::vector<T> get_vector() const
|
||||||
{
|
{
|
||||||
const T* p = get_data_ptr<T>();
|
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));
|
return std::vector<T>(p, p + shape_size(m_shape));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,10 +53,11 @@ void op::Squeeze::pre_validate_and_infer_types()
|
|||||||
bool data_has_dynamic_shape = data.get_partial_shape().is_dynamic();
|
bool data_has_dynamic_shape = data.get_partial_shape().is_dynamic();
|
||||||
|
|
||||||
auto axes_constant = get_constant_from_source(axes_node);
|
auto axes_constant = get_constant_from_source(axes_node);
|
||||||
bool axes_is_empty_constant =
|
bool axes_is_empty_constant = (axes_constant && axes_constant->get_data_ptr() != nullptr)
|
||||||
(axes_constant) ? axes_constant->cast_vector<int64_t>().empty() : false;
|
? 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))
|
(data_has_dynamic_shape && axes_is_empty_constant))
|
||||||
{
|
{
|
||||||
set_output_type(0, get_input_element_type(0), PartialShape::dynamic());
|
set_output_type(0, get_input_element_type(0), PartialShape::dynamic());
|
||||||
|
Loading…
Reference in New Issue
Block a user