Skip to content

Commit

Permalink
Merge branch 'master' into mvafin/pt_fe/quantize_regular_ops
Browse files Browse the repository at this point in the history
  • Loading branch information
mvafin authored Jul 21, 2023
2 parents 4bb0dc2 + 44cae12 commit 94521bd
Show file tree
Hide file tree
Showing 129 changed files with 3,604 additions and 4,859 deletions.
4 changes: 2 additions & 2 deletions cmake/developer_package/packaging/common-libraries.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ macro(ov_define_component_include_rules)
set(OV_CPACK_COMP_PYTHON_SAMPLES_EXCLUDE_ALL EXCLUDE_FROM_ALL)
# python
set(OV_CPACK_COMP_PYTHON_OPENVINO_EXCLUDE_ALL EXCLUDE_FROM_ALL)
set(OV_CPACK_COMP_PYTHON_BENCHMARK_APP_EXCLUDE_ALL ${OV_CPACK_COMP_PYTHON_OPENVINO_EXCLUDE_ALL})
set(OV_CPACK_COMP_PYTHON_OVC_EXCLUDE_ALL ${OV_CPACK_COMP_PYTHON_OPENVINO_EXCLUDE_ALL})
set(OV_CPACK_COMP_BENCHMARK_APP_EXCLUDE_ALL ${OV_CPACK_COMP_PYTHON_OPENVINO_EXCLUDE_ALL})
set(OV_CPACK_COMP_OVC_EXCLUDE_ALL ${OV_CPACK_COMP_PYTHON_OPENVINO_EXCLUDE_ALL})
# we don't pack artifacts of setup.py install, because it's called explicitly in conda / brew
# or not used at all like in cases with conan / vcpkg
set(OV_CPACK_COMP_PYTHON_OPENVINO_PACKAGE_EXCLUDE_ALL ${OV_CPACK_COMP_PYTHON_OPENVINO_EXCLUDE_ALL})
Expand Down
4 changes: 2 additions & 2 deletions cmake/developer_package/packaging/debian/debian.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,10 @@ macro(ov_define_component_include_rules)
else()
set(OV_CPACK_COMP_PYTHON_OPENVINO_PACKAGE_EXCLUDE_ALL EXCLUDE_FROM_ALL)
endif()
set(OV_CPACK_COMP_PYTHON_BENCHMARK_APP_EXCLUDE_ALL ${OV_CPACK_COMP_PYTHON_OPENVINO_PACKAGE_EXCLUDE_ALL})
set(OV_CPACK_COMP_PYTHON_OVC_EXCLUDE_ALL ${OV_CPACK_COMP_PYTHON_OPENVINO_PACKAGE_EXCLUDE_ALL})
# we don't pack python components itself, we pack artifacts of setup.py install
set(OV_CPACK_COMP_PYTHON_OPENVINO_EXCLUDE_ALL EXCLUDE_FROM_ALL)
set(OV_CPACK_COMP_BENCHMARK_APP_EXCLUDE_ALL ${OV_CPACK_COMP_PYTHON_OPENVINO_EXCLUDE_ALL})
set(OV_CPACK_COMP_OVC_EXCLUDE_ALL ${OV_CPACK_COMP_PYTHON_OPENVINO_EXCLUDE_ALL})
# we don't need wheels in Debian packages
set(OV_CPACK_COMP_PYTHON_WHEELS_EXCLUDE_ALL EXCLUDE_FROM_ALL)
# tools
Expand Down
4 changes: 2 additions & 2 deletions cmake/developer_package/packaging/nsis.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ macro(ov_define_component_include_rules)
unset(OV_CPACK_COMP_PYTHON_SAMPLES_EXCLUDE_ALL)
# python
unset(OV_CPACK_COMP_PYTHON_OPENVINO_EXCLUDE_ALL)
set(OV_CPACK_COMP_PYTHON_BENCHMARK_APP_EXCLUDE_ALL ${OV_CPACK_COMP_PYTHON_OPENVINO_EXCLUDE_ALL})
set(OV_CPACK_COMP_PYTHON_OVC_EXCLUDE_ALL ${OV_CPACK_COMP_PYTHON_OPENVINO_EXCLUDE_ALL})
set(OV_CPACK_COMP_BENCHMARK_APP_EXCLUDE_ALL ${OV_CPACK_COMP_PYTHON_OPENVINO_EXCLUDE_ALL})
set(OV_CPACK_COMP_OVC_EXCLUDE_ALL ${OV_CPACK_COMP_PYTHON_OPENVINO_EXCLUDE_ALL})
set(OV_CPACK_COMP_PYTHON_WHEELS_EXCLUDE_ALL EXCLUDE_FROM_ALL)
set(OV_CPACK_COMP_PYTHON_OPENVINO_PACKAGE_EXCLUDE_ALL EXCLUDE_FROM_ALL)
# tools
Expand Down
8 changes: 4 additions & 4 deletions cmake/developer_package/packaging/packaging.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@ macro(ov_define_component_names)
set(OV_CPACK_COMP_PYTHON_SAMPLES "python_samples")
# python
set(OV_CPACK_COMP_PYTHON_OPENVINO "pyopenvino")
set(OV_CPACK_COMP_PYTHON_BENCHMARK_APP "benchmark_app")
set(OV_CPACK_COMP_PYTHON_OVC "ovc")
set(OV_CPACK_COMP_BENCHMARK_APP "benchmark_app")
set(OV_CPACK_COMP_OVC "ovc")
set(OV_CPACK_COMP_PYTHON_OPENVINO_PACKAGE "pyopenvino_package")
set(OV_CPACK_COMP_PYTHON_WHEELS "python_wheels")
# tools
Expand Down Expand Up @@ -184,8 +184,8 @@ macro(ov_define_component_include_rules)
unset(OV_CPACK_COMP_PYTHON_SAMPLES_EXCLUDE_ALL)
# python
unset(OV_CPACK_COMP_PYTHON_OPENVINO_EXCLUDE_ALL)
unset(OV_CPACK_COMP_PYTHON_BENCHMARK_APP_EXCLUDE_ALL)
unset(OV_CPACK_COMP_PYTHON_OVC_EXCLUDE_ALL)
unset(OV_CPACK_COMP_BENCHMARK_APP_EXCLUDE_ALL)
unset(OV_CPACK_COMP_OVC_EXCLUDE_ALL)
set(OV_CPACK_COMP_PYTHON_OPENVINO_PACKAGE_EXCLUDE_ALL EXCLUDE_FROM_ALL)
unset(OV_CPACK_COMP_PYTHON_WHEELS_EXCLUDE_ALL)
# tools
Expand Down
4 changes: 2 additions & 2 deletions cmake/developer_package/packaging/rpm/rpm.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,10 @@ macro(ov_define_component_include_rules)
else()
set(OV_CPACK_COMP_PYTHON_OPENVINO_PACKAGE_EXCLUDE_ALL EXCLUDE_FROM_ALL)
endif()
set(OV_CPACK_COMP_PYTHON_BENCHMARK_APP_EXCLUDE_ALL ${OV_CPACK_COMP_PYTHON_OPENVINO_PACKAGE_EXCLUDE_ALL})
set(OV_CPACK_COMP_PYTHON_OVC_EXCLUDE_ALL ${OV_CPACK_COMP_PYTHON_OPENVINO_PACKAGE_EXCLUDE_ALL})
# we don't pack python components itself, we pack artifacts of setup.py install
set(OV_CPACK_COMP_PYTHON_OPENVINO_EXCLUDE_ALL EXCLUDE_FROM_ALL)
set(OV_CPACK_COMP_BENCHMARK_APP_EXCLUDE_ALL ${OV_CPACK_COMP_PYTHON_OPENVINO_EXCLUDE_ALL})
set(OV_CPACK_COMP_OVC_EXCLUDE_ALL ${OV_CPACK_COMP_PYTHON_OPENVINO_EXCLUDE_ALL})
# we don't need wheels in RPM packages
set(OV_CPACK_COMP_PYTHON_WHEELS_EXCLUDE_ALL EXCLUDE_FROM_ALL)
# tools
Expand Down
12 changes: 7 additions & 5 deletions cmake/templates/OpenVINOConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -419,16 +419,18 @@ macro(_ov_find_onnx_frontend_dependencies)
endmacro()

