Skip to content

Commit

Permalink
Merge branch 'master' into itikhono/ts/strided_slice
Browse files Browse the repository at this point in the history
  • Loading branch information
itikhono authored Oct 6, 2023
2 parents 97eb153 + 5764b5c commit d1b227a
Show file tree
Hide file tree
Showing 100 changed files with 914 additions and 871 deletions.
4 changes: 2 additions & 2 deletions .github/github_org_control/configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
from pathlib import Path


if sys.version_info[:2] < (3, 7):
raise Exception("Python version must be >= 3.7")
if sys.version_info[:2] < (3, 8):
raise Exception("Python version must be >= 3.8")


class ConfigException(Exception):
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/py_checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.7'
python-version: '3.8'

- name: Install dependencies
run: python -m pip install -r src/bindings/python/requirements_test.txt
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
clang==11.1.0; python_version == '3.7'
clang==12.0.1; python_version == '3.8'
clang==12.0.1; python_version == '3.9'
clang==14.0; python_version == '3.10'
Expand Down
2 changes: 1 addition & 1 deletion scripts/setupvars/setupvars.bat
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ set "PATH=%OPENVINO_LIB_PATHS%;%PATH%"

:: Check if Python is installed
set PYTHON_VERSION_MAJOR=3
set MIN_REQUIRED_PYTHON_VERSION_MINOR=7
set MIN_REQUIRED_PYTHON_VERSION_MINOR=8
set MAX_SUPPORTED_PYTHON_VERSION_MINOR=11

python --version 2>NUL
Expand Down
2 changes: 1 addition & 1 deletion scripts/setupvars/setupvars.sh
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ if command -v lsb_release >/dev/null 2>&1; then
fi

PYTHON_VERSION_MAJOR="3"
MIN_REQUIRED_PYTHON_VERSION_MINOR="7"
MIN_REQUIRED_PYTHON_VERSION_MINOR="8"
MAX_SUPPORTED_PYTHON_VERSION_MINOR="11"

check_python_version () {
Expand Down
6 changes: 3 additions & 3 deletions src/bindings/python/src/compatibility/ngraph/utils/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,16 +105,16 @@ def get_dtype(ngraph_type: NgraphType) -> np.dtype:

def get_ndarray(data: NumericData) -> np.ndarray:
"""Wrap data into a numpy ndarray."""
if type(data) == np.ndarray:
if isinstance(data, np.ndarray):
return data
return np.array(data)


def get_shape(data: NumericData) -> TensorShape:
"""Return a shape of NumericData."""
if type(data) == np.ndarray:
if isinstance(data, np.ndarray):
return data.shape # type: ignore
elif type(data) == list:
if isinstance(data, list):
return [len(data)] # type: ignore
return []

Expand Down
6 changes: 3 additions & 3 deletions src/bindings/python/src/openvino/runtime/utils/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,16 +121,16 @@ def get_numpy_ctype(openvino_type: Type) -> type:

def get_ndarray(data: NumericData) -> np.ndarray:
"""Wrap data into a numpy ndarray."""
if type(data) == np.ndarray:
if isinstance(data, np.ndarray):
return data # type: ignore
return np.array(data)


def get_shape(data: NumericData) -> TensorShape:
"""Return a shape of NumericData."""
if type(data) == np.ndarray:
if isinstance(data, np.ndarray):
return data.shape # type: ignore
elif type(data) == list:
if isinstance(data, list):
return [len(data)] # type: ignore
return []

Expand Down
5 changes: 1 addition & 4 deletions src/bindings/python/src/openvino/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,7 @@ def _add_openvino_libs_to_search_path() -> None:
lib_path = os.path.join(os.path.dirname(__file__), lib)
if os.path.isdir(lib_path):
# On Windows, with Python >= 3.8, DLLs are no longer imported from the PATH.
if (3, 8) <= sys.version_info:
os.add_dll_directory(os.path.abspath(lib_path))
else:
os.environ["PATH"] = os.path.abspath(lib_path) + ";" + os.environ["PATH"]
os.add_dll_directory(os.path.abspath(lib_path))


def add_openvino_libs_to_path() -> None:
Expand Down
4 changes: 2 additions & 2 deletions src/bindings/python/tests/test_graph/test_any.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ def test_any_dict(value_dict, value_type, data_type):
assert isinstance(ovany.value, dict)
assert ovany[key] == list(value_dict.values())[0]
assert len(ovany.value) == 1
assert type(ovany.value[key]) == value_type
assert type(list(value_dict.values())[0]) == data_type
assert isinstance(ovany.value[key], value_type)
assert isinstance(list(value_dict.values())[0], data_type)
assert ovany.get() == value_dict


Expand Down
2 changes: 1 addition & 1 deletion src/bindings/python/tests/test_graph/test_if.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ def test_simple_if_basic():
if_node.set_function(0, then_body)
subgraph_func = if_node.get_function(0)

assert type(subgraph_func) == type(then_body)
assert isinstance(subgraph_func, type(then_body))
assert compare_models(subgraph_func, then_body)
assert subgraph_func._get_raw_address() == then_body._get_raw_address()

Expand Down
2 changes: 1 addition & 1 deletion src/bindings/python/tests/test_graph/test_loop.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def test_loop_basic():

subgraph_func = loop.get_function()

assert type(subgraph_func) == type(graph_body)
assert isinstance(subgraph_func, type(graph_body))
assert subgraph_func._get_raw_address() == graph_body._get_raw_address()
assert compare_models(subgraph_func, graph_body)
assert loop.get_special_body_ports() == body_ports
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def test_tensor_iterator_basic():

subgraph_func = ti.get_function()

assert type(subgraph_func) == type(graph_body)
assert isinstance(subgraph_func, type(graph_body))
assert compare_models(subgraph_func, graph_body)
assert subgraph_func._get_raw_address() == graph_body._get_raw_address()
assert ti.get_num_iterations() == 16
Expand Down
2 changes: 1 addition & 1 deletion src/bindings/python/tests/test_runtime/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ def test_evaluate_invalid_input_shape():
[Tensor("float32", Shape([2, 1]))],
[Tensor("float32", Shape([3, 1])), Tensor("float32", Shape([3, 1]))],
)
assert "must be compatible with the partial shape: [2,1]" in str(e.value)
assert "Cannot evaluate model!" in str(e.value)


