Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inference Engine API 1.0 leftovers #22667

Merged
merged 18 commits into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cmake/templates/openvino.pc.in
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ exec_prefix=${prefix}/@OV_CPACK_RUNTIMEDIR@
libdir=${exec_prefix}

include_prefix=${prefix}/@OV_CPACK_INCLUDEDIR@
includedir_new=${include_prefix}
includedir=${include_prefix}

Name: OpenVINO
Description: OpenVINO™ Toolkit
URL: https://docs.openvino.ai/latest/index.html
Version: @OpenVINO_VERSION@
Conflicts: openvino < @OpenVINO_VERSION@
Cflags: -I${includedir_new} @PKGCONFIG_OpenVINO_DEFINITIONS@
Cflags: -I${includedir} @PKGCONFIG_OpenVINO_DEFINITIONS@
Libs: -L${libdir} @PKGCONFIG_OpenVINO_FRONTENDS@ -lopenvino_c -lopenvino @PKGCONFIG_OpenVINO_PRIVATE_DEPS@
Libs.private: -ldl -lm -lpthread -lrt
2 changes: 1 addition & 1 deletion src/cmake/openvino.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ if(ENABLE_PLUGINS_XML)
${OV_CPACK_COMP_CORE_EXCLUDE_ALL})

if(ENABLE_TESTS)
# for InferenceEngineUnitTest
# for ov_inference_unit_tests
install(FILES $<TARGET_FILE_DIR:${TARGET_NAME}>/plugins.xml
DESTINATION tests COMPONENT tests EXCLUDE_FROM_ALL)
endif()
Expand Down
2 changes: 1 addition & 1 deletion src/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ if(ON)
set(MIXED_SRC
"${CMAKE_CURRENT_SOURCE_DIR}/src/runtime/allocator.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/runtime/itensor.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/runtime/ov_tensor.cpp")
"${CMAKE_CURRENT_SOURCE_DIR}/src/runtime/tensor.cpp")

