Skip to content

Commit

Permalink
Merge branch 'master' into bell/try_fix_precision_gap
Browse files Browse the repository at this point in the history
  • Loading branch information
songbell authored Jan 2, 2024
2 parents 847f4dc + 387f453 commit e4f4f62
Show file tree
Hide file tree
Showing 119 changed files with 1,417 additions and 2,054 deletions.
12 changes: 7 additions & 5 deletions .github/workflows/job_onnx_runtime.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ jobs:
--parallel \
--skip_tests \
--compile_no_warning_as_error \
--allow_running_as_root \
--build_dir ${ONNX_RUNTIME_BUILD_DIR}
env:
CXXFLAGS: "-Wno-error=deprecated-declarations"
Expand Down Expand Up @@ -138,11 +139,12 @@ jobs:
./onnxruntime_global_thread_pools_test
working-directory: ${{ env.ONNX_RUNTIME_BUILD_DIR }}/RelWithDebInfo/RelWithDebInfo

- name: Run onnxruntime_api_tests_without_env
run: |
source ${INSTALL_DIR}/setupvars.sh
./onnxruntime_api_tests_without_env
working-directory: ${{ env.ONNX_RUNTIME_BUILD_DIR }}/RelWithDebInfo/RelWithDebInfo
# Test removed in onnxruntime 1.16.2
# - name: Run onnxruntime_api_tests_without_env
# run: |
# source ${INSTALL_DIR}/setupvars.sh
# ./onnxruntime_api_tests_without_env
# working-directory: ${{ env.ONNX_RUNTIME_BUILD_DIR }}/RelWithDebInfo/RelWithDebInfo

- name: Run pytorch-converted tests
run: |
Expand Down
2 changes: 1 addition & 1 deletion install_build_dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ fi
current_cmake_ver=$($cmake_command --version | sed -ne 's/[^0-9]*\(\([0-9]\.\)\{0,4\}[0-9][^.]\).*/\1/p')
required_cmake_ver=3.20.0
if [ ! "$(printf '%s\n' "$required_cmake_ver" "$current_cmake_ver" | sort -V | head -n1)" = "$required_cmake_ver" ]; then
installed_cmake_ver=3.24.0
installed_cmake_ver=3.26.0
arch=$(uname -m)

if command -v apt-get &> /dev/null; then
Expand Down
2 changes: 2 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,6 @@ add_subdirectory(bindings)
if(ENABLE_TESTS)
add_subdirectory(core/tests)
add_subdirectory(tests)
else()
add_subdirectory(tests/ov_helpers/ov_models/ov_builders)
endif()
1 change: 0 additions & 1 deletion src/cmake/openvino.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ target_include_directories(${TARGET_NAME} PUBLIC
$<BUILD_INTERFACE:${OpenVINO_SOURCE_DIR}/src/inference/include/ie>)

target_link_libraries(${TARGET_NAME} PRIVATE openvino::reference
openvino::builders
openvino::shape_inference
openvino::pugixml
${CMAKE_DL_LIBS}
Expand Down
2 changes: 1 addition & 1 deletion src/common/transformations/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ ov_build_target_faster(${TARGET_NAME}_obj
PCH PRIVATE "src/precomp.hpp"
)

target_link_libraries(${TARGET_NAME}_obj PRIVATE openvino::reference openvino::itt openvino::builders openvino::core::dev openvino::shape_inference)
target_link_libraries(${TARGET_NAME}_obj PRIVATE openvino::reference openvino::itt openvino::core::dev openvino::shape_inference)

target_include_directories(${TARGET_NAME}_obj PRIVATE "${PUBLIC_HEADERS_DIR}"
"${CMAKE_CURRENT_SOURCE_DIR}/src")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,11 @@ TSGatherBackward::TSGatherBackward() {
main_node->input(1).replace_source_output(squeeze->input_value(0));
}
}
std::vector<size_t> new_axes_val;
if (!axes_val.empty()) {
for (size_t i = 0; i < axes_val.size(); ++i) {
new_axes_val.push_back(order_val[axes_val[i]]);
}
order_val = GetOrderAfterReduction(axes_val, order_val);
}