def test_get_batch():
Expand Down
16 changes: 8 additions & 8 deletions src/bindings/python/tests/test_runtime/test_properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ def test_single_property_setting(device):
core.set_property(device, streams.num(streams.Num.AUTO))

assert props.streams.Num.AUTO.to_integer() == -1
assert type(core.get_property(device, streams.num())) == int
assert isinstance(core.get_property(device, streams.num()), int)


@pytest.mark.skipif(os.environ.get("TEST_DEVICE", "CPU") != "CPU", reason=f"Cannot run test on device {os.environ.get('TEST_DEVICE')}, Plugin specific test")
Expand Down Expand Up @@ -539,10 +539,10 @@ def test_core_cpu_properties(properties_to_set):
assert core.get_property("CPU", streams.num) == 5

# RO properties
assert type(core.get_property("CPU", props.supported_properties)) == dict
assert type(core.get_property("CPU", props.available_devices)) == list
assert type(core.get_property("CPU", props.optimal_number_of_infer_requests)) == int
assert type(core.get_property("CPU", props.range_for_streams)) == tuple
assert type(core.get_property("CPU", props.range_for_async_infer_requests)) == tuple
assert type(core.get_property("CPU", device.full_name)) == str
assert type(core.get_property("CPU", device.capabilities)) == list
assert isinstance(core.get_property("CPU", props.supported_properties), dict)
assert isinstance(core.get_property("CPU", props.available_devices), list)
assert isinstance(core.get_property("CPU", props.optimal_number_of_infer_requests), int)
assert isinstance(core.get_property("CPU", props.range_for_streams), tuple)
assert isinstance(core.get_property("CPU", props.range_for_async_infer_requests), tuple)
assert isinstance(core.get_property("CPU", device.full_name), str)
assert isinstance(core.get_property("CPU", device.capabilities), list)
2 changes: 1 addition & 1 deletion src/bindings/python/wheel/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ def set_rpath(rpath, binary):
log.warn(f"WARNING: {binary}: missed ELF header")
return
rpath_tool = "patchelf"
cmd = [rpath_tool, "--set-rpath", rpath, binary]
cmd = [rpath_tool, "--set-rpath", rpath, binary, "--force-rpath"]
elif sys.platform == "darwin":
rpath_tool = "install_name_tool"
cmd = [rpath_tool, "-add_rpath", rpath, binary]
Expand Down
33 changes: 32 additions & 1 deletion src/core/dev_api/validation_util.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,17 @@

#pragma once

#include "openvino/core/node.hpp"
#include "openvino/core/coordinate_diff.hpp"
#include "openvino/core/core_visibility.hpp"
#include "openvino/core/partial_shape.hpp"
#include "openvino/core/shape.hpp"
#include "openvino/core/strides.hpp"
#include "openvino/op/constant.hpp"
#include "openvino/op/util/attr_types.hpp"

