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

Fix/normal reduce sum #1214

Merged
merged 12 commits into from
Jun 11, 2024
8 changes: 4 additions & 4 deletions .github/workflows/compiler-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
config:
- {name: x86_64-macos, os: macos-12, cmakeArgs: -DENABLE_X86SIMD=OFF, buildType: Release}
- {name: x86_64-linux, os: ubuntu-latest, cmakeArgs: '', buildType: Release}
- {name: x86_64-windows, os: windows-latest, arch: x64, cmakeArgs: -DCMAKE_C_COMPILER=clang-cl -DCMAKE_CXX_COMPILER=clang-cl, buildType: Release}
- {name: x86_64-windows, os: windows-2019, arch: x64, cmakeArgs: -DCMAKE_C_COMPILER=clang-cl -DCMAKE_CXX_COMPILER=clang-cl, buildType: Release}

steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -81,7 +81,7 @@ jobs:
config:
- {name: x86_64-macos, os: macos-12, shell: bash, rid: osx-x64, buildType: Release}
- {name: x86_64-linux, os: ubuntu-latest, shell: bash, rid: linux-x64, buildType: Release}
- {name: x86_64-windows, os: windows-latest, shell: bash, rid: win-x64, buildType: Release}
- {name: x86_64-windows, os: windows-2019, shell: bash, rid: win-x64, buildType: Release}

steps:
- uses: actions/checkout@v2
Expand Down Expand Up @@ -170,7 +170,7 @@ jobs:
config:
- {name: x86_64-macos, os: macos-12, shell: bash}
- {name: x86_64-linux, os: ubuntu-latest, shell: bash}
- {name: x86_64-windows, os: windows-latest, shell: bash}
- {name: x86_64-windows, os: windows-2019, shell: bash}

env:
VULKANSDK_VER: 1.3.268.0
Expand Down Expand Up @@ -327,4 +327,4 @@ jobs:
with:
name: nncase-coverage-report
path: coveragereport
if-no-files-found: error
if-no-files-found: error
4 changes: 2 additions & 2 deletions .github/workflows/compiler-python-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
config:
- {name: x86_64-macos, os: macos-12, shell: bash, rid: osx-x64, buildType: Release}
- {name: x86_64-linux, os: ubuntu-latest, shell: bash, rid: linux-x64, buildType: Release}
- {name: x86_64-windows, os: windows-latest, shell: bash, rid: win-x64, buildType: Release}
- {name: x86_64-windows, os: windows-2019, shell: bash, rid: win-x64, buildType: Release}

steps:
- uses: actions/checkout@v2
Expand Down Expand Up @@ -55,7 +55,7 @@ jobs:
config:
- {name: x86_64-macos, os: macos-12}
- {name: x86_64-linux, os: ubuntu-latest}
- {name: x86_64-windows, os: windows-latest, arch: x64}
- {name: x86_64-windows, os: windows-2019, arch: x64}

env:
VULKANSDK_VER: 1.3.268.0
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/jupyter-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
config:
- {name: x86_64-macos, os: macos-12}
- {name: x86_64-linux, os: ubuntu-latest}
- {name: x86_64-windows, os: windows-latest}
- {name: x86_64-windows, os: windows-2019}

steps:
- uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/runtime-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
config:
- { name: x86_64-macos, os: macos-12, cmakeArgs: '', buildType: Release }
- { name: x86_64-linux, os: ubuntu-latest, cmakeArgs: '', buildType: Release }
- { name: x86_64-windows, os: windows-latest, arch: x64, cmakeArgs: -DCMAKE_C_COMPILER=clang-cl -DCMAKE_CXX_COMPILER=clang-cl, buildType: Release }
- { name: x86_64-windows, os: windows-2019, arch: x64, cmakeArgs: -DCMAKE_C_COMPILER=clang-cl -DCMAKE_CXX_COMPILER=clang-cl, buildType: Release }