set_property(SOURCE ${MIXED_SRC}
APPEND PROPERTY INCLUDE_DIRECTORIES
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// SPDX-License-Identifier: Apache-2.0
//

#include "openvino/runtime/tensor.hpp"

#include <numeric>

#include "openvino/core/except.hpp"
Expand All @@ -12,7 +14,6 @@
#include "openvino/runtime/itensor.hpp"
#include "openvino/runtime/make_tensor.hpp"
#include "openvino/runtime/remote_tensor.hpp"
#include "openvino/runtime/tensor.hpp"

namespace ov {

Expand Down
2 changes: 1 addition & 1 deletion src/inference/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ target_include_directories(${TARGET_NAME}_obj PRIVATE
target_link_libraries(${TARGET_NAME}_obj PRIVATE openvino::itt openvino::util openvino::core::dev)
ov_mark_target_as_cc(${TARGET_NAME}_obj)

# IE is public API => need to mark this library as important for ABI free
# OpenVINO Runtime is public API => need to mark this library as important for ABI free
ov_abi_free_target(${TARGET_NAME}_obj)

ov_set_threading_interface_for(${TARGET_NAME}_obj)
Expand Down
4 changes: 0 additions & 4 deletions src/inference/dev_api/openvino/runtime/icompiled_model.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,6 @@ class OPENVINO_RUNTIME_API ICompiledModel : public std::enable_shared_from_this<

friend ov::CoreImpl;

// FIXME: Remove after removing IE API
std::vector<std::shared_ptr<const ov::Node>> _parameters;
std::vector<std::shared_ptr<const ov::Node>> _results;

protected:
/**
* @brief Method creates infer request implementation
Expand Down
2 changes: 0 additions & 2 deletions src/inference/dev_api/openvino/runtime/icore.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,6 @@ class OPENVINO_RUNTIME_API ICore {
*/
virtual ov::SoPtr<ov::IRemoteContext> create_context(const std::string& device_name, const AnyMap& args) const = 0;

virtual bool is_new_api() const = 0;

/**
* @brief Get a pointer to default shared context object for the specified device.
* @param device_name - A name of a device to get create shared context from.
Expand Down
7 changes: 0 additions & 7 deletions src/inference/dev_api/openvino/runtime/iplugin.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,12 +206,6 @@ class OPENVINO_RUNTIME_API IPlugin : public std::enable_shared_from_this<IPlugin
*/
std::shared_ptr<ov::ICore> get_core() const;

/**
* @brief Provides an information about used API
* @return true if new API is used
*/
bool is_new_api() const;

/**
* @brief Gets reference to tasks execution manager
* @return Reference to ExecutorManager interface
Expand All @@ -228,7 +222,6 @@ class OPENVINO_RUNTIME_API IPlugin : public std::enable_shared_from_this<IPlugin
std::weak_ptr<ov::ICore> m_core; //!< A pointer to ICore interface
std::shared_ptr<ov::threading::ExecutorManager> m_executor_manager; //!< A tasks execution manager
ov::Version m_version; //!< Member contains plugin version
bool m_is_new_api; //!< A flag which shows used API
};

/**
Expand Down
121 changes: 4 additions & 117 deletions src/inference/dev_api/openvino/runtime/performance_heuristics.hpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
// Copyright (C) 2018-2023 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//

#pragma once

#include <cfloat>
#include <memory>

#include "openvino/runtime/common.hpp"
#include "openvino/core/model.hpp"
#include "transformations/utils/utils.hpp"

Expand All @@ -24,124 +26,9 @@ struct MemBandwidthPressure {
static constexpr float LIMITED = 0.5f; // conservatively assume 1/2 utilization of the cache
};

static MemBandwidthPressure mem_bandwidth_pressure_tolerance(
OPENVINO_RUNTIME_API MemBandwidthPressure mem_bandwidth_pressure_tolerance(
ilya-lavrenov marked this conversation as resolved.
Show resolved Hide resolved
const std::shared_ptr<ov::Model> model,
const float cache_size,
const float memThresholdAssumeLimited = MemBandwidthPressure::LIMITED) {
int total_convs = 0, mem_limited_convs = 0, compute_convs = 0, total_gemms = 0, mem_limited_gemms = 0,
total_deconvs = 0, compute_deconvs = 0, mem_limited_deconvs = 0;
auto memLimitedFactor = [&](size_t size_data_moved, int datatype_size = 4) -> float {
return (cache_size / (size_data_moved * datatype_size));
};
auto isLowPrecision = [&](ov::element::Type type) -> bool {
return (type == ov::element::i8) || (type == ov::element::u8);
};
auto isHalfPrecision = [&](ov::element::Type type) -> bool {
return (type == ov::element::bf16) || (type == ov::element::f16);
};

float worst_case = MemBandwidthPressure::UNKNOWN;
// Traverse OpenVINO Model in topological order
for (auto& node : model->get_ordered_ops()) {
const auto node_name = node->get_type_info().name;
if (std::strcmp("MatMul", node_name) && std::strcmp("Convolution", node_name) &&
std::strcmp("ConvolutionBackpropData", node_name)) {
if (!std::strcmp("GRUSequence", node_name) || !std::strcmp("TensorIterator", node_name)) {
MemBandwidthPressure res;
res.max_mem_tolerance = MemBandwidthPressure::UNKNOWN;
return res;
}
continue;
}
auto type1 = node->input_value(1).get_element_type(); // weights
const bool isINT8 = isLowPrecision(type1);
const bool isBF16orFP16 = isHalfPrecision(type1);
const int data_type_size = isINT8 ? 1 : isBF16orFP16 ? 2 : 4;

size_t dataSizeInput = 0, dataSizeOutput = 0;
if (!std::strcmp("MatMul", node_name)) {
const auto input0 = node->input(0);
const auto input1 = node->input(1);
const auto output = node->output(0);
// Check that input and output shape a fully defined (not dynamic)
if (input0.get_partial_shape().is_static() && input1.get_partial_shape().is_static() &&
output.get_partial_shape().is_static()) {
const auto& shapeInput0 = input0.get_shape();
const auto& shapeInput1 = input1.get_shape();
const auto non_const = !ov::op::util::is_on_constant_path(node->input_value(1));
const auto& shapeOutput = output.get_shape();
const auto dataSizeInput0 =
std::accumulate(shapeInput0.begin(), shapeInput0.end(), size_t(1), std::multiplies<size_t>());
const auto dataSizeInput1 =
std::accumulate(shapeInput1.begin(), shapeInput1.end(), size_t(1), std::multiplies<size_t>());
dataSizeOutput =
std::accumulate(shapeOutput.begin(), shapeOutput.end(), size_t(1), std::multiplies<size_t>());
const auto total_data = dataSizeInput0 + non_const * dataSizeInput1 + dataSizeOutput;
total_gemms++;
const auto factor = memLimitedFactor(total_data, data_type_size);
mem_limited_gemms += factor < memThresholdAssumeLimited;
worst_case = std::min(factor, worst_case);
}
} else if (!std::strcmp("Convolution", node_name)) {
// Check that input and output shape a fully defined (not dynamic)
const auto input = node->input(0);
const auto output = node->output(0);
const auto kernels = node->input(1);

total_convs++;
if (kernels.get_partial_shape().is_static()) {
const auto& shape = kernels.get_shape();
if (shape.size() >= 4 /* conventional 2D/3D conv */ && shape[2] >= 3 && shape[3] >= 3) {
compute_convs++;
continue;
}
}
if (input.get_partial_shape().is_static() && output.get_partial_shape().is_static()) {
const auto& shapeInput = input.get_shape();
const auto& shapeOutput = output.get_shape();
if (shapeInput.size() > 4 /*5D*/ && isINT8) {
compute_convs++;
continue;
}
dataSizeInput =
std::accumulate(shapeInput.begin(), shapeInput.end(), size_t(1), std::multiplies<size_t>());
dataSizeOutput =
std::accumulate(shapeOutput.begin(), shapeOutput.end(), size_t(1), std::multiplies<size_t>());
const auto factor = memLimitedFactor(static_cast<int>(dataSizeInput + dataSizeOutput), data_type_size);
mem_limited_convs += factor < memThresholdAssumeLimited;
worst_case = std::min(factor, worst_case);
}
} else if (!std::strcmp("ConvolutionBackpropData", node_name)) {
const auto input = node->input(0);
const auto output = node->output(0);
total_deconvs++;

// Check that input and output shape a fully defined (not dynamic)
if (input.get_partial_shape().is_static() && output.get_partial_shape().is_static()) {
const auto shapeInput = input.get_shape();
const auto shapeOutput = output.get_shape();
if (shapeInput.size() > 4 /*5D*/ && isINT8) {
compute_deconvs++;
continue;
}
dataSizeInput =
std::accumulate(shapeInput.begin(), shapeInput.end(), size_t(1), std::multiplies<size_t>());
dataSizeOutput =
std::accumulate(shapeOutput.begin(), shapeOutput.end(), size_t(1), std::multiplies<size_t>());
const auto factor = memLimitedFactor(static_cast<int>(dataSizeInput + dataSizeOutput), data_type_size);
mem_limited_deconvs += factor < memThresholdAssumeLimited;
worst_case = std::min(factor, worst_case);
}
}
}
MemBandwidthPressure res;
res.max_mem_tolerance = worst_case;
res.ratio_mem_limited_convs = total_convs ? static_cast<float>(mem_limited_convs) / total_convs : 0;
res.ratio_mem_limited_deconvs = total_deconvs ? static_cast<float>(mem_limited_deconvs) / total_deconvs : 0;
res.ratio_mem_limited_gemms = total_gemms ? static_cast<float>(mem_limited_gemms) / total_gemms : 0;
res.ratio_compute_convs = total_convs ? static_cast<float>(compute_convs) / total_convs : 0;
res.ratio_compute_deconvs = total_deconvs ? static_cast<float>(compute_deconvs) / total_deconvs : 0;
return res;
}
const float memThresholdAssumeLimited = MemBandwidthPressure::LIMITED);

} // namespace ov
27 changes: 0 additions & 27 deletions src/inference/src/any_copy.cpp