function(_ov_target_no_deprecation_error)
if(NOT MSVC)
if(NOT CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
# older macOS x86_64 does not support this linker option
if(CMAKE_CROSSCOMPILING AND NOT APPLE)
set_target_properties(${ARGV} PROPERTIES
INTERFACE_LINK_OPTIONS "-Wl,--allow-shlib-undefined")
endif()

if(CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
set(flags "-diag-warning=1786")
else()
set(flags "-Wno-error=deprecated-declarations")
endif()
if(CMAKE_CROSSCOMPILING)
set_target_properties(${ARGV} PROPERTIES
INTERFACE_LINK_OPTIONS "-Wl,--allow-shlib-undefined")
endif()

set_target_properties(${ARGV} PROPERTIES INTERFACE_COMPILE_OPTIONS ${flags})
endif()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,13 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
# 'argument': conversion from 'size_t' to 'int', possible loss of data
ie_add_compiler_flags(/wd4267)
ie_add_compiler_flags(/wd4244)
ie_add_compiler_flags(/wd4551)
endif()
if (OV_COMPILER_IS_CLANG OR CMAKE_COMPILER_IS_GNUCXX)
if(OV_COMPILER_IS_CLANG OR CMAKE_COMPILER_IS_GNUCXX)
ie_add_compiler_flags(-Wno-undef)
if(OV_COMPILER_IS_CLANG)
ie_add_compiler_flags(-Wno-parentheses-equality)
endif()
endif()
if(UNUSED_BUT_SET_VARIABLE_SUPPORTED)
ie_add_compiler_flags(-Wno-unused-but-set-variable)
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
cython>=0.29.32,<=0.29.36
cython>=0.29.32
7 changes: 0 additions & 7 deletions src/bindings/python/src/openvino/runtime/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,6 @@
from openvino.runtime.ie_api import compile_model


# Model Conversion API
try:
from openvino.tools.ovc import convert_model, InputCutInfo, LayoutMap
except ImportError:
pass


# Extend Node class to support binary operators
Node.__add__ = opset12.add
Node.__sub__ = opset12.subtract
Expand Down
46 changes: 46 additions & 0 deletions src/frontends/pytorch/src/op/quantized_add.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// Copyright (C) 2018-2023 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//

#include "openvino/frontend/pytorch/node_context.hpp"
#include "openvino/op/add.hpp"
#include "openvino/op/constant.hpp"
#include "openvino/op/relu.hpp"
#include "utils_quantize.hpp"

namespace ov {
namespace frontend {
namespace pytorch {
namespace op {

using namespace ov::op;

OutputVector translate_quantized_add(const NodeContext& context) {
num_inputs_check(context, 4, 4);
const auto x = context.get_input(0);
const auto y = context.get_input(1);
const auto scale = context.get_input(2);
const auto zero_point = context.get_input(3);

const auto quantized_add = context.mark_node(std::make_shared<v1::Add>(x, y));

return {quantize(context, quantized_add, scale, zero_point, x)};
}

OutputVector translate_quantized_add_relu(const NodeContext& context) {
num_inputs_check(context, 4, 4);
const auto x = context.get_input(0);
const auto y = context.get_input(1);
const auto scale = context.get_input(2);
const auto zero_point = context.get_input(3);

const auto quantized_add = context.mark_node(std::make_shared<v1::Add>(x, y));
const auto quantized_add_relu = context.mark_node(std::make_shared<v0::Relu>(quantized_add));

return {quantize(context, quantized_add_relu, scale, zero_point, x)};
}

} // namespace op
} // namespace pytorch
} // namespace frontend
} // namespace ov
31 changes: 31 additions & 0 deletions src/frontends/pytorch/src/op/quantized_hardswish.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Copyright (C) 2018-2023 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//

#include "openvino/frontend/pytorch/node_context.hpp"
#include "openvino/op/constant.hpp"
#include "openvino/op/hswish.hpp"
#include "utils_quantize.hpp"

namespace ov {
namespace frontend {
namespace pytorch {
namespace op {

using namespace ov::op;

OutputVector translate_quantized_hardswish(const NodeContext& context) {
num_inputs_check(context, 3, 3);
const auto x = context.get_input(0);
const auto scale = context.get_input(1);
const auto zero_point = context.get_input(2);

const auto quantized_hardswish = context.mark_node(std::make_shared<v4::HSwish>(x));

return {quantize(context, quantized_hardswish, scale, zero_point, x)};
}

} // namespace op
} // namespace pytorch
} // namespace frontend
} // namespace ov
32 changes: 32 additions & 0 deletions src/frontends/pytorch/src/op/quantized_mul.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Copyright (C) 2018-2023 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//

#include "openvino/frontend/pytorch/node_context.hpp"
#include "openvino/op/constant.hpp"
#include "openvino/op/multiply.hpp"
#include "utils_quantize.hpp"

namespace ov {
namespace frontend {
namespace pytorch {
namespace op {

using namespace ov::op;

OutputVector translate_quantized_mul(const NodeContext& context) {
num_inputs_check(context, 4, 4);
const auto x = context.get_input(0);
const auto y = context.get_input(1);
const auto scale = context.get_input(2);
const auto zero_point = context.get_input(3);

const auto quantized_mul = context.mark_node(std::make_shared<v1::Multiply>(x, y));

return {quantize(context, quantized_mul, scale, zero_point, x)};
}

} // namespace op
} // namespace pytorch
} // namespace frontend
} // namespace ov
Loading

0 comments on commit 94521bd

Please sign in to comment.