Expand Down Expand Up @@ -303,7 +307,7 @@ TSGatherBackward::TSGatherBackward() {
RemoveTransposeConsumers(main_node);
if (success) {
auto target_inputs = main_node->get_output_target_inputs(0);
auto unsqueeze_axes = ov::op::v0::Constant::create(element::i32, {axes_val.size()}, axes_val);
auto unsqueeze_axes = ov::op::v0::Constant::create(element::i32, {new_axes_val.size()}, new_axes_val);
auto unsqueeze = std::make_shared<ov::op::v0::Unsqueeze>(main_node, unsqueeze_axes);
for (const auto& input : target_inputs) {
input.replace_source_output(unsqueeze);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,16 @@ INSTANTIATE_TEST_SUITE_P(TSCommonGatherBackward_1, TSTestFixture, test_backward_
auto test_backward_gather_optimization = [](const GatherBackwardArguments& test_arguments) {
TestCase test_case;

auto custom_transpose = [&](const vector<size_t>& idxs, const OutputVector& out_vec) -> OutputVector {
const auto& order_val = test_arguments.ref_transpose_order;
auto order = constant<size_t>(i32, {order_val.size()}, order_val);
OutputVector new_outputs = out_vec;
for (const auto& idx : idxs) {
new_outputs[idx] = make_shared<Transpose>(out_vec[idx], order);
}
return new_outputs;
};

// Initialize common attributes
test_case.transformation = CREATE_PASS_FACTORY(TSGatherBackward);
test_case.num_main_ops = {1};
Expand All @@ -229,7 +239,7 @@ auto test_backward_gather_optimization = [](const GatherBackwardArguments& test_
return {make_shared<Unsqueeze>(out_vec[0], axes)};
};

test_case.model_ref.preprocess_inputs_to_main = {{set_transpose_for, update_gather_inputs}, {{0}, {1, 2}}};
test_case.model_ref.preprocess_inputs_to_main = {{custom_transpose, update_gather_inputs}, {{0}, {1, 2}}};
test_case.model_ref.main_op = {CREATE_GATHER_FACTORY(Gather)};
test_case.model_ref.preprocess_outputs_of_main = {{unsqueeze_for}, {{0}}};
test_case.model_ref.model_template = create_model;
Expand All @@ -240,16 +250,20 @@ auto test_backward_gather_optimization = [](const GatherBackwardArguments& test_
vector<GatherBackwardArguments> tests_arguments_bw_optimization{
{{parameter(f32, {257, 8}), constant<int>(i32, {1, 2}, {0}), constant<int>(i32, {1}, {0})},
constant<int>(i32, {1}, {1}),
AxisVector{},
AxisVector{0}},
AxisVector{1, 0},
AxisVector{2}},
{{parameter(f32, {4}), constant<int>(i32, {1}, {0}), constant<int>(i32, {1}, {0})},
constant<int>(i32, {1}, {0}),
AxisVector{},
AxisVector{0},
AxisVector{0}},
{{parameter(f32, {4}), constant<int>(i32, {1, 1, 1}, {0}), constant<int>(i32, {1}, {0})},
constant<int>(i32, {1}, {0}),
AxisVector{},
AxisVector{0, 1, 2}},
AxisVector{0},
AxisVector{2, 1, 0}},
{{parameter(f32, {32, 100}), constant<int>(i32, {1, 60}, {0}), constant<int>(i32, {1}, {0})},
constant<int>(i32, {1}, {1}),
AxisVector{1, 0},
AxisVector{2}},
};

INSTANTIATE_TEST_SUITE_P(TSCommonGatherBackwardOptimization_0,
Expand All @@ -261,6 +275,9 @@ INSTANTIATE_TEST_SUITE_P(TSCommonGatherBackwardOptimization_1,
INSTANTIATE_TEST_SUITE_P(TSCommonGatherBackwardOptimization_2,
TSTestFixture,
test_backward_gather_optimization(tests_arguments_bw_optimization[2]));
INSTANTIATE_TEST_SUITE_P(TSCommonGatherBackwardOptimization_3,
TSTestFixture,
test_backward_gather_optimization(tests_arguments_bw_optimization[3]));
} // namespace gather
} // namespace testing
} // namespace transpose_sinking
7 changes: 3 additions & 4 deletions src/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ file(GLOB_RECURSE LIBRARY_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp
file(GLOB_RECURSE PUBLIC_HEADERS ${OV_CORE_INCLUDE_PATH}/*.hpp)
file(GLOB_RECURSE DEV_HEADERS ${OV_CORE_DEV_API_PATH}/*.hpp)

add_subdirectory(builder)
add_subdirectory(reference)
add_subdirectory(shape_inference)

Expand Down Expand Up @@ -88,7 +87,7 @@ ov_build_target_faster(ngraph_obj

ov_add_version_defines(src/version.cpp ngraph_obj)

target_link_libraries(ngraph_obj PRIVATE openvino::builders openvino::reference openvino::util
target_link_libraries(ngraph_obj PRIVATE openvino::reference openvino::util
openvino::pugixml openvino::shape_inference openvino::core::dev)

ov_mark_target_as_cc(ngraph_obj)
Expand All @@ -106,12 +105,12 @@ if(NOT BUILD_SHARED_LIBS)
endif()

if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
# ngraph is linked against openvino::builders, openvino::reference, openvino::shape_inference static libraries
# ngraph is linked against openvino::reference, openvino::shape_inference static libraries
# which include ngraph headers with dllimport attribute. Linker complains about it
# but no way to fix this: linking with no attribute defaults to dllexport and we have
# multiple defitions for ngraph symbols.
#
# The possible way is to use object libraries for openvino::builders, openvino::reference
# The possible way is to use object libraries for openvino::reference
# but it's not convinient since these libraries are exported from build tree
# and it's better to use them as static libraries in 3rd party projects
if(BUILD_SHARED_LIBS)
Expand Down
Loading

0 comments on commit e4f4f62

Please sign in to comment.