namespace ov {
namespace util {

/// \brief Normalize value to the max if value is negative.
///
/// \param value Input value to normalize.
Expand Down Expand Up @@ -47,5 +54,29 @@ OPENVINO_API std::shared_ptr<op::v0::Constant> constantfold_subgraph(const Outpu
* @return Shared pointer to constant data or nullptr.
*/
OPENVINO_API std::shared_ptr<op::v0::Constant> get_constant_from_source(const Output<Node>& source);

/// \brief Apply auto padding to padding_above and padding_below inputs
/// if all needed informations are known.
///
/// \param image_shape The shape of input image.
/// \param filter_shape The shape of filter input.
/// \param filter_strides The strides of applied padding.
/// \param filter_dilations The dilations of applied padding.
/// \param pad_type The type of padding. Auto padding is applied only
/// for SAME_UPPER and SAME_LOWER mode.
/// \param padding_above The beginning of padding shape.
/// \param end The beginning of padding shape.
///
/// \return true if auto padding was applied successfully (all needed informations such as
/// spatial dims are known), false otherwise.
OPENVINO_API
bool try_apply_auto_padding(const PartialShape& image_shape,
const Shape& filter_shape,
const Strides& filter_strides,
const Strides& filter_dilations,
const op::PadType pad_type,
CoordinateDiff& padding_above,
CoordinateDiff& padding_below);

} // namespace util
} // namespace ov
4 changes: 1 addition & 3 deletions src/core/include/openvino/op/constant.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,7 @@ class OPENVINO_API Constant : public Op {

bool visit_attributes(AttributeVisitor& visitor) override;

OPENVINO_SUPPRESS_DEPRECATED_START
bool evaluate(const HostTensorVector& outputs, const HostTensorVector& inputs) const override;
OPENVINO_SUPPRESS_DEPRECATED_END
bool evaluate(ov::TensorVector& outputs, const ov::TensorVector& inputs) const override;
bool has_evaluate() const override;
bool evaluate_lower(TensorVector& outputs) const override;
bool evaluate_upper(TensorVector& outputs) const override;
Expand Down
6 changes: 2 additions & 4 deletions src/core/include/openvino/op/reshape.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,7 @@ class OPENVINO_API Reshape : public Op {
void set_special_zero(bool special_zero) {
m_special_zero = special_zero;
}
OPENVINO_SUPPRESS_DEPRECATED_START
bool evaluate(const HostTensorVector& outputs, const HostTensorVector& inputs) const override;
OPENVINO_SUPPRESS_DEPRECATED_END
bool evaluate(ov::TensorVector& outputs, const ov::TensorVector& inputs) const override;
bool has_evaluate() const override;
bool evaluate_upper(TensorVector& outputs) const override;
bool evaluate_lower(TensorVector& outputs) const override;
Expand All @@ -57,7 +55,7 @@ class OPENVINO_API Reshape : public Op {

protected:
bool m_special_zero;
bool evaluate_reshape(const HostTensorVector& outputs, const HostTensorVector& inputs) const;
bool evaluate_reshape(ov::TensorVector& outputs, const ov::TensorVector& inputs) const;

private:
void calculate_output_shape(std::vector<Dimension>& reshape_pattern,
Expand Down
4 changes: 1 addition & 3 deletions src/core/include/openvino/op/result.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ class OPENVINO_API Result : public Op {

std::shared_ptr<Node> clone_with_new_inputs(const OutputVector& new_args) const override;

OPENVINO_SUPPRESS_DEPRECATED_START
bool evaluate(const HostTensorVector& outputs, const HostTensorVector& inputs) const override;
OPENVINO_SUPPRESS_DEPRECATED_END
bool evaluate(ov::TensorVector& outputs, const ov::TensorVector& inputs) const override;
bool has_evaluate() const override;
bool constant_fold(OutputVector& output_values, const OutputVector& inputs_values) override;

Expand Down
6 changes: 0 additions & 6 deletions src/core/include/openvino/op/tile.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,11 @@ class OPENVINO_API Tile : public Op {

std::shared_ptr<Node> clone_with_new_inputs(const OutputVector& new_args) const override;

OPENVINO_SUPPRESS_DEPRECATED_START
bool evaluate(const HostTensorVector& outputs, const HostTensorVector& inputs) const override;
OPENVINO_SUPPRESS_DEPRECATED_END
bool evaluate_lower(TensorVector& outputs) const override;
bool evaluate_upper(TensorVector& outputs) const override;
bool has_evaluate() const override;
bool evaluate(ov::TensorVector& output_values, const ov::TensorVector& input_values) const override;
bool evaluate_label(TensorLabelVector& output_labels) const override;

private:
bool evaluate_tile(const HostTensorVector& outputs, const HostTensorVector& inputs) const;
};
} // namespace v0
} // namespace op
Expand Down
6 changes: 3 additions & 3 deletions src/core/src/itt.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,21 +50,21 @@ OV_CC_DOMAINS(ov_opset);
# define INSERT_OP(opset_name, op_name, op_namespace) opset.insert<op_namespace::op_name>()
#endif

#define NGRAPH_TYPE_CASE(region, a, ...) \
#define OPENVINO_TYPE_CASE(region, a, ...) \
case ov::element::Type_t::a: { \
OV_SCOPE(ov_op, OV_PP_CAT3(region, _, a)) { \
rc = evaluate<ov::element::Type_t::a>(__VA_ARGS__); \
} \
} break

#define NGRAPH_2_TYPES_CASE(region, a, b, ...) \
#define OPENVINO_2_TYPES_CASE(region, a, b, ...) \
case element::Type_t::a: { \
OV_SCOPE(ov_op, OV_PP_CAT4(region, _, a, b)) { \
rc = evaluate<element::Type_t::a, element::Type_t::b>(__VA_ARGS__); \
} \
} break

#define NGRAPH_COPY_TENSOR(region, a, ...) \
#define OPENVINO_COPY_TENSOR(region, a, ...) \
case ov::element::Type_t::a: { \
OV_SCOPE(ov_op, OV_PP_CAT3(region, _, a)) { \
rc = copy_tensor<ov::element::Type_t::a>(__VA_ARGS__); \
Expand Down
13 changes: 12 additions & 1 deletion src/core/src/model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -516,8 +516,19 @@ bool ov::Model::evaluate(ov::TensorVector& output_tensors,
ov::EvaluationContext& evaluation_context) const {
evaluation_context.emplace("VariableContext", ov::op::util::VariableContext());
std::map<RawNodeOutput, ov::Tensor> value_map;
OPENVINO_ASSERT(input_tensors.size() == m_parameters.size(),
"Cannot evaluate model! Number of tensors (",
input_tensors.size(),
") is not equal to number of parameters (",
m_parameters.size(),
").");
for (size_t i = 0; i < m_parameters.size(); ++i) {
value_map[m_parameters.at(i)->output(0)] = input_tensors.at(i);
OPENVINO_ASSERT(m_parameters.at(i)->get_partial_shape().is_dynamic() ||
m_parameters.at(i)->get_partial_shape().to_shape() == input_tensors[i].get_shape(),
"Cannot evaluate model! Tensor input shape and Parameter op with index ",
i,
" are mismatches.");
}
OutputVector outputs;
std::map<RawNodeOutput, ov::Tensor> output_tensor_map;
Expand Down Expand Up @@ -554,7 +565,7 @@ bool ov::Model::evaluate(ov::TensorVector& output_tensors,
}
return output_tensors;
} else {
OPENVINO_ASSERT(false, "Evaluation failed on ", node);
OPENVINO_THROW("Evaluation failed on ", node);
}
});
for (const auto& value : outputs) {
Expand Down
3 changes: 1 addition & 2 deletions src/core/src/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0
//

#include "ngraph/node.hpp"
#include "openvino/core/node.hpp"

#include <memory>
#include <sstream>
Expand All @@ -12,7 +12,6 @@
#include "atomic_guard.hpp"
#include "bound_evaluate.hpp"
#include "itt.hpp"
#include "ngraph/graph_util.hpp"
#include "openvino/core/descriptor/input.hpp"
#include "openvino/core/rt_info.hpp"
#include "openvino/core/shape_util.hpp"
Expand Down
2 changes: 1 addition & 1 deletion src/core/src/op/binary_convolution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ void ov::op::v1::BinaryConvolution::validate_and_infer_types() {
"Data batch element type must be numeric. Got: ",
data_batch_et);

// TODO: Add NodeValidationCheck to filters et once u1 is supported in nGraph Python API
// TODO: Add NodeValidationCheck to filters et once u1 is supported in OpenVINO Python API
// (#52715)
OPENVINO_SUPPRESS_DEPRECATED_START
const auto input_shapes = get_node_input_partial_shapes(*this);
Expand Down
Loading

0 comments on commit d1b227a

Please sign in to comment.