steps:
- uses: actions/checkout@v3
Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@
Telegram: [nncase community](https://t.me/joinchat/PPcEPZMLaTViNDI1)
Technical Discussion QQ Group: 790699378 . Answer: 人工智能

[TOC]
---

## Tips

- [2024/05/28] [BUG] nncase v2.8.3: ReduceSum(onnx) has a BUG that causes segmentfault. Please downgrade to v2.8.2, if your model has ReduceSum.

---

Expand Down
32 changes: 16 additions & 16 deletions cmake/conan.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ function(_get_msvc_ide_version result)
set(${result} 15 PARENT_SCOPE)
elseif(NOT MSVC_VERSION VERSION_LESS 1920 AND MSVC_VERSION VERSION_LESS 1930)
set(${result} 16 PARENT_SCOPE)
elseif(NOT MSVC_VERSION VERSION_LESS 1930 AND MSVC_VERSION VERSION_LESS 1940)
elseif(NOT MSVC_VERSION VERSION_LESS 1930 AND MSVC_VERSION VERSION_LESS 1950)
set(${result} 17 PARENT_SCOPE)
else()
message(FATAL_ERROR "Conan: Unknown MSVC compiler version [${MSVC_VERSION}]")
Expand Down Expand Up @@ -152,7 +152,7 @@ macro(_conan_detect_compiler)
set(COMPILER_VERSION ${MAJOR})
else()
set(COMPILER_VERSION ${MAJOR}.${MINOR})
endif()
endif()
elseif (${CMAKE_${LANGUAGE}_COMPILER_ID} STREQUAL QCC)
set(_CONAN_SETTING_COMPILER qcc)
set(COMPILER_VERSION ${MAJOR}.${MINOR})
Expand Down Expand Up @@ -186,7 +186,7 @@ macro(_conan_detect_compiler)
set(COMPILER_VERSION ${MAJOR})
else()
set(COMPILER_VERSION ${MAJOR}.${MINOR})
endif()
endif()

set(_CONAN_SETTING_COMPILER_VERSION ${COMPILER_VERSION})

Expand All @@ -196,7 +196,7 @@ macro(_conan_detect_compiler)
set(_CONAN_SETTING_COMPILER_LIBCXX ${_LIBCXX})
endif ()
elseif (${CMAKE_${LANGUAGE}_COMPILER_ID} STREQUAL Clang
AND NOT "${CMAKE_${LANGUAGE}_COMPILER_FRONTEND_VARIANT}" STREQUAL "MSVC"
AND NOT "${CMAKE_${LANGUAGE}_COMPILER_FRONTEND_VARIANT}" STREQUAL "MSVC"
AND NOT "${CMAKE_${LANGUAGE}_SIMULATE_ID}" STREQUAL "MSVC")

string(REPLACE "." ";" VERSION_LIST ${CMAKE_${LANGUAGE}_COMPILER_VERSION})
Expand All @@ -209,7 +209,7 @@ macro(_conan_detect_compiler)
set(COMPILER_VERSION ${MAJOR})
else()
set(COMPILER_VERSION ${MAJOR}.${MINOR})
endif()
endif()

set(_CONAN_SETTING_COMPILER_VERSION ${COMPILER_VERSION})

Expand All @@ -225,8 +225,8 @@ macro(_conan_detect_compiler)
set(_CONAN_SETTING_COMPILER_LIBCXX ${_LIBCXX})
endif ()
elseif(${CMAKE_${LANGUAGE}_COMPILER_ID} STREQUAL MSVC
OR (${CMAKE_${LANGUAGE}_COMPILER_ID} STREQUAL Clang
AND "${CMAKE_${LANGUAGE}_COMPILER_FRONTEND_VARIANT}" STREQUAL "MSVC"
OR (${CMAKE_${LANGUAGE}_COMPILER_ID} STREQUAL Clang
AND "${CMAKE_${LANGUAGE}_COMPILER_FRONTEND_VARIANT}" STREQUAL "MSVC"
AND "${CMAKE_${LANGUAGE}_SIMULATE_ID}" STREQUAL "MSVC"))

set(_VISUAL "Visual Studio")
Expand Down Expand Up @@ -481,7 +481,7 @@ function(conan_cmake_autodetect detected_settings)
endfunction()

macro(conan_parse_arguments)
set(options BASIC_SETUP CMAKE_TARGETS UPDATE KEEP_RPATHS NO_LOAD NO_OUTPUT_DIRS
set(options BASIC_SETUP CMAKE_TARGETS UPDATE KEEP_RPATHS NO_LOAD NO_OUTPUT_DIRS
OUTPUT_QUIET NO_IMPORTS SKIP_STD)
set(oneValueArgs CONANFILE ARCH BUILD_TYPE INSTALL_FOLDER OUTPUT_FOLDER CONAN_COMMAND)
set(multiValueArgs DEBUG_PROFILE RELEASE_PROFILE RELWITHDEBINFO_PROFILE MINSIZEREL_PROFILE
Expand Down Expand Up @@ -662,11 +662,11 @@ function(conan_cmake_install)
if(DEFINED NO_IMPORTS)
set(NO_IMPORTS --no-imports)
endif()
set(install_args install ${PATH_OR_REFERENCE} ${REFERENCE} ${UPDATE} ${NO_IMPORTS} ${REMOTE}
${LOCKFILE} ${LOCKFILE_OUT} ${LOCKFILE_NODE_ID} ${INSTALL_FOLDER}
${OUTPUT_FOLDER} ${GENERATOR} ${BUILD} ${ENV} ${ENV_HOST} ${ENV_BUILD}
${OPTIONS} ${OPTIONS_HOST} ${OPTIONS_BUILD} ${PROFILE} ${PROFILE_HOST}
${PROFILE_BUILD} ${SETTINGS} ${SETTINGS_HOST} ${SETTINGS_BUILD}
set(install_args install ${PATH_OR_REFERENCE} ${REFERENCE} ${UPDATE} ${NO_IMPORTS} ${REMOTE}
${LOCKFILE} ${LOCKFILE_OUT} ${LOCKFILE_NODE_ID} ${INSTALL_FOLDER}
${OUTPUT_FOLDER} ${GENERATOR} ${BUILD} ${ENV} ${ENV_HOST} ${ENV_BUILD}
${OPTIONS} ${OPTIONS_HOST} ${OPTIONS_BUILD} ${PROFILE} ${PROFILE_HOST}
${PROFILE_BUILD} ${SETTINGS} ${SETTINGS_HOST} ${SETTINGS_BUILD}
${CONF} ${CONF_HOST} ${CONF_BUILD})

string(REPLACE ";" " " _install_args "${install_args}")
Expand Down Expand Up @@ -770,12 +770,12 @@ function(conan_cmake_lock_create)
set(BASE --base)
endif()
set(lock_create_Args lock create ${PATH} ${REFERENCE} ${UPDATE} ${BASE} ${REMOTE} ${LOCKFILE} ${LOCKFILE_OUT} ${LOCKFILE_NODE_ID} ${INSTALL_FOLDER}
${GENERATOR} ${BUILD} ${ENV} ${ENV_HOST} ${ENV_BUILD} ${OPTIONS} ${OPTIONS_HOST} ${OPTIONS_BUILD}
${GENERATOR} ${BUILD} ${ENV} ${ENV_HOST} ${ENV_BUILD} ${OPTIONS} ${OPTIONS_HOST} ${OPTIONS_BUILD}
${PROFILE} ${PROFILE_HOST} ${PROFILE_BUILD} ${SETTINGS} ${SETTINGS_HOST} ${SETTINGS_BUILD})

string(REPLACE ";" " " _lock_create_Args "${lock_create_Args}")
message(STATUS "Conan executing: ${CONAN_CMD} ${_lock_create_Args}")

if(ARGS_OUTPUT_QUIET)
set(OUTPUT_OPT OUTPUT_QUIET)
endif()
Expand Down Expand Up @@ -1089,7 +1089,7 @@ function(conan_cmake_profile)
set(profileMultiValueArgs SETTINGS OPTIONS CONF ENV BUILDENV RUNENV TOOL_REQUIRES)
cmake_parse_arguments(ARGS "" "${profileOneValueArgs}" "${profileMultiValueArgs}" ${ARGN})

if(DEFINED ARGS_FILEPATH)
if(DEFINED ARGS_FILEPATH)
set(_FN "${ARGS_FILEPATH}")
else()
set(_FN "${CMAKE_CURRENT_BINARY_DIR}/profile")
Expand Down
2 changes: 1 addition & 1 deletion src/Nncase.Importer/Onnx/Reduce.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public partial class OnnxImporter
{
private Expr VisitReduce(in NodeProto op, ReduceOp reduceOp, Expr initValue)
{
return ReduceCore(op, reduceOp, initValue, expr => expr);
return ReduceCore(op, reduceOp, initValue, expr => expr, GetOpSet(op));
}

private Expr ReduceCore(in NodeProto op, ReduceOp reduceOp, Expr initValue, Func<Expr, Expr> f, long opVersion = 999)
Expand Down
16 changes: 10 additions & 6 deletions tests/importer/onnx_/basic/test_reduce.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ def _make_module(in_shape, in_datatype, reduce_op, axes, keepdims, op_version):
'ReduceMax',
'ReduceMean',
'ReduceMin',
'ReduceProd'
'ReduceProd',
'ReduceSum',
]

axes_list = [
Expand Down Expand Up @@ -120,11 +121,14 @@ def _make_module(in_shape, in_datatype, reduce_op, axes, keepdims, op_version):
@pytest.mark.parametrize('op_version', op_version_lists)
def test_reduce(in_shape, in_datatype, reduce_op, axes, keepdims, request, op_version):
if len(axes) <= len(in_shape):
model_def = _make_module(in_shape, in_datatype, reduce_op, axes, keepdims, op_version)

runner = OnnxTestRunner(request.node.name)
model_file = runner.from_onnx_helper(model_def)
runner.run(model_file)
if reduce_op == 'ReduceSum' and op_version >= 13:
pass
else:
model_def = _make_module(in_shape, in_datatype, reduce_op, axes, keepdims, op_version)

runner = OnnxTestRunner(request.node.name)
model_file = runner.from_onnx_helper(model_def)
runner.run(model_file)


if __name__ == "__main__":
Expand Down
Loading