This file was deleted.

18 changes: 0 additions & 18 deletions src/inference/src/any_copy.hpp

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
//

/**
* @brief This is a header file for the Inference Engine Cache Manager class C++ API
* @brief This is a header file for the OpenVINO Cache Manager class C++ API
*
* @file ie_cache_manager.hpp
* @file cache_manager.hpp
*/
#pragma once

Expand Down Expand Up @@ -35,38 +35,38 @@ class ICacheManager {
*/
using StreamWriter = std::function<void(std::ostream&)>;
/**
* @brief Callback when Inference Engine intends to write network to cache
* @brief Callback when OpenVINO intends to write model to cache
*
* Client needs to call create std::ostream object and call writer(ostream)
* Otherwise, network will not be cached
* Otherwise, model will not be cached
*
* @param id Id of cache (hash of the network)
* @param id Id of cache (hash of the model)
* @param writer Lambda function to be called when stream is created
*/
virtual void write_cache_entry(const std::string& id, StreamWriter writer) = 0;

/**
* @brief Function passing created input stream
*
*/
using StreamReader = std::function<void(std::istream&)>;

/**
* @brief Callback when Inference Engine intends to read network from cache
* @brief Callback when OpenVINO intends to read model from cache
*
* Client needs to call create std::istream object and call reader(istream)
* Otherwise, network will not be read from cache and will be loaded as usual
* Otherwise, model will not be read from cache and will be loaded as usual
*
* @param id Id of cache (hash of the network)
* @param id Id of cache (hash of the model)
* @param reader Lambda function to be called when input stream is created
*/
virtual void read_cache_entry(const std::string& id, StreamReader reader) = 0;

/**
* @brief Callback when Inference Engine intends to remove cache entry
* @brief Callback when OpenVINO intends to remove cache entry
*
* Client needs to perform appropriate cleanup (e.g. delete a cache file)
*
* @param id Id of cache (hash of the network)
* @param id Id of cache (hash of the model)
*/
virtual void remove_cache_entry(const std::string& id) = 0;
};
Expand Down
1 change: 1 addition & 0 deletions src/inference/src/check_network_batchable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#pragma once

#include <memory>
#include <string>

#include "openvino/core/model.hpp"

Expand Down
1 change: 0 additions & 1 deletion src/inference/src/compilation_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,6 @@ std::istream& operator>>(std::istream& stream, CompiledBlobHeader& header) {

pugi::xml_document document;
pugi::xml_parse_result res = document.load_string(xmlStr.c_str());

OPENVINO_ASSERT(res.status == pugi::status_ok, "Error reading compiled blob header");

pugi::xml_node compiledBlobNode = document.document_element();
Expand Down
Loading
Loading