instruction stringclasses 9 values | input stringlengths 279 5.47k | output stringlengths 6 9.58k |
|---|---|---|
You are an expert OpenCV code reviewer specializing in code quality and best practices. Review the provided code changes and provide specific, actionable feedback. | **File:** cmake/OpenCVCompilerOptimizations.cmake
**Change Type:** modified
**Context:** PR #25901: RISC-V/AArch64: disable CPU features detection - This PR is the first step in fixing current issues with NEON/RVV, FP16, BF16 and other CPU...
**Code Changes:**
```diff
@@ -104,7 +104,7 @@ ocv_optimization_process_obsolete_option(ENABLE_AVX2 AVX2 ON)
ocv_optimization_process_obsolete_option(ENABLE_FMA3 FMA3 ON)
ocv_optimization_process_obsolete_option(ENABLE_VFPV3 VFPV3 OFF)
-ocv_optimization_process_obsolete_option(ENABLE_NEON NEON OFF)
+ocv_optimization_process_obsolete_option(ENABLE_NEON NEON ON)
ocv_optimization_process_obsolete_option(ENABLE_VSX VSX ON)
@@ -170,7 +170,29 @@ elseif(" ${CMAKE_CXX_FLAGS} " MATCHES " -march=native | -xHost | /QxHost ")
``` | I propose to revert changes in this files and use: - https://github.com/opencv/opencv/pull/25930 |
You are an expert OpenCV code reviewer specializing in code quality and best practices. Review the provided code changes and provide specific, actionable feedback. | **File:** platforms/linux/arm.toolchain.cmake
**Change Type:** modified
**Context:** PR #25901: RISC-V/AArch64: disable CPU features detection - This PR is the first step in fixing current issues with NEON/RVV, FP16, BF16 and other CPU...
**Code Changes:**
```diff
@@ -48,32 +48,23 @@ if(NOT DEFINED ARM_LINUX_SYSROOT AND DEFINED GNU_MACHINE)
set(ARM_LINUX_SYSROOT /usr/${GNU_MACHINE}${FLOAT_ABI_SUFFIX})
endif()
-if(NOT DEFINED CMAKE_CXX_FLAGS)
- set(CMAKE_CXX_FLAGS "" CACHE INTERNAL "")
- set(CMAKE_C_FLAGS "" CACHE INTERNAL "")
- set(CMAKE_SHARED_LINKER_FLAGS "" CACHE INTERNAL "")
- set(CMAKE_MODULE_LINKER_FLAGS "" CACHE INTERNAL "")
- set(CMAKE_EXE_LINKER_FLAGS "" CACHE INTERNAL "")
``` | > ENABLE_BF16 Toolchain files have issue with cached variables (not available to them - just add `message()`), |
You are an expert OpenCV code reviewer specializing in code quality and best practices. Review the provided code changes and provide specific, actionable feedback. | **File:** platforms/linux/arm.toolchain.cmake
**Change Type:** modified
**Context:** PR #25901: RISC-V/AArch64: disable CPU features detection - This PR is the first step in fixing current issues with NEON/RVV, FP16, BF16 and other CPU...
**Code Changes:**
```diff
@@ -48,32 +48,23 @@ if(NOT DEFINED ARM_LINUX_SYSROOT AND DEFINED GNU_MACHINE)
set(ARM_LINUX_SYSROOT /usr/${GNU_MACHINE}${FLOAT_ABI_SUFFIX})
endif()
-if(NOT DEFINED CMAKE_CXX_FLAGS)
- set(CMAKE_CXX_FLAGS "" CACHE INTERNAL "")
- set(CMAKE_C_FLAGS "" CACHE INTERNAL "")
- set(CMAKE_SHARED_LINKER_FLAGS "" CACHE INTERNAL "")
- set(CMAKE_MODULE_LINKER_FLAGS "" CACHE INTERNAL "")
- set(CMAKE_EXE_LINKER_FLAGS "" CACHE INTERNAL "")
``` | Toolchain files are not used for native compilation. We need a robust solution for such cases too, e.g. through `OPENCV_EXTRA_*` flags (currently they are applied after the feature checks) |
You are an expert OpenCV code reviewer specializing in performance optimization. Review the provided code changes and provide specific, actionable feedback. | **File:** cmake/OpenCVCompilerOptimizations.cmake
**Change Type:** modified
**Context:** PR #25901: RISC-V/AArch64: disable CPU features detection - This PR is the first step in fixing current issues with NEON/RVV, FP16, BF16 and other CPU...
**Code Changes:**
```diff
@@ -104,7 +104,7 @@ ocv_optimization_process_obsolete_option(ENABLE_AVX2 AVX2 ON)
ocv_optimization_process_obsolete_option(ENABLE_FMA3 FMA3 ON)
ocv_optimization_process_obsolete_option(ENABLE_VFPV3 VFPV3 OFF)
-ocv_optimization_process_obsolete_option(ENABLE_NEON NEON OFF)
+ocv_optimization_process_obsolete_option(ENABLE_NEON NEON ON)
ocv_optimization_process_obsolete_option(ENABLE_VSX VSX ON)
@@ -170,7 +170,29 @@ elseif(" ${CMAKE_CXX_FLAGS} " MATCHES " -march=native | -xHost | /QxHost ")
``` | The main idea here is to avoid modifying _arch_ compiler flags at all. If I understand correctly, changes in #25930 will still try to append custom flags and run compiler checks. For example, with that patch, if we compile OpenCV with `-DCMAKE_CXX_FLAGS="-mcpu=cortex-a72" -DCPU_BASELINE=NEON_FP16` options (`cortex-a72` is [armv8-a CPU](https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=gcc/config/aarch64/aarch64-cores.def;h=e58bc0f27de3d60d39c02d2be2aa15570bd5db4d;hb=refs/heads/master)), then our scripts will silently append `-march=armv8.2-a+fp16` and make this build incompatible with explicitly requested CPU. This behavior can cause compatibility, performance issues and compilation errors. |
You are an expert OpenCV code reviewer specializing in code quality and best practices. Review the provided code changes and provide specific, actionable feedback. | **File:** platforms/linux/arm.toolchain.cmake
**Change Type:** modified
**Context:** PR #25901: RISC-V/AArch64: disable CPU features detection - This PR is the first step in fixing current issues with NEON/RVV, FP16, BF16 and other CPU...
**Code Changes:**
```diff
@@ -48,32 +48,23 @@ if(NOT DEFINED ARM_LINUX_SYSROOT AND DEFINED GNU_MACHINE)
set(ARM_LINUX_SYSROOT /usr/${GNU_MACHINE}${FLOAT_ABI_SUFFIX})
endif()
-if(NOT DEFINED CMAKE_CXX_FLAGS)
- set(CMAKE_CXX_FLAGS "" CACHE INTERNAL "")
- set(CMAKE_C_FLAGS "" CACHE INTERNAL "")
- set(CMAKE_SHARED_LINKER_FLAGS "" CACHE INTERNAL "")
- set(CMAKE_MODULE_LINKER_FLAGS "" CACHE INTERNAL "")
- set(CMAKE_EXE_LINKER_FLAGS "" CACHE INTERNAL "")
``` | For native compilation we assume that toolchain have architecture flags set by default. |
You are an expert OpenCV code reviewer specializing in code quality and best practices. Review the provided code changes and provide specific, actionable feedback. | **File:** platforms/linux/arm.toolchain.cmake
**Change Type:** modified
**Context:** PR #25901: RISC-V/AArch64: disable CPU features detection - This PR is the first step in fixing current issues with NEON/RVV, FP16, BF16 and other CPU...
**Code Changes:**
```diff
@@ -48,32 +48,23 @@ if(NOT DEFINED ARM_LINUX_SYSROOT AND DEFINED GNU_MACHINE)
set(ARM_LINUX_SYSROOT /usr/${GNU_MACHINE}${FLOAT_ABI_SUFFIX})
endif()
-if(NOT DEFINED CMAKE_CXX_FLAGS)
- set(CMAKE_CXX_FLAGS "" CACHE INTERNAL "")
- set(CMAKE_C_FLAGS "" CACHE INTERNAL "")
- set(CMAKE_SHARED_LINKER_FLAGS "" CACHE INTERNAL "")
- set(CMAKE_MODULE_LINKER_FLAGS "" CACHE INTERNAL "")
- set(CMAKE_EXE_LINKER_FLAGS "" CACHE INTERNAL "")
``` | For example on Armbian 12 (OrangePi) I have: ``` g++ -march=native -Q --target-help | grep march -march= armv8.2-a+crypto+fp16+rcpc+dotprod ``` |
You are an expert OpenCV code reviewer specializing in code quality and best practices. Review the provided code changes and provide specific, actionable feedback. | **File:** platforms/linux/arm.toolchain.cmake
**Change Type:** modified
**Context:** PR #25901: RISC-V/AArch64: disable CPU features detection - This PR is the first step in fixing current issues with NEON/RVV, FP16, BF16 and other CPU...
**Code Changes:**
```diff
@@ -48,32 +48,23 @@ if(NOT DEFINED ARM_LINUX_SYSROOT AND DEFINED GNU_MACHINE)
set(ARM_LINUX_SYSROOT /usr/${GNU_MACHINE}${FLOAT_ABI_SUFFIX})
endif()
-if(NOT DEFINED CMAKE_CXX_FLAGS)
- set(CMAKE_CXX_FLAGS "" CACHE INTERNAL "")
- set(CMAKE_C_FLAGS "" CACHE INTERNAL "")
- set(CMAKE_SHARED_LINKER_FLAGS "" CACHE INTERNAL "")
- set(CMAKE_MODULE_LINKER_FLAGS "" CACHE INTERNAL "")
- set(CMAKE_EXE_LINKER_FLAGS "" CACHE INTERNAL "")
``` | I've checked this variable, it seem to be working. I build with `-DENABLE_BF16=ON` and got `-march=armv8.6-a` in the compiler string. We use this approach in XuanTie cmake toolchain: https://github.com/opencv/opencv/blob/4.x/platforms/linux/riscv64-071-gcc.toolchain.cmake (`CORE` variable) |
You are an expert OpenCV code reviewer specializing in code quality and best practices. Review the provided code changes and provide specific, actionable feedback. | **File:** platforms/linux/arm.toolchain.cmake
**Change Type:** modified
**Context:** PR #25901: RISC-V/AArch64: disable CPU features detection - This PR is the first step in fixing current issues with NEON/RVV, FP16, BF16 and other CPU...
**Code Changes:**
```diff
@@ -48,32 +48,23 @@ if(NOT DEFINED ARM_LINUX_SYSROOT AND DEFINED GNU_MACHINE)
set(ARM_LINUX_SYSROOT /usr/${GNU_MACHINE}${FLOAT_ABI_SUFFIX})
endif()
-if(NOT DEFINED CMAKE_CXX_FLAGS)
- set(CMAKE_CXX_FLAGS "" CACHE INTERNAL "")
- set(CMAKE_C_FLAGS "" CACHE INTERNAL "")
- set(CMAKE_SHARED_LINKER_FLAGS "" CACHE INTERNAL "")
- set(CMAKE_MODULE_LINKER_FLAGS "" CACHE INTERNAL "")
- set(CMAKE_EXE_LINKER_FLAGS "" CACHE INTERNAL "")
``` | Just add `message()` and run. Also add `message() for modified `CMAKE_CXX_FLAGS` because you got the `else()` branch in case of undefined value. |
You are an expert OpenCV code reviewer specializing in code quality and best practices. Review the provided code changes and provide specific, actionable feedback. | **File:** platforms/linux/arm.toolchain.cmake
**Change Type:** modified
**Context:** PR #25901: RISC-V/AArch64: disable CPU features detection - This PR is the first step in fixing current issues with NEON/RVV, FP16, BF16 and other CPU...
**Code Changes:**
```diff
@@ -48,32 +48,23 @@ if(NOT DEFINED ARM_LINUX_SYSROOT AND DEFINED GNU_MACHINE)
set(ARM_LINUX_SYSROOT /usr/${GNU_MACHINE}${FLOAT_ABI_SUFFIX})
endif()
-if(NOT DEFINED CMAKE_CXX_FLAGS)
- set(CMAKE_CXX_FLAGS "" CACHE INTERNAL "")
- set(CMAKE_C_FLAGS "" CACHE INTERNAL "")
- set(CMAKE_SHARED_LINKER_FLAGS "" CACHE INTERNAL "")
- set(CMAKE_MODULE_LINKER_FLAGS "" CACHE INTERNAL "")
- set(CMAKE_EXE_LINKER_FLAGS "" CACHE INTERNAL "")
``` | > `-march=native` It is not a default actually. "Native" case is already properly handled by the current scripts: https://github.com/opencv/opencv/blob/4.10.0/cmake/OpenCVCompilerOptimizations.cmake#L167 |
You are an expert OpenCV code reviewer specializing in code quality and best practices. Review the provided code changes and provide specific, actionable feedback. | **File:** cmake/OpenCVCompilerOptimizations.cmake
**Change Type:** modified
**Context:** PR #25901: RISC-V/AArch64: disable CPU features detection - This PR is the first step in fixing current issues with NEON/RVV, FP16, BF16 and other CPU...
**Code Changes:**
```diff
@@ -104,7 +104,7 @@ ocv_optimization_process_obsolete_option(ENABLE_AVX2 AVX2 ON)
ocv_optimization_process_obsolete_option(ENABLE_FMA3 FMA3 ON)
ocv_optimization_process_obsolete_option(ENABLE_VFPV3 VFPV3 OFF)
-ocv_optimization_process_obsolete_option(ENABLE_NEON NEON OFF)
+ocv_optimization_process_obsolete_option(ENABLE_NEON NEON ON)
ocv_optimization_process_obsolete_option(ENABLE_VSX VSX ON)
@@ -170,7 +170,29 @@ elseif(" ${CMAKE_CXX_FLAGS} " MATCHES " -march=native | -xHost | /QxHost ")
``` | > avoid modifying arch compiler flags at all For dispatched optimization we still need to modify compiler flags anyway. > make this build incompatible with explicitly requested CPU If compiler doesn't fail on `try_compile()` in that case then it could be workaronded through `-DCPU_NEON_FP16_FLAGS_ON=` CMake override. |
You are an expert OpenCV code reviewer specializing in code quality and best practices. Review the provided code changes and provide specific, actionable feedback. | **File:** cmake/OpenCVCompilerOptimizations.cmake
**Change Type:** modified
**Context:** PR #25901: RISC-V/AArch64: disable CPU features detection - This PR is the first step in fixing current issues with NEON/RVV, FP16, BF16 and other CPU...
**Code Changes:**
```diff
@@ -104,7 +104,7 @@ ocv_optimization_process_obsolete_option(ENABLE_AVX2 AVX2 ON)
ocv_optimization_process_obsolete_option(ENABLE_FMA3 FMA3 ON)
ocv_optimization_process_obsolete_option(ENABLE_VFPV3 VFPV3 OFF)
-ocv_optimization_process_obsolete_option(ENABLE_NEON NEON OFF)
+ocv_optimization_process_obsolete_option(ENABLE_NEON NEON ON)
ocv_optimization_process_obsolete_option(ENABLE_VSX VSX ON)
@@ -170,7 +170,29 @@ elseif(" ${CMAKE_CXX_FLAGS} " MATCHES " -march=native | -xHost | /QxHost ")
``` | Besides of DETECT, empty or other values of CPU_BASELINE are used for **limiting** of used features in OpenCV without touching compiler flags. |
You are an expert OpenCV code reviewer specializing in code quality and best practices. Review the provided code changes and provide specific, actionable feedback. | **File:** cmake/OpenCVCompilerOptimizations.cmake
**Change Type:** modified
**Context:** PR #25901: RISC-V/AArch64: disable CPU features detection - This PR is the first step in fixing current issues with NEON/RVV, FP16, BF16 and other CPU...
**Code Changes:**
```diff
@@ -104,7 +104,7 @@ ocv_optimization_process_obsolete_option(ENABLE_AVX2 AVX2 ON)
ocv_optimization_process_obsolete_option(ENABLE_FMA3 FMA3 ON)
ocv_optimization_process_obsolete_option(ENABLE_VFPV3 VFPV3 OFF)
-ocv_optimization_process_obsolete_option(ENABLE_NEON NEON OFF)
+ocv_optimization_process_obsolete_option(ENABLE_NEON NEON ON)
ocv_optimization_process_obsolete_option(ENABLE_VSX VSX ON)
@@ -170,7 +170,29 @@ elseif(" ${CMAKE_CXX_FLAGS} " MATCHES " -march=native | -xHost | /QxHost ")
``` | > For dispatched optimization we still need to modify compiler flags anyway. Yes, perhaps users will be required to manually provide flags for dispatched files via `CPU_XXX_FLAGS_ON` variables. Examples with our cmake-toolchain file from this PR: * Build with RVV as a baseline: ` -DENABLE_RVV=ON` * Build without RVV in a baseline, but with dispatched RVV files: `-DCPU_DISPATCH=RVV -DCPU_RVV_FLAGS_ON=-march=rv64gcv` > empty or other values of CPU_BASELINE are used for limiting of used features Doesn't `CPU_BASELINE_DISABLE` do this? I tried to use it with this PR and enabled RVV compiler flags: `-DENABLE_RVV=ON -DCPU_BASELINE_DISABLE=RVV`, but I'm not sure if correct macros are being set in cv_cpu_config.h: ```.h // OpenCV CPU baseline features #define CV_CPU_COMPILE_RVV 1 #define CV_CPU_BASELINE_COMPILE_RVV 1 #define CV_CPU_BASELINE_FEATURES 0 \ , CV_CPU_RVV \ // OpenCV supported CPU dispatched features #define CV_CPU_DISPATCH_FEATURES 0 \ ``` |
You are an expert OpenCV code reviewer specializing in testing and validation. Review the provided code changes and provide specific, actionable feedback. | **File:** platforms/linux/arm.toolchain.cmake
**Change Type:** modified
**Context:** PR #25901: RISC-V/AArch64: disable CPU features detection - This PR is the first step in fixing current issues with NEON/RVV, FP16, BF16 and other CPU...
**Code Changes:**
```diff
@@ -48,32 +48,23 @@ if(NOT DEFINED ARM_LINUX_SYSROOT AND DEFINED GNU_MACHINE)
set(ARM_LINUX_SYSROOT /usr/${GNU_MACHINE}${FLOAT_ABI_SUFFIX})
endif()
-if(NOT DEFINED CMAKE_CXX_FLAGS)
- set(CMAKE_CXX_FLAGS "" CACHE INTERNAL "")
- set(CMAKE_C_FLAGS "" CACHE INTERNAL "")
- set(CMAKE_SHARED_LINKER_FLAGS "" CACHE INTERNAL "")
- set(CMAKE_MODULE_LINKER_FLAGS "" CACHE INTERNAL "")
- set(CMAKE_EXE_LINKER_FLAGS "" CACHE INTERNAL "")
``` | Oh, I remembered, it was an issue with CMAKE_CXX_FLAGS. As I understand, modern cmake (3.7+) have respective `_INIT` variables for toolchain files specifically (https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_FLAGS_INIT.html). In new commit I've updated some of our toolchains to use them too. |
You are an expert OpenCV code reviewer specializing in code quality and best practices. Review the provided code changes and provide specific, actionable feedback. | **File:** platforms/linux/arm.toolchain.cmake
**Change Type:** modified
**Context:** PR #25901: RISC-V/AArch64: disable CPU features detection - This PR is the first step in fixing current issues with NEON/RVV, FP16, BF16 and other CPU...
**Code Changes:**
```diff
@@ -48,32 +48,23 @@ if(NOT DEFINED ARM_LINUX_SYSROOT AND DEFINED GNU_MACHINE)
set(ARM_LINUX_SYSROOT /usr/${GNU_MACHINE}${FLOAT_ABI_SUFFIX})
endif()
-if(NOT DEFINED CMAKE_CXX_FLAGS)
- set(CMAKE_CXX_FLAGS "" CACHE INTERNAL "")
- set(CMAKE_C_FLAGS "" CACHE INTERNAL "")
- set(CMAKE_SHARED_LINKER_FLAGS "" CACHE INTERNAL "")
- set(CMAKE_MODULE_LINKER_FLAGS "" CACHE INTERNAL "")
- set(CMAKE_EXE_LINKER_FLAGS "" CACHE INTERNAL "")
``` | Looks like these options are lost: - https://pullrequest.opencv.org/buildbot/builders/precommit_armv8/builds/100061 - https://pullrequest.opencv.org/buildbot/builders/precommit_armv7/builds/100073 |
You are an expert OpenCV code reviewer specializing in code quality and best practices. Review the provided code changes and provide specific, actionable feedback. | **File:** cmake/OpenCVCompilerOptimizations.cmake
**Change Type:** modified
**Context:** PR #25901: RISC-V/AArch64: disable CPU features detection - This PR is the first step in fixing current issues with NEON/RVV, FP16, BF16 and other CPU...
**Code Changes:**
```diff
@@ -104,7 +104,7 @@ ocv_optimization_process_obsolete_option(ENABLE_AVX2 AVX2 ON)
ocv_optimization_process_obsolete_option(ENABLE_FMA3 FMA3 ON)
ocv_optimization_process_obsolete_option(ENABLE_VFPV3 VFPV3 OFF)
-ocv_optimization_process_obsolete_option(ENABLE_NEON NEON OFF)
+ocv_optimization_process_obsolete_option(ENABLE_NEON NEON ON)
ocv_optimization_process_obsolete_option(ENABLE_VSX VSX ON)
@@ -170,7 +170,29 @@ elseif(" ${CMAKE_CXX_FLAGS} " MATCHES " -march=native | -xHost | /QxHost ")
``` | `CPU_BASELINE=NATIVE` should be supported. |
You are an expert OpenCV code reviewer specializing in code quality and best practices. Review the provided code changes and provide specific, actionable feedback. | **File:** cmake/OpenCVCompilerOptimizations.cmake
**Change Type:** modified
**Context:** PR #25901: RISC-V/AArch64: disable CPU features detection - This PR is the first step in fixing current issues with NEON/RVV, FP16, BF16 and other CPU...
**Review Line:** 586
**Code Changes:**
```diff
set(CPU_${OPT}_USAGE_COUNT 0 CACHE INTERNAL "")
if("${CPU_${OPT}_FLAGS_ON}" STREQUAL "disabled")
@@ -577,7 +584,7 @@ foreach(OPT ${CPU_KNOWN_OPTIMIZATIONS})
if(CPU_${OPT}_SUPPORTED)
if(";${CPU_DISPATCH};" MATCHES ";${OPT};" AND NOT __is_from_baseline)
list(APPEND CPU_DISPATCH_FINAL ${OPT})
- elseif(__is_from_baseline)
+ elseif(__is_from_baseline AND NOT __is_disabled)
if(NOT ";${CPU_BASELINE_FINAL};" MATCHES ";${OPT};")
list(APPEND CPU_BASELINE_FINAL ${OPT})
endif()
``` | `CPU_BASELINE_DISABLE` should not affect `CPU_DISPATCH` modes. |
You are an expert OpenCV code reviewer specializing in testing and validation. Review the provided code changes and provide specific, actionable feedback. | **File:** platforms/linux/arm.toolchain.cmake
**Change Type:** modified
**Context:** PR #25901: RISC-V/AArch64: disable CPU features detection - This PR is the first step in fixing current issues with NEON/RVV, FP16, BF16 and other CPU...
**Code Changes:**
```diff
@@ -48,32 +48,23 @@ if(NOT DEFINED ARM_LINUX_SYSROOT AND DEFINED GNU_MACHINE)
set(ARM_LINUX_SYSROOT /usr/${GNU_MACHINE}${FLOAT_ABI_SUFFIX})
endif()
-if(NOT DEFINED CMAKE_CXX_FLAGS)
- set(CMAKE_CXX_FLAGS "" CACHE INTERNAL "")
- set(CMAKE_C_FLAGS "" CACHE INTERNAL "")
- set(CMAKE_SHARED_LINKER_FLAGS "" CACHE INTERNAL "")
- set(CMAKE_MODULE_LINKER_FLAGS "" CACHE INTERNAL "")
- set(CMAKE_EXE_LINKER_FLAGS "" CACHE INTERNAL "")
``` | This is because cmake version on buildbot is too old (3.5.1) for this [feature](https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_FLAGS_INIT.html) (`CMAKE_<LANG>_FLAGS_INIT`). I propose raising minimum cmake version to 3.7. |
You are an expert OpenCV code reviewer specializing in testing and validation. Review the provided code changes and provide specific, actionable feedback. | **File:** cmake/OpenCVCompilerOptimizations.cmake
**Change Type:** modified
**Context:** PR #25901: RISC-V/AArch64: disable CPU features detection - This PR is the first step in fixing current issues with NEON/RVV, FP16, BF16 and other CPU...
**Code Changes:**
```diff
@@ -104,7 +104,7 @@ ocv_optimization_process_obsolete_option(ENABLE_AVX2 AVX2 ON)
ocv_optimization_process_obsolete_option(ENABLE_FMA3 FMA3 ON)
ocv_optimization_process_obsolete_option(ENABLE_VFPV3 VFPV3 OFF)
-ocv_optimization_process_obsolete_option(ENABLE_NEON NEON OFF)
+ocv_optimization_process_obsolete_option(ENABLE_NEON NEON ON)
ocv_optimization_process_obsolete_option(ENABLE_VSX VSX ON)
@@ -170,7 +170,29 @@ elseif(" ${CMAKE_CXX_FLAGS} " MATCHES " -march=native | -xHost | /QxHost ")
``` | I'm still against forcing of `DETECT`. It could be default, but it should not be forced. We should not block user to disable some OpenCV intrinsics, e.g. for debug/testing purposes. Even if they are "enabled in compiler". |
You are an expert OpenCV code reviewer specializing in code quality and best practices. Review the provided code changes and provide specific, actionable feedback. | **File:** cmake/OpenCVCompilerOptimizations.cmake
**Change Type:** modified
**Context:** PR #25901: RISC-V/AArch64: disable CPU features detection - This PR is the first step in fixing current issues with NEON/RVV, FP16, BF16 and other CPU...
**Code Changes:**
```diff
@@ -104,7 +104,7 @@ ocv_optimization_process_obsolete_option(ENABLE_AVX2 AVX2 ON)
ocv_optimization_process_obsolete_option(ENABLE_FMA3 FMA3 ON)
ocv_optimization_process_obsolete_option(ENABLE_VFPV3 VFPV3 OFF)
-ocv_optimization_process_obsolete_option(ENABLE_NEON NEON OFF)
+ocv_optimization_process_obsolete_option(ENABLE_NEON NEON ON)
ocv_optimization_process_obsolete_option(ENABLE_VSX VSX ON)
@@ -170,7 +170,29 @@ elseif(" ${CMAKE_CXX_FLAGS} " MATCHES " -march=native | -xHost | /QxHost ")
``` | Why do we lost `_IMPLIES` configuration? |
You are an expert OpenCV code reviewer specializing in code quality and best practices. Review the provided code changes and provide specific, actionable feedback. | **File:** CMakeLists.txt
**Change Type:** modified
**Context:** PR #25901: RISC-V/AArch64: disable CPU features detection - This PR is the first step in fixing current issues with NEON/RVV, FP16, BF16 and other CPU...
**Code Changes:**
```diff
@@ -145,7 +145,7 @@ if(NOT OPENCV_SKIP_CMAKE_SYSTEM_FILE)
endif()
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) # https://cmake.org/cmake/help/latest/variable/CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT.html
- if(NOT CMAKE_TOOLCHAIN_FILE)
+ if(NOT CMAKE_CROSSCOMPILING)
if(WIN32)
set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/install" CACHE PATH "Installation Directory" FORCE)
else()
@@ -513,10 +513,6 @@ OCV_OPTION(OPENCV_ENABLE_MEMORY_SANITIZER "Better support for memory/address san
``` | There is already something for platforms: https://github.com/opencv/opencv/tree/4.x/cmake/platforms We could add similar for processors. |
You are an expert OpenCV code reviewer specializing in code quality and best practices. Review the provided code changes and provide specific, actionable feedback. | **File:** platforms/linux/flags-aarch64.cmake
**Change Type:** added
**Context:** PR #25901: RISC-V/AArch64: disable CPU features detection - This PR is the first step in fixing current issues with NEON/RVV, FP16, BF16 and other CPU...
**Code Changes:**
```diff
@@ -0,0 +1,19 @@
+# see https://gcc.gnu.org/onlinedocs/gcc/AArch64-Options.html#index-march
+function(ocv_set_platform_flags VAR)
+ unset(flags)
+ if(ENABLE_BF16)
+ set(flags "${flags}+bf16")
+ endif()
+ if(ENABLE_DOTPROD)
+ set(flags "${flags}+dotprod")
+ endif()
``` | Google uses `-march=armv8.2-a+bf16` for dispatched code: https://github.com/google/XNNPACK/blob/f416ab3d2781c8eb53eaa999239138296146b5e0/CMakeLists.txt#L836 Why do we need `8.4`? |
You are an expert OpenCV code reviewer specializing in code quality and best practices. Review the provided code changes and provide specific, actionable feedback. | **File:** CMakeLists.txt
**Change Type:** modified
**Context:** PR #25901: RISC-V/AArch64: disable CPU features detection - This PR is the first step in fixing current issues with NEON/RVV, FP16, BF16 and other CPU...
**Code Changes:**
```diff
@@ -145,7 +145,7 @@ if(NOT OPENCV_SKIP_CMAKE_SYSTEM_FILE)
endif()
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) # https://cmake.org/cmake/help/latest/variable/CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT.html
- if(NOT CMAKE_TOOLCHAIN_FILE)
+ if(NOT CMAKE_CROSSCOMPILING)
if(WIN32)
set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/install" CACHE PATH "Installation Directory" FORCE)
else()
@@ -513,10 +513,6 @@ OCV_OPTION(OPENCV_ENABLE_MEMORY_SANITIZER "Better support for memory/address san
``` | > platforms/linux OSX/iOS? android? other OS? We should not depend on "linux" here. |
You are an expert OpenCV code reviewer specializing in code quality and best practices. Review the provided code changes and provide specific, actionable feedback. | **File:** CMakeLists.txt
**Change Type:** modified
**Context:** PR #25901: RISC-V/AArch64: disable CPU features detection - This PR is the first step in fixing current issues with NEON/RVV, FP16, BF16 and other CPU...
**Code Changes:**
```diff
@@ -145,7 +145,7 @@ if(NOT OPENCV_SKIP_CMAKE_SYSTEM_FILE)
endif()
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) # https://cmake.org/cmake/help/latest/variable/CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT.html
- if(NOT CMAKE_TOOLCHAIN_FILE)
+ if(NOT CMAKE_CROSSCOMPILING)
if(WIN32)
set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/install" CACHE PATH "Installation Directory" FORCE)
else()
@@ -513,10 +513,6 @@ OCV_OPTION(OPENCV_ENABLE_MEMORY_SANITIZER "Better support for memory/address san
``` | This block's purpose is to use the same flags for native Linux compilation as for cross-compilation with **our** toolchain files. * It is not applicable to Android, because it uses own toolchain files from NDK and doesn't have native compilation (or does it?). * Also not applicable to OSX/iOS because we rely on CMake/XCode to set platform flags for specific target. * Not so sure about Windows, but it was not handled specifically by OpenCVCompilerOptimizations.cmake (we have only GCC/Clang flags there for AArch64). * Other platforms are not officially supported by us and I think we should recommend users to use there own cmake-toolchain files for these cases. |
You are an expert OpenCV code reviewer specializing in performance optimization. Review the provided code changes and provide specific, actionable feedback. | **File:** platforms/linux/flags-aarch64.cmake
**Change Type:** added
**Context:** PR #25901: RISC-V/AArch64: disable CPU features detection - This PR is the first step in fixing current issues with NEON/RVV, FP16, BF16 and other CPU...
**Code Changes:**
```diff
@@ -0,0 +1,19 @@
+# see https://gcc.gnu.org/onlinedocs/gcc/AArch64-Options.html#index-march
+function(ocv_set_platform_flags VAR)
+ unset(flags)
+ if(ENABLE_BF16)
+ set(flags "${flags}+bf16")
+ endif()
+ if(ENABLE_DOTPROD)
+ set(flags "${flags}+dotprod")
+ endif()
``` | I used this table from GCC documentation to establish baselines with assumption that actual hardware also lines up with it and there are no platforms which have `dotprod` on top of `armv8.2-a`, plus an assumption that compiler can optimize code better for such "baseline" arch. ``` arch value Architecture Includes by default ‘armv8-a’ Armv8-A ‘+fp’, ‘+simd’ ‘armv8.1-a’ Armv8.1-A ‘armv8-a’, ‘+crc’, ‘+lse’, ‘+rdma’ ‘armv8.2-a’ Armv8.2-A ‘armv8.1-a’ ‘armv8.3-a’ Armv8.3-A ‘armv8.2-a’, ‘+pauth’ ‘armv8.4-a’ Armv8.4-A ‘armv8.3-a’, ‘+flagm’, ‘+fp16fml’, ‘+dotprod’ ‘armv8.5-a’ Armv8.5-A ‘armv8.4-a’, ‘+sb’, ‘+ssbs’, ‘+predres’ ‘armv8.6-a’ Armv8.6-A ‘armv8.5-a’, ‘+bf16’, ‘+i8mm’ ``` Should I change it back to `armv8.2-a+...`? |
You are an expert OpenCV code reviewer specializing in code quality and best practices. Review the provided code changes and provide specific, actionable feedback. | **File:** CMakeLists.txt
**Change Type:** modified
**Context:** PR #25901: RISC-V/AArch64: disable CPU features detection - This PR is the first step in fixing current issues with NEON/RVV, FP16, BF16 and other CPU...
**Code Changes:**
```diff
@@ -145,7 +145,7 @@ if(NOT OPENCV_SKIP_CMAKE_SYSTEM_FILE)
endif()
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) # https://cmake.org/cmake/help/latest/variable/CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT.html
- if(NOT CMAKE_TOOLCHAIN_FILE)
+ if(NOT CMAKE_CROSSCOMPILING)
if(WIN32)
set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/install" CACHE PATH "Installation Directory" FORCE)
else()
@@ -513,10 +513,6 @@ OCV_OPTION(OPENCV_ENABLE_MEMORY_SANITIZER "Better support for memory/address san
``` | Perhaps we can move this specific block to `Linux.cmake` if it has all used variables being set at the time of importing (e.g. `CMAKE_CROSSCOMPILING`). I'll try it. |
You are an expert OpenCV code reviewer specializing in code quality and best practices. Review the provided code changes and provide specific, actionable feedback. | **File:** cmake/OpenCVCompilerOptimizations.cmake
**Change Type:** modified
**Context:** PR #25901: RISC-V/AArch64: disable CPU features detection - This PR is the first step in fixing current issues with NEON/RVV, FP16, BF16 and other CPU...
**Code Changes:**
```diff
@@ -104,7 +104,7 @@ ocv_optimization_process_obsolete_option(ENABLE_AVX2 AVX2 ON)
ocv_optimization_process_obsolete_option(ENABLE_FMA3 FMA3 ON)
ocv_optimization_process_obsolete_option(ENABLE_VFPV3 VFPV3 OFF)
-ocv_optimization_process_obsolete_option(ENABLE_NEON NEON OFF)
+ocv_optimization_process_obsolete_option(ENABLE_NEON NEON ON)
ocv_optimization_process_obsolete_option(ENABLE_VSX VSX ON)
@@ -170,7 +170,29 @@ elseif(" ${CMAKE_CXX_FLAGS} " MATCHES " -march=native | -xHost | /QxHost ")
``` | I had concerns that it might affect compilation flags for dispatched or baseline files. I'll try to restore it. |
You are an expert OpenCV code reviewer specializing in code quality and best practices. Review the provided code changes and provide specific, actionable feedback. | **File:** cmake/OpenCVCompilerOptimizations.cmake
**Change Type:** modified
**Context:** PR #25901: RISC-V/AArch64: disable CPU features detection - This PR is the first step in fixing current issues with NEON/RVV, FP16, BF16 and other CPU...
**Code Changes:**
```diff
@@ -104,7 +104,7 @@ ocv_optimization_process_obsolete_option(ENABLE_AVX2 AVX2 ON)
ocv_optimization_process_obsolete_option(ENABLE_FMA3 FMA3 ON)
ocv_optimization_process_obsolete_option(ENABLE_VFPV3 VFPV3 OFF)
-ocv_optimization_process_obsolete_option(ENABLE_NEON NEON OFF)
+ocv_optimization_process_obsolete_option(ENABLE_NEON NEON ON)
ocv_optimization_process_obsolete_option(ENABLE_VSX VSX ON)
@@ -170,7 +170,29 @@ elseif(" ${CMAKE_CXX_FLAGS} " MATCHES " -march=native | -xHost | /QxHost ")
``` | I've added support of an empty `CPU_BASELINE`. Currently this configuration is broken due to incorrect macros being used somewhere in DNN inline optimizations: compiler has feature enabled and some macros are enabled too, but some other macros from generated cv_cpu_config.hpp are disabled, thus causing missing symbols. ``` /usr/bin/ld: modules/dnn/CMakeFiles/opencv_dnn.dir/src/layers/cpu_kernels/conv_winograd_f63.cpp.o: in function `cv::dnn::runWinograd63(cv::_InputArray const&, cv::_InputArray const&, cv::_OutputArray const&, cv::Ptr<cv::dnn::FastConv> const&, int, float, float, cv::dnn::dnn4_v20240521::ActivationLayer*, bool)::{lambda(cv::Range const&)#1}::operator()(cv::Range const&) const': /work/opencv/modules/dnn/src/layers/cpu_kernels/conv_winograd_f63.cpp:205: undefined reference to `cv::dnn::winofunc_BtXB_8x8_F32(float const*, int, float*, int, int, int)' /usr/bin/ld: modules/dnn/CMakeFiles/opencv_dnn.dir/src/layers/cpu_kernels/conv_winograd_f63.cpp.o: in function `cv::dnn::runWinograd63(cv::_InputArray const&, cv::_InputArray const&, cv::_OutputArray const&, cv::Ptr<cv::dnn::FastConv> const&, int, float, float, cv::dnn::dnn4_v20240521::ActivationLayer*, bool)::{lambda(cv::Range const&)#2}::operator()(cv::Range const&) const': /work/opencv/modules/dnn/src/layers/cpu_kernels/conv_winograd_f63.cpp:302: undefined reference to `cv::dnn::winofunc_accum_F32(float const*, float const*, float*, int, int, int, int, int, int)' /usr/bin/ld: /work/opencv/modules/dnn/src/layers/cpu_kernels/conv_winograd_f63.cpp:368: undefined reference to `cv::dnn::winofunc_AtXA_8x8_F32(float const*, int, float*, int, float*, int, float, float, float, bool)' collect2: error: ld returned 1 exit status ``` It is not related to this PR and we'll need to resolve this issue separately, my quick fix attempt has failed. |
You are an expert OpenCV code reviewer specializing in code quality and best practices. Review the provided code changes and provide specific, actionable feedback. | **File:** platforms/linux/flags-aarch64.cmake
**Change Type:** added
**Context:** PR #25901: RISC-V/AArch64: disable CPU features detection - This PR is the first step in fixing current issues with NEON/RVV, FP16, BF16 and other CPU...
**Code Changes:**
```diff
@@ -0,0 +1,19 @@
+# see https://gcc.gnu.org/onlinedocs/gcc/AArch64-Options.html#index-march
+function(ocv_set_platform_flags VAR)
+ unset(flags)
+ if(ENABLE_BF16)
+ set(flags "${flags}+bf16")
+ endif()
+ if(ENABLE_DOTPROD)
+ set(flags "${flags}+dotprod")
+ endif()
``` | Changed it to use `armv8.2-a+...` combination with feature flags. It became slightly more complicated, but I believe it's OK. Please let me know if we need to revert it. |
You are an expert OpenCV code reviewer specializing in testing and validation. Review the provided code changes and provide specific, actionable feedback. | **File:** cmake/OpenCVCompilerOptimizations.cmake
**Change Type:** modified
**Context:** PR #25901: RISC-V/AArch64: disable CPU features detection - This PR is the first step in fixing current issues with NEON/RVV, FP16, BF16 and other CPU...
**Code Changes:**
```diff
@@ -104,7 +104,7 @@ ocv_optimization_process_obsolete_option(ENABLE_AVX2 AVX2 ON)
ocv_optimization_process_obsolete_option(ENABLE_FMA3 FMA3 ON)
ocv_optimization_process_obsolete_option(ENABLE_VFPV3 VFPV3 OFF)
-ocv_optimization_process_obsolete_option(ENABLE_NEON NEON OFF)
+ocv_optimization_process_obsolete_option(ENABLE_NEON NEON ON)
ocv_optimization_process_obsolete_option(ENABLE_VSX VSX ON)
@@ -170,7 +170,29 @@ elseif(" ${CMAKE_CXX_FLAGS} " MATCHES " -march=native | -xHost | /QxHost ")
``` | Just "empty" handling is not enough. > We should not block user to disable some OpenCV intrinsics, e.g. for debug/testing purposes. Even if they are "enabled in compiler". |
You are an expert OpenCV code reviewer specializing in code quality and best practices. Review the provided code changes and provide specific, actionable feedback. | **File:** CMakeLists.txt
**Change Type:** modified
**Context:** PR #25901: RISC-V/AArch64: disable CPU features detection - This PR is the first step in fixing current issues with NEON/RVV, FP16, BF16 and other CPU...
**Code Changes:**
```diff
@@ -145,7 +145,7 @@ if(NOT OPENCV_SKIP_CMAKE_SYSTEM_FILE)
endif()
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) # https://cmake.org/cmake/help/latest/variable/CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT.html
- if(NOT CMAKE_TOOLCHAIN_FILE)
+ if(NOT CMAKE_CROSSCOMPILING)
if(WIN32)
set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/install" CACHE PATH "Installation Directory" FORCE)
else()
@@ -513,10 +513,6 @@ OCV_OPTION(OPENCV_ENABLE_MEMORY_SANITIZER "Better support for memory/address san
``` | Lets move out that from the root CMake file. |
You are an expert OpenCV code reviewer specializing in documentation and code clarity. Review the provided code changes and provide specific, actionable feedback. | **File:** cmake/OpenCVCompilerOptimizations.cmake
**Change Type:** modified
**Context:** PR #25901: RISC-V/AArch64: disable CPU features detection - This PR is the first step in fixing current issues with NEON/RVV, FP16, BF16 and other CPU...
**Code Changes:**
```diff
@@ -104,7 +104,7 @@ ocv_optimization_process_obsolete_option(ENABLE_AVX2 AVX2 ON)
ocv_optimization_process_obsolete_option(ENABLE_FMA3 FMA3 ON)
ocv_optimization_process_obsolete_option(ENABLE_VFPV3 VFPV3 OFF)
-ocv_optimization_process_obsolete_option(ENABLE_NEON NEON OFF)
+ocv_optimization_process_obsolete_option(ENABLE_NEON NEON ON)
ocv_optimization_process_obsolete_option(ENABLE_VSX VSX ON)
@@ -170,7 +170,29 @@ elseif(" ${CMAKE_CXX_FLAGS} " MATCHES " -march=native | -xHost | /QxHost ")
``` | User can disable OpenCV intrinsics on affected platforms in two ways: * set `-DCPU_BASELINE=` - disable all intrinsics * set `-DCPU_BASELINE_DISABLE=RVV` - disable selected categories Example: ``` cmake \ -DRISCV_CLANG_BUILD_ROOT=/chains/llvm-main -DRISCV_GCC_INSTALL_ROOT=/chains/riscv-gcc-14.1.0 -DCMAKE_TOOLCHAIN_FILE=/opencv/platforms/linux/riscv64-clang.toolchain.cmake -DBUILD_SHARED_LIBS=OFF -DWITH_OPENCL=OFF \ -DENABLE_RVV=ON \ # choose RVV flags in the toolchain -DCPU_BASELINE= \ # disable all intrinsics -DBUILD_opencv_dnn=OFF \ # know issue -DCMAKE_BUILD_TYPE=Release \ ../opencv ``` CMake output: ``` ... -- CPU/HW features: -- Baseline: ... -- C++ flags (Release): -march=rv64gcv --gcc-toolchain=/chains/riscv-gcc-14.1.0 -w -fsigned-char -W -Wall -Wreturn-type -Wnon-virtual-dtor -Waddress -Wsequence-point -Wformat -Wformat-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winconsistent-missing-override -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -Wno-deprecated-enum-enum-conversion -Wno-deprecated-anon-enum-enum-conversion -fdiagnostics-show-option -pthread -Qunused-arguments -ffunction-sections -fdata-sections -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG -DNDEBUG ... ``` Generated cv_cpu_config.h: ```.h // OpenCV CPU baseline features #define CV_CPU_BASELINE_FEATURES 0 \ // OpenCV supported CPU dispatched features #define CV_CPU_DISPATCH_FEATURES 0 \ ``` ------- If we don't change `CPU_BASELINE` (leave it `DETECT`), then OpenCV intrinsics will be enabled, cv_cpu_config.h: ``` // OpenCV CPU baseline features #define CV_CPU_COMPILE_RVV 1 #define CV_CPU_BASELINE_COMPILE_RVV 1 #define CV_CPU_BASELINE_FEATURES 0 \ , CV_CPU_RVV \ // OpenCV supported CPU dispatched features #define CV_CPU_DISPATCH_FEATURES 0 \ ``` |
You are an expert OpenCV code reviewer specializing in code quality and best practices. Review the provided code changes and provide specific, actionable feedback. | **File:** CMakeLists.txt
**Change Type:** modified
**Context:** PR #25901: RISC-V/AArch64: disable CPU features detection - This PR is the first step in fixing current issues with NEON/RVV, FP16, BF16 and other CPU...
**Code Changes:**
```diff
@@ -145,7 +145,7 @@ if(NOT OPENCV_SKIP_CMAKE_SYSTEM_FILE)
endif()
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) # https://cmake.org/cmake/help/latest/variable/CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT.html
- if(NOT CMAKE_TOOLCHAIN_FILE)
+ if(NOT CMAKE_CROSSCOMPILING)
if(WIN32)
set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/install" CACHE PATH "Installation Directory" FORCE)
else()
@@ -513,10 +513,6 @@ OCV_OPTION(OPENCV_ENABLE_MEMORY_SANITIZER "Better support for memory/address san
``` | Moved to `cmake/platforms/OpenCV-Linux.cmake` |
You are an expert OpenCV code reviewer specializing in code quality and best practices. Review the provided code changes and provide specific, actionable feedback. | **File:** cmake/OpenCVCompilerOptimizations.cmake
**Change Type:** modified
**Context:** PR #25901: RISC-V/AArch64: disable CPU features detection - This PR is the first step in fixing current issues with NEON/RVV, FP16, BF16 and other CPU...
**Code Changes:**
```diff
@@ -104,7 +104,7 @@ ocv_optimization_process_obsolete_option(ENABLE_AVX2 AVX2 ON)
ocv_optimization_process_obsolete_option(ENABLE_FMA3 FMA3 ON)
ocv_optimization_process_obsolete_option(ENABLE_VFPV3 VFPV3 OFF)
-ocv_optimization_process_obsolete_option(ENABLE_NEON NEON OFF)
+ocv_optimization_process_obsolete_option(ENABLE_NEON NEON ON)
ocv_optimization_process_obsolete_option(ENABLE_VSX VSX ON)
@@ -170,7 +170,29 @@ elseif(" ${CMAKE_CXX_FLAGS} " MATCHES " -march=native | -xHost | /QxHost ")
``` | Lets remove `set(CPU_BASELINE "DETECT")`. Warning message is enough. |
You are an expert OpenCV code reviewer specializing in documentation and code clarity. Review the provided code changes and provide specific, actionable feedback. | **File:** cmake/platforms/OpenCV-Linux.cmake
**Change Type:** modified
**Context:** PR #25901: RISC-V/AArch64: disable CPU features detection - This PR is the first step in fixing current issues with NEON/RVV, FP16, BF16 and other CPU...
**Code Changes:**
```diff
@@ -1 +1,9 @@
-# empty
+if((CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
+ AND NOT CMAKE_CROSSCOMPILING
+ AND NOT CMAKE_TOOLCHAIN_FILE)
+ if(CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64") # Maybe use AARCH64 variable?
+ include(${CMAKE_CURRENT_LIST_DIR}/../../platforms/linux/flags-aarch64.cmake)
+ elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "riscv64")
+ include(${CMAKE_CURRENT_LIST_DIR}/../../platforms/linux/flags-riscv64.cmake)
+ endif()
``` | Lets remove this comment as file is not "intentionally empty" anymore. |
You are an expert OpenCV code reviewer specializing in code quality and best practices. Review the provided code changes and provide specific, actionable feedback. | **File:** platforms/linux/arm.toolchain.cmake
**Change Type:** modified
**Context:** PR #25901: RISC-V/AArch64: disable CPU features detection - This PR is the first step in fixing current issues with NEON/RVV, FP16, BF16 and other CPU...
**Code Changes:**
```diff
@@ -48,32 +48,23 @@ if(NOT DEFINED ARM_LINUX_SYSROOT AND DEFINED GNU_MACHINE)
set(ARM_LINUX_SYSROOT /usr/${GNU_MACHINE}${FLOAT_ABI_SUFFIX})
endif()
-if(NOT DEFINED CMAKE_CXX_FLAGS)
- set(CMAKE_CXX_FLAGS "" CACHE INTERNAL "")
- set(CMAKE_C_FLAGS "" CACHE INTERNAL "")
- set(CMAKE_SHARED_LINKER_FLAGS "" CACHE INTERNAL "")
- set(CMAKE_MODULE_LINKER_FLAGS "" CACHE INTERNAL "")
- set(CMAKE_EXE_LINKER_FLAGS "" CACHE INTERNAL "")
``` | My experiments has shown that unfortunately `FLAGS_INIT` vars do not work with regular `FLAGS` variables as I expected. They are not appended to initial value, but override it: ``` cmake \ -DCMAKE_TOOLCHAIN_FILE=/work/opencv/platforms/linux/riscv64-clang.toolchain.cmake \ ../opencv # result: -march=rv64gc ... # this is flag from our toolchain file cmake \ -DCMAKE_TOOLCHAIN_FILE=/work/opencv/platforms/linux/riscv64-clang.toolchain.cmake \ -DCMAKE_CXX_FLAGS="-Werror" \ ../opencv # result: -Werror ... # no -march flags from toolchain file ``` Correct way to add custom flags to cross-compilation in this case will be via * `CMAKE_<LANG>_FLAGS_<CONFIG>` variable, or * `<LANG>FLAGS` environment variable, or * OpenCV-specific variables `OPENCV_EXTRA_<LANG>_FLAGS`, or * custom toolchain-file. I believe this behavior is acceptable because this is how cmake works. |
You are an expert OpenCV code reviewer specializing in code quality and best practices. Review the provided code changes and provide specific, actionable feedback. | **File:** platforms/linux/flags-aarch64.cmake
**Change Type:** added
**Context:** PR #25901: RISC-V/AArch64: disable CPU features detection - This PR is the first step in fixing current issues with NEON/RVV, FP16, BF16 and other CPU...
**Code Changes:**
```diff
@@ -0,0 +1,19 @@
+# see https://gcc.gnu.org/onlinedocs/gcc/AArch64-Options.html#index-march
+function(ocv_set_platform_flags VAR)
+ unset(flags)
+ if(ENABLE_BF16)
+ set(flags "${flags}+bf16")
+ endif()
+ if(ENABLE_DOTPROD)
+ set(flags "${flags}+dotprod")
+ endif()
``` | Also added to the toolchain ability to disable NEON for AArch64 by explicitly setting `ENABLE_NEON` to `OFF`. |
You are an expert OpenCV code reviewer specializing in performance optimization. Review the provided code changes and provide specific, actionable feedback. | **File:** cmake/OpenCVCompilerOptimizations.cmake
**Change Type:** modified
**Context:** PR #25901: RISC-V/AArch64: disable CPU features detection - This PR is the first step in fixing current issues with NEON/RVV, FP16, BF16 and other CPU...
**Code Changes:**
```diff
@@ -104,7 +104,7 @@ ocv_optimization_process_obsolete_option(ENABLE_AVX2 AVX2 ON)
ocv_optimization_process_obsolete_option(ENABLE_FMA3 FMA3 ON)
ocv_optimization_process_obsolete_option(ENABLE_VFPV3 VFPV3 OFF)
-ocv_optimization_process_obsolete_option(ENABLE_NEON NEON OFF)
+ocv_optimization_process_obsolete_option(ENABLE_NEON NEON ON)
ocv_optimization_process_obsolete_option(ENABLE_VSX VSX ON)
@@ -170,7 +170,29 @@ elseif(" ${CMAKE_CXX_FLAGS} " MATCHES " -march=native | -xHost | /QxHost ")
``` | The goal is to avoid modifying compiler flags unnecessarily, as this can lead to incompatibilities and performance issues, especially when specific CPU architectures are requested. Users should have the option to manually set flags for dispatched files via CPU_XXX_FLAGS_ON. In the case of RVV, -DCPU_DISPATCH=RVV -DCPU_RVV_FLAGS_ON=-march=rv64gcv can handle dispatched optimizations without affecting the baseline configuration. |
You are an expert OpenCV code reviewer specializing in code quality and best practices. Review the provided code changes and provide specific, actionable feedback. | **File:** cmake/OpenCVUtils.cmake
**Change Type:** modified
**Context:** PR #26234: move the gcc6 compatibility check to occur on a per-directory basis, …
**Code Changes:**
```diff
@@ -353,23 +353,23 @@ function(ocv_target_include_directories target)
#ocv_debug_message("ocv_target_include_directories(${target} ${ARGN})")
_ocv_fix_target(target)
set(__params "")
- if(CV_GCC AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS "6.0" AND
- ";${ARGN};" MATCHES "/usr/include;")
- return() # workaround for GCC 6.x bug
- endif()
- set(__params "")
set(__system_params "")
``` | > `"${dir}"` Please use `dir MATCHES ...` without variable unpacking. |
You are an expert OpenCV code reviewer specializing in code quality and best practices. Review the provided code changes and provide specific, actionable feedback. | **File:** cmake/OpenCVUtils.cmake
**Change Type:** modified
**Context:** PR #26234: move the gcc6 compatibility check to occur on a per-directory basis, …
**Code Changes:**
```diff
@@ -353,23 +353,23 @@ function(ocv_target_include_directories target)
#ocv_debug_message("ocv_target_include_directories(${target} ${ARGN})")
_ocv_fix_target(target)
set(__params "")
- if(CV_GCC AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS "6.0" AND
- ";${ARGN};" MATCHES "/usr/include;")
- return() # workaround for GCC 6.x bug
- endif()
- set(__params "")
set(__system_params "")
``` | Use `dir MATCHES "/usr/include$"` See line 309 |
You are an expert OpenCV code reviewer specializing in code quality and best practices. Review the provided code changes and provide specific, actionable feedback. | **File:** cmake/OpenCVUtils.cmake
**Change Type:** modified
**Context:** PR #26234: move the gcc6 compatibility check to occur on a per-directory basis, …
**Code Changes:**
```diff
@@ -353,23 +353,23 @@ function(ocv_target_include_directories target)
#ocv_debug_message("ocv_target_include_directories(${target} ${ARGN})")
_ocv_fix_target(target)
set(__params "")
- if(CV_GCC AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS "6.0" AND
- ";${ARGN};" MATCHES "/usr/include;")
- return() # workaround for GCC 6.x bug
- endif()
- set(__params "")
set(__system_params "")
``` | got it! sorry about that |
You are an expert OpenCV code reviewer specializing in code quality and best practices. Review the provided code changes and provide specific, actionable feedback. | **File:** doc/tutorials/features2d/akaze_matching/akaze_matching.markdown
**Change Type:** modified
**Context:** PR #25292: features2d cleanup: Move several feature detectors and descriptors to opencv_contrib - features2d cleanup: #24999 The PR moves KAZE, AKAZE,...
**Code Changes:**
```diff
@@ -22,6 +22,8 @@ number of inliers (i.e. matches that fit in the given homography).
You can find expanded version of this example here:
<https://github.com/pablofdezalc/test_kaze_akaze_opencv>
+\warning You need the [OpenCV contrib module *xfeatures2d*](https://github.com/opencv/opencv_contrib/tree/5.x/modules/xfeatures2d) to be able to use the AKAZE features.
+
Data
----
@@ -42,23 +44,23 @@ You can find the images (*graf1.png*, *graf3.png*) and homography (*H1to3p.xml*)
``` | Use markdown notation for links. |
You are an expert OpenCV code reviewer specializing in code quality and best practices. Review the provided code changes and provide specific, actionable feedback. | **File:** doc/tutorials/features2d/akaze_tracking/akaze_tracking.markdown
**Change Type:** modified
**Context:** PR #25292: features2d cleanup: Move several feature detectors and descriptors to opencv_contrib - features2d cleanup: #24999 The PR moves KAZE, AKAZE,...
**Code Changes:**
```diff
@@ -17,6 +17,8 @@ Introduction
In this tutorial we will compare *AKAZE* and *ORB* local features using them to find matches between
video frames and track object movements.
+\warning You need the [OpenCV contrib module *xfeatures2d*](https://github.com/opencv/opencv_contrib/tree/5.x/modules/xfeatures2d) to be able to use the AKAZE features.
+
The algorithm is as follows:
- Detect and describe keypoints on the first frame, manually set object boundaries
``` | Use markdown notation for links. |
You are an expert OpenCV code reviewer specializing in testing and validation. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/imgproc/perf/perf_warp.cpp
**Change Type:** modified
**Context:** PR #25984: imgproc: add optimized warpAffine kernels for 8U/16U/32F + C1/C3/C4 inputs
**Review Line:** 50
**Code Changes:**
```diff
+ }
+ case CV_16U: {
+ cvtest::fillGradient<uint16_t>(src);
+ if(borderMode == BORDER_CONSTANT) cvtest::smoothBorder<uint16_t>(src, borderColor, 1);
+ break;
+ }
+ case CV_32F: {
+ cvtest::fillGradient<float>(src);
+ if(borderMode == BORDER_CONSTANT) cvtest::smoothBorder<float>(src, borderColor, 1);
+ break;
+ }
``` | OpenVX support is removed in https://github.com/opencv/opencv/pull/25197. So I remove this test. Also removed perf data from `$opencv_extra/testdata/perf/imgproc.xml`. |
You are an expert OpenCV code reviewer specializing in testing and validation. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/imgproc/perf/perf_warp.cpp
**Change Type:** modified
**Context:** PR #25984: imgproc: add optimized warpAffine kernels for 8U/16U/32F + C1/C3/C4 inputs
**Review Line:** 117
**Code Changes:**
```diff
-
PERF_TEST_P( TestWarpPerspectiveNear_t, WarpPerspectiveNear,
Combine(
Values( Size(640,480), Size(1920,1080), Size(2592,1944) ),
@@ -168,8 +117,8 @@ PERF_TEST_P( TestWarpPerspectiveNear_t, WarpPerspectiveNear,
Scalar borderColor = Scalar::all(150);
Mat src(size, type), dst(size, type);
- cvtest::fillGradient(src);
- if(borderMode == BORDER_CONSTANT) cvtest::smoothBorder(src, borderColor, 1);
+ cvtest::fillGradient<uint8_t>(src);
``` | OpenVX support is removed in https://github.com/opencv/opencv/pull/25197. So I remove this test. Also removed perf data from `$opencv_extra/testdata/perf/imgproc.xml`. |
You are an expert OpenCV code reviewer specializing in code quality and best practices. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/imgproc/CMakeLists.txt
**Change Type:** modified
**Context:** PR #25984: imgproc: add optimized warpAffine kernels for 8U/16U/32F + C1/C3/C4 inputs
**Code Changes:**
```diff
@@ -10,6 +10,7 @@ ocv_add_dispatched_file(median_blur SSE2 SSE4_1 AVX2)
ocv_add_dispatched_file(morph SSE2 SSE4_1 AVX2)
ocv_add_dispatched_file(smooth SSE2 SSE4_1 AVX2)
ocv_add_dispatched_file(sumpixels SSE2 AVX2 AVX512_SKX)
+ocv_add_dispatched_file(warp_kernels SSE2 SSE4_1 AVX2 NEON NEON_FP16 RVV LASX)
ocv_define_module(imgproc opencv_core WRAP java objc python js)
ocv_module_include_directories(opencv_imgproc ${ZLIB_INCLUDE_DIRS})
``` | what about NEON_FP16? |
You are an expert OpenCV code reviewer specializing in testing and validation. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/imgproc/CMakeLists.txt
**Change Type:** modified
**Context:** PR #25984: imgproc: add optimized warpAffine kernels for 8U/16U/32F + C1/C3/C4 inputs
**Code Changes:**
```diff
@@ -10,6 +10,7 @@ ocv_add_dispatched_file(median_blur SSE2 SSE4_1 AVX2)
ocv_add_dispatched_file(morph SSE2 SSE4_1 AVX2)
ocv_add_dispatched_file(smooth SSE2 SSE4_1 AVX2)
ocv_add_dispatched_file(sumpixels SSE2 AVX2 AVX512_SKX)
+ocv_add_dispatched_file(warp_kernels SSE2 SSE4_1 AVX2 NEON NEON_FP16 RVV LASX)
ocv_define_module(imgproc opencv_core WRAP java objc python js)
ocv_module_include_directories(opencv_imgproc ${ZLIB_INCLUDE_DIRS})
``` | Added. But actually `FP16` is set to be one of the baselines according to the CMake log: ``` -- CPU/HW features: -- Baseline: NEON FP16 -- Dispatched code generation: NEON_DOTPROD NEON_FP16 NEON_BF16 -- requested: NEON_FP16 NEON_BF16 NEON_DOTPROD -- NEON_DOTPROD (1 files): + NEON_DOTPROD -- NEON_FP16 (3 files): + NEON_FP16 -- NEON_BF16 (0 files): + NEON_BF16 ``` `FP16` enables `NEON_FP16`. So performance testing results are not changing. |
You are an expert OpenCV code reviewer specializing in header file design and interface. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/core/include/opencv2/core/hal/intrin_neon.hpp
**Change Type:** modified
**Context:** PR #25984: imgproc: add optimized warpAffine kernels for 8U/16U/32F + C1/C3/C4 inputs
**Review Line:** 2231
**Code Changes:**
```diff
inline v_int16x8 v_floor(const v_float16x8 &a)
{
- int16x8_t a1 = vcvtq_s16_f16(a.val);
- uint16x8_t mask = vcgtq_f16(vcvtq_f16_s16(a1), a.val);
- return v_int16x8(vaddq_s16(a1, vreinterpretq_s16_u16(mask)));
+ return v_int16x8(vcvtmq_s16_f16(a.val));
}
inline v_int16x8 v_ceil(const v_float16x8 &a)
@@ -2271,9 +2269,13 @@ inline v_int32x4 v_round(const v_float32x4& a)
#endif
``` | The instruction is not available on armv7, but available on aarch32 and aarch64. We need macro check here. |
You are an expert OpenCV code reviewer specializing in header file design and interface. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/core/include/opencv2/core/hal/intrin_neon.hpp
**Change Type:** modified
**Context:** PR #25984: imgproc: add optimized warpAffine kernels for 8U/16U/32F + C1/C3/C4 inputs
**Code Changes:**
```diff
@@ -2228,9 +2228,7 @@ inline v_int16x8 v_round(const v_float16x8 &a)
inline v_int16x8 v_floor(const v_float16x8 &a)
{
- int16x8_t a1 = vcvtq_s16_f16(a.val);
- uint16x8_t mask = vcgtq_f16(vcvtq_f16_s16(a1), a.val);
- return v_int16x8(vaddq_s16(a1, vreinterpretq_s16_u16(mask)));
+ return v_int16x8(vcvtmq_s16_f16(a.val));
}
``` | The instruction is available on aarch32 too https://developer.arm.com/architectures/instruction-sets/intrinsics/vcvtmq_s32_f32 |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/imgproc/perf/perf_warp.cpp
**Change Type:** modified
**Context:** PR #25984: imgproc: add optimized warpAffine kernels for 8U/16U/32F + C1/C3/C4 inputs
**Code Changes:**
```diff
@@ -12,7 +12,7 @@ CV_ENUM(InterType, INTER_NEAREST, INTER_LINEAR)
CV_ENUM(InterTypeExtended, INTER_NEAREST, INTER_LINEAR, WARP_RELATIVE_MAP)
CV_ENUM(RemapMode, HALF_SIZE, UPSIDE_DOWN, REFLECTION_X, REFLECTION_BOTH)
-typedef TestBaseWithParam< tuple<MatType, Size, InterType, BorderMode> > TestWarpAffine;
+typedef TestBaseWithParam< tuple<Size, InterType, BorderMode, MatType> > TestWarpAffine;
typedef TestBaseWithParam< tuple<Size, InterType, BorderMode, int> > TestWarpPerspective;
typedef TestBaseWithParam< tuple<Size, InterType, BorderMode, MatType> > TestWarpPerspectiveNear_t;
typedef TestBaseWithParam< tuple<MatType, Size, InterTypeExtended, BorderMode, RemapMode> > TestRemap;
@@ -21,24 +21,39 @@ void update_map(const Mat& src, Mat& map_x, Mat& map_y, const int remapMode, boo
``` | no need in extra line here. |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/imgproc/test/test_imgwarp_strict.cpp
**Change Type:** modified
**Context:** PR #25984: imgproc: add optimized warpAffine kernels for 8U/16U/32F + C1/C3/C4 inputs
**Code Changes:**
```diff
@@ -150,7 +150,7 @@ void CV_ImageWarpBaseTest::generate_test_data()
while (depth == CV_8S || depth == CV_32S)
depth = rng.uniform(0, CV_64F);
- int cn = rng.uniform(1, 4);
+ int cn = rng.uniform(1, 5);
src.create(ssize, CV_MAKE_TYPE(depth, cn));
@@ -1045,6 +1045,13 @@ class CV_WarpAffine_Test :
``` | please remove. |
You are an expert OpenCV code reviewer specializing in testing and validation. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/imgproc/perf/perf_warp.cpp
**Change Type:** modified
**Context:** PR #25984: imgproc: add optimized warpAffine kernels for 8U/16U/32F + C1/C3/C4 inputs
**Code Changes:**
```diff
@@ -12,7 +12,7 @@ CV_ENUM(InterType, INTER_NEAREST, INTER_LINEAR)
CV_ENUM(InterTypeExtended, INTER_NEAREST, INTER_LINEAR, WARP_RELATIVE_MAP)
CV_ENUM(RemapMode, HALF_SIZE, UPSIDE_DOWN, REFLECTION_X, REFLECTION_BOTH)
-typedef TestBaseWithParam< tuple<MatType, Size, InterType, BorderMode> > TestWarpAffine;
+typedef TestBaseWithParam< tuple<Size, InterType, BorderMode, MatType> > TestWarpAffine;
typedef TestBaseWithParam< tuple<Size, InterType, BorderMode, int> > TestWarpPerspective;
typedef TestBaseWithParam< tuple<Size, InterType, BorderMode, MatType> > TestWarpPerspectiveNear_t;
typedef TestBaseWithParam< tuple<MatType, Size, InterTypeExtended, BorderMode, RemapMode> > TestRemap;
@@ -21,24 +21,39 @@ void update_map(const Mat& src, Mat& map_x, Mat& map_y, const int remapMode, boo
``` | Will remove later. Need this for testing purposes. |
You are an expert OpenCV code reviewer specializing in header file design and interface. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/imgproc/src/warp_kernels.simd.hpp
**Change Type:** added
**Context:** PR #25984: imgproc: add optimized warpAffine kernels for 8U/16U/32F + C1/C3/C4 inputs
**Code Changes:**
```diff
@@ -0,0 +1,2137 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html.
+
+#include <numeric>
+#include "precomp.hpp"
+#include "warp_common.hpp"
+#include "opencv2/core/hal/intrin.hpp"
+
``` | Will try in the next commit. |
You are an expert OpenCV code reviewer specializing in header file design and interface. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/core/include/opencv2/core/hal/intrin_neon.hpp
**Change Type:** modified
**Context:** PR #25984: imgproc: add optimized warpAffine kernels for 8U/16U/32F + C1/C3/C4 inputs
**Code Changes:**
```diff
@@ -2228,9 +2228,7 @@ inline v_int16x8 v_round(const v_float16x8 &a)
inline v_int16x8 v_floor(const v_float16x8 &a)
{
- int16x8_t a1 = vcvtq_s16_f16(a.val);
- uint16x8_t mask = vcgtq_f16(vcvtq_f16_s16(a1), a.val);
- return v_int16x8(vaddq_s16(a1, vreinterpretq_s16_u16(mask)));
+ return v_int16x8(vcvtmq_s16_f16(a.val));
}
``` | I was struggled at armv7 support. There is no existing macros indicating if target supports only armv7. |
You are an expert OpenCV code reviewer specializing in header file design and interface. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/core/include/opencv2/core/hal/intrin_neon.hpp
**Change Type:** modified
**Context:** PR #25984: imgproc: add optimized warpAffine kernels for 8U/16U/32F + C1/C3/C4 inputs
**Review Line:** 2231
**Code Changes:**
```diff
inline v_int16x8 v_floor(const v_float16x8 &a)
{
- int16x8_t a1 = vcvtq_s16_f16(a.val);
- uint16x8_t mask = vcgtq_f16(vcvtq_f16_s16(a1), a.val);
- return v_int16x8(vaddq_s16(a1, vreinterpretq_s16_u16(mask)));
+ return v_int16x8(vcvtmq_s16_f16(a.val));
}
inline v_int16x8 v_ceil(const v_float16x8 &a)
@@ -2271,9 +2269,13 @@ inline v_int32x4 v_round(const v_float32x4& a)
#endif
``` | Do we have an existing macro indicating the target platform is armv7? |
You are an expert OpenCV code reviewer specializing in header file design and interface. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/core/include/opencv2/core/hal/intrin_neon.hpp
**Change Type:** modified
**Context:** PR #25984: imgproc: add optimized warpAffine kernels for 8U/16U/32F + C1/C3/C4 inputs
**Code Changes:**
```diff
@@ -2228,9 +2228,7 @@ inline v_int16x8 v_round(const v_float16x8 &a)
inline v_int16x8 v_floor(const v_float16x8 &a)
{
- int16x8_t a1 = vcvtq_s16_f16(a.val);
- uint16x8_t mask = vcgtq_f16(vcvtq_f16_s16(a1), a.val);
- return v_int16x8(vaddq_s16(a1, vreinterpretq_s16_u16(mask)));
+ return v_int16x8(vcvtmq_s16_f16(a.val));
}
``` | There is manual "CAROTENE_NEON_ARCH" option. Looks like we need build check or handle march option correctly. |
You are an expert OpenCV code reviewer specializing in header file design and interface. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/core/include/opencv2/core/hal/intrin_neon.hpp
**Change Type:** modified
**Context:** PR #25984: imgproc: add optimized warpAffine kernels for 8U/16U/32F + C1/C3/C4 inputs
**Code Changes:**
```diff
@@ -2228,9 +2228,7 @@ inline v_int16x8 v_round(const v_float16x8 &a)
inline v_int16x8 v_floor(const v_float16x8 &a)
{
- int16x8_t a1 = vcvtq_s16_f16(a.val);
- uint16x8_t mask = vcgtq_f16(vcvtq_f16_s16(a1), a.val);
- return v_int16x8(vaddq_s16(a1, vreinterpretq_s16_u16(mask)));
+ return v_int16x8(vcvtmq_s16_f16(a.val));
}
``` | > need build check or handle march option correctly. That sounds like a dedicated PR. How about guard it (as well as the above one) with `CV_NEON_AARCH64` for now? |
You are an expert OpenCV code reviewer specializing in header file design and interface. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/core/include/opencv2/core/hal/intrin_neon.hpp
**Change Type:** modified
**Context:** PR #25984: imgproc: add optimized warpAffine kernels for 8U/16U/32F + C1/C3/C4 inputs
**Review Line:** 2231
**Code Changes:**
```diff
inline v_int16x8 v_floor(const v_float16x8 &a)
{
- int16x8_t a1 = vcvtq_s16_f16(a.val);
- uint16x8_t mask = vcgtq_f16(vcvtq_f16_s16(a1), a.val);
- return v_int16x8(vaddq_s16(a1, vreinterpretq_s16_u16(mask)));
+ return v_int16x8(vcvtmq_s16_f16(a.val));
}
inline v_int16x8 v_ceil(const v_float16x8 &a)
@@ -2271,9 +2269,13 @@ inline v_int32x4 v_round(const v_float32x4& a)
#endif
``` | Input is of type `v_float16x8`. I guess compile flag `+fp16` can only be used with >= `armv8.2a` right? In this case, no need to guard with `__ARM_ARCH > 7` then. |
You are an expert OpenCV code reviewer specializing in API design and compatibility. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/imgproc/src/warp_kernels.simd.hpp
**Change Type:** added
**Context:** PR #25984: imgproc: add optimized warpAffine kernels for 8U/16U/32F + C1/C3/C4 inputs
**Code Changes:**
```diff
@@ -0,0 +1,2137 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html.
+
+#include <numeric>
+#include "precomp.hpp"
+#include "warp_common.hpp"
+#include "opencv2/core/hal/intrin.hpp"
+
``` | `.simd.hpp` should not have `cv::Mat` or other C++ classes in their API. |
You are an expert OpenCV code reviewer specializing in header file design and interface. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/imgproc/src/warp_kernels.simd.hpp
**Change Type:** added
**Context:** PR #25984: imgproc: add optimized warpAffine kernels for 8U/16U/32F + C1/C3/C4 inputs
**Review Line:** 91
**Code Changes:**
```diff
+ if( p < 0 )
+ p = -p - 1 + delta;
+ else
+ p = len - 1 - (p - len) - delta;
+ }
+ while( (unsigned)p >= (unsigned)len );
+ }
+ else if( borderType == BORDER_WRAP )
+ {
+ if( p < 0 )
+ p -= ((p-len+1)/len)*len;
``` | How to guarantee avoidance of infinite loop? |
You are an expert OpenCV code reviewer specializing in header file design and interface. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/imgproc/src/warp_kernels.simd.hpp
**Change Type:** added
**Context:** PR #25984: imgproc: add optimized warpAffine kernels for 8U/16U/32F + C1/C3/C4 inputs
**Code Changes:**
```diff
@@ -0,0 +1,2137 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html.
+
+#include <numeric>
+#include "precomp.hpp"
+#include "warp_common.hpp"
+#include "opencv2/core/hal/intrin.hpp"
+
``` | There are many of those scattered in the code. One of them is: https://github.com/opencv/opencv/blob/babc669dba4c1f55a0acc904e47bf2186aa8f7d1/modules/imgproc/src/bilateral_filter.simd.hpp#L55-L60 |
You are an expert OpenCV code reviewer specializing in header file design and interface. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/imgproc/src/warp_kernels.simd.hpp
**Change Type:** added
**Context:** PR #25984: imgproc: add optimized warpAffine kernels for 8U/16U/32F + C1/C3/C4 inputs
**Review Line:** 91
**Code Changes:**
```diff
+ if( p < 0 )
+ p = -p - 1 + delta;
+ else
+ p = len - 1 - (p - len) - delta;
+ }
+ while( (unsigned)p >= (unsigned)len );
+ }
+ else if( borderType == BORDER_WRAP )
+ {
+ if( p < 0 )
+ p -= ((p-len+1)/len)*len;
``` | I don't know. Ask people who wrote that originally: https://github.com/opencv/opencv/blob/babc669dba4c1f55a0acc904e47bf2186aa8f7d1/modules/core/src/copy.cpp#L806-L817 |
You are an expert OpenCV code reviewer specializing in testing and validation. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/core/include/opencv2/core/hal/intrin_neon.hpp
**Change Type:** modified
**Context:** PR #25984: imgproc: add optimized warpAffine kernels for 8U/16U/32F + C1/C3/C4 inputs
**Code Changes:**
```diff
@@ -2228,9 +2228,7 @@ inline v_int16x8 v_round(const v_float16x8 &a)
inline v_int16x8 v_floor(const v_float16x8 &a)
{
- int16x8_t a1 = vcvtq_s16_f16(a.val);
- uint16x8_t mask = vcgtq_f16(vcvtq_f16_s16(a1), a.val);
- return v_int16x8(vaddq_s16(a1, vreinterpretq_s16_u16(mask)));
+ return v_int16x8(vcvtmq_s16_f16(a.val));
}
``` | Please use __ARM_ARCH > 7 check. I have armv7 board and test it regularly. |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/imgproc/perf/opencl/perf_imgwarp.cpp
**Change Type:** modified
**Context:** PR #25984: imgproc: add optimized warpAffine kernels for 8U/16U/32F + C1/C3/C4 inputs
**Review Line:** 78
**Code Changes:**
```diff
const int type = get<1>(params), interpolation = get<2>(params);
- const double eps = CV_MAT_DEPTH(type) <= CV_32S ? 1 : interpolation == INTER_CUBIC ? 2e-3 : 1e-4;
+
+ // BUG: OpenCL and CPU version diverges a bit
+ // Ticket: https://github.com/opencv/opencv/issues/26235
+ const double eps = CV_MAT_DEPTH(type) <= CV_32S ? 2 : interpolation == INTER_CUBIC ? 2e-3 : 3e-2;
checkDeviceMaxMemoryAllocSize(srcSize, type);
``` | Looks like the change does not make sense as soon as you introduced `AlgorithmHint`. I reverted the change and no not see regressions with Intel OpenCL (iGPU) and NVIDIA GF 1080. |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/imgproc/test/ocl/test_warp.cpp
**Change Type:** modified
**Context:** PR #25984: imgproc: add optimized warpAffine kernels for 8U/16U/32F + C1/C3/C4 inputs
**Review Line:** 175
**Code Changes:**
```diff
@@ -172,7 +172,7 @@ OCL_TEST_P(WarpAffine, Mat)
{
for (int j = 0; j < test_loop_times; j++)
{
- double eps = depth < CV_32F ? 0.04 : 0.06;
+ double eps = depth < CV_32F ? ( depth < CV_16U ? 0.09 : 0.04 ) : 0.06;
random_roi();
Mat M = getRotationMatrix2D(Point2f(src_roi.cols / 2.0f, src_roi.rows / 2.0f),
@@ -189,7 +189,7 @@ OCL_TEST_P(WarpAffine, inplace_25853) // when src and dst are the same variable,
{
``` | I propose to convert it to conditions with explicit types. We have fp16, int64, bool that comes after fp64. Also it's hard to understand the condition. |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/imgproc/test/ocl/test_warp.cpp
**Change Type:** modified
**Context:** PR #25984: imgproc: add optimized warpAffine kernels for 8U/16U/32F + C1/C3/C4 inputs
**Review Line:** 192
**Code Changes:**
```diff
@@ -189,7 +189,7 @@ OCL_TEST_P(WarpAffine, inplace_25853) // when src and dst are the same variable,
{
for (int j = 0; j < test_loop_times; j++)
{
- double eps = depth < CV_32F ? 0.04 : 0.06;
+ double eps = depth < CV_32F ? ( depth < CV_16U ? 0.09 : 0.04 ) : 0.06;
random_roi();
Mat M = getRotationMatrix2D(Point2f(src_roi.cols / 2.0f, src_roi.rows / 2.0f),
``` | The same proposal here. |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/imgproc/test/test_imgwarp_strict.cpp
**Change Type:** modified
**Context:** PR #25984: imgproc: add optimized warpAffine kernels for 8U/16U/32F + C1/C3/C4 inputs
**Code Changes:**
```diff
@@ -150,7 +150,7 @@ void CV_ImageWarpBaseTest::generate_test_data()
while (depth == CV_8S || depth == CV_32S)
depth = rng.uniform(0, CV_64F);
- int cn = rng.uniform(1, 4);
+ int cn = rng.uniform(1, 5);
src.create(ssize, CV_MAKE_TYPE(depth, cn));
@@ -1045,6 +1045,13 @@ class CV_WarpAffine_Test :
``` | The change is not relevant after AlgorithmHint introduction. It passes without the change on Intel at least. |
You are an expert OpenCV code reviewer specializing in testing and validation. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/imgproc/test/test_imgwarp_strict.cpp
**Change Type:** modified
**Context:** PR #25984: imgproc: add optimized warpAffine kernels for 8U/16U/32F + C1/C3/C4 inputs
**Review Line:** 153
**Code Changes:**
```diff
@@ -150,7 +150,7 @@ void CV_ImageWarpBaseTest::generate_test_data()
while (depth == CV_8S || depth == CV_32S)
depth = rng.uniform(0, CV_64F);
- int cn = rng.uniform(1, 4);
+ int cn = rng.uniform(1, 5);
src.create(ssize, CV_MAKE_TYPE(depth, cn));
@@ -1045,6 +1045,13 @@ class CV_WarpAffine_Test :
Mat M;
``` | The change triggers massve OpenCL code compilation errors for the new case. Some check should be added on OpenCL side. See attached log. [Uploading test.log…]() |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/imgproc/test/test_imgwarp_strict.cpp
**Change Type:** modified
**Context:** PR #25984: imgproc: add optimized warpAffine kernels for 8U/16U/32F + C1/C3/C4 inputs
**Review Line:** 153
**Code Changes:**
```diff
@@ -150,7 +150,7 @@ void CV_ImageWarpBaseTest::generate_test_data()
while (depth == CV_8S || depth == CV_32S)
depth = rng.uniform(0, CV_64F);
- int cn = rng.uniform(1, 4);
+ int cn = rng.uniform(1, 5);
src.create(ssize, CV_MAKE_TYPE(depth, cn));
@@ -1045,6 +1045,13 @@ class CV_WarpAffine_Test :
Mat M;
``` | I added check to OpenCL code. |
You are an expert OpenCV code reviewer specializing in testing and validation. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/imgproc/test/test_drawing.cpp
**Change Type:** modified
**Context:** PR #26187: Fix fillPoly drawing over boundaries
**Code Changes:**
```diff
@@ -680,6 +680,75 @@ TEST(Drawing, fillpoly_circle)
EXPECT_LT(diff_fp3, 1.);
}
+TEST(Drawing, fillpoly_contours)
+{
+ const int imgSize = 50;
+ const int type = CV_8UC1;
+ const int shift = 0;
+ const Scalar cl = Scalar::all(255);
``` | Why is this test disabled? |
You are an expert OpenCV code reviewer specializing in testing and validation. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/imgproc/test/test_drawing.cpp
**Change Type:** modified
**Context:** PR #26187: Fix fillPoly drawing over boundaries
**Code Changes:**
```diff
@@ -680,6 +680,75 @@ TEST(Drawing, fillpoly_circle)
EXPECT_LT(diff_fp3, 1.);
}
+TEST(Drawing, fillpoly_contours)
+{
+ const int imgSize = 50;
+ const int type = CV_8UC1;
+ const int shift = 0;
+ const Scalar cl = Scalar::all(255);
``` | It takes a lot of time compared to the other tests. The last time I added such a heavy test I was advised to not run it by default, see https://github.com/opencv/opencv/pull/23076#discussion_r1060193514 |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/imgproc/test/test_drawing.cpp
**Change Type:** modified
**Context:** PR #26187: Fix fillPoly drawing over boundaries
**Code Changes:**
```diff
@@ -680,6 +680,75 @@ TEST(Drawing, fillpoly_circle)
EXPECT_LT(diff_fp3, 1.);
}
+TEST(Drawing, fillpoly_contours)
+{
+ const int imgSize = 50;
+ const int type = CV_8UC1;
+ const int shift = 0;
+ const Scalar cl = Scalar::all(255);
``` | Instead of two comparison we can make one simpler check: ```.cpp im1 = 0; img2 = 0; cv::fillPoly(img1, ...); cv::polylines(img2, ...); // same color EXPECT_MAT_N_DIFF(img1, img2, 0); ``` |
You are an expert OpenCV code reviewer specializing in testing and validation. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/imgproc/test/test_drawing.cpp
**Change Type:** modified
**Context:** PR #26187: Fix fillPoly drawing over boundaries
**Code Changes:**
```diff
@@ -680,6 +680,75 @@ TEST(Drawing, fillpoly_circle)
EXPECT_LT(diff_fp3, 1.);
}
+TEST(Drawing, fillpoly_contours)
+{
+ const int imgSize = 50;
+ const int type = CV_8UC1;
+ const int shift = 0;
+ const Scalar cl = Scalar::all(255);
``` | I suggest reducing this test by: 1. use only corners and the middle as the first point: ```.cpp for (int x1 = 0; x1 < imgSize; x1 += imgSize / 2) // imgSize = 49 for (int y1 = 0; y1 < imgSize; y1 += imgSize / 2) ``` 2. Draw on two separate images and compare them afterwards (see my other comment) I've prepared an example: https://github.com/opencv/opencv/commit/1b1277b787438b3827208b7323652a892e486072 Does it cover all the required cases, what do you think? |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/imgproc/test/test_drawing.cpp
**Change Type:** modified
**Context:** PR #26187: Fix fillPoly drawing over boundaries
**Code Changes:**
```diff
@@ -680,6 +680,75 @@ TEST(Drawing, fillpoly_circle)
EXPECT_LT(diff_fp3, 1.);
}
+TEST(Drawing, fillpoly_contours)
+{
+ const int imgSize = 50;
+ const int type = CV_8UC1;
+ const int shift = 0;
+ const Scalar cl = Scalar::all(255);
``` | Make one `vector<vector<Point>>` with all required data and pass it directly to the function: ```.cpp std::vector<std::vector<cv::Point>> polygonPoints {{ {x1, y1}, {x2, y2} }}; ``` |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/imgproc/test/test_drawing.cpp
**Change Type:** modified
**Context:** PR #26187: Fix fillPoly drawing over boundaries
**Code Changes:**
```diff
@@ -680,6 +680,75 @@ TEST(Drawing, fillpoly_circle)
EXPECT_LT(diff_fp3, 1.);
}
+TEST(Drawing, fillpoly_contours)
+{
+ const int imgSize = 50;
+ const int type = CV_8UC1;
+ const int shift = 0;
+ const Scalar cl = Scalar::all(255);
``` | What about other line types? `LINE_AA`? Will it work the same as before? |
You are an expert OpenCV code reviewer specializing in testing and validation. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/imgproc/src/drawing.cpp
**Change Type:** modified
**Context:** PR #26187: Fix fillPoly drawing over boundaries
**Review Line:** 1302
**Code Changes:**
```diff
if (t0.y != t1.y)
{
pt0c.y = t0.y; pt1c.y = t1.y;
- pt0c.x = (int64)(t0.x) << XY_SHIFT;
- pt1c.x = (int64)(t1.x) << XY_SHIFT;
}
}
- else
- {
- pt0c.x += XY_ONE >> 1;
- pt1c.x += XY_ONE >> 1;
``` | Does any test check clipping scenario? Non-zero shift? |
You are an expert OpenCV code reviewer specializing in testing and validation. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/imgproc/src/drawing.cpp
**Change Type:** modified
**Context:** PR #26187: Fix fillPoly drawing over boundaries
**Review Line:** 1302
**Code Changes:**
```diff
if (t0.y != t1.y)
{
pt0c.y = t0.y; pt1c.y = t1.y;
- pt0c.x = (int64)(t0.x) << XY_SHIFT;
- pt1c.x = (int64)(t1.x) << XY_SHIFT;
}
}
- else
- {
- pt0c.x += XY_ONE >> 1;
- pt1c.x += XY_ONE >> 1;
``` | I did not add tests for all scenarios since `fillPoly` and `polylines` handle incoming points slightly different and also have differences in drawing the contours for certain parameters. To make the contours match in all scenarios probably both functions would need further adjustments. This PR should fix the matching contours for `line_type < LINE_AA` and zero shift since it used to match before the changes of #23076 |
You are an expert OpenCV code reviewer specializing in testing and validation. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/imgproc/test/test_drawing.cpp
**Change Type:** modified
**Context:** PR #26187: Fix fillPoly drawing over boundaries
**Code Changes:**
```diff
@@ -680,6 +680,75 @@ TEST(Drawing, fillpoly_circle)
EXPECT_LT(diff_fp3, 1.);
}
+TEST(Drawing, fillpoly_contours)
+{
+ const int imgSize = 50;
+ const int type = CV_8UC1;
+ const int shift = 0;
+ const Scalar cl = Scalar::all(255);
``` | `LINE_AA` is not affected by the changes of this PR so it works the same, but it does not pass the test due to the reasons mentioned in the other comment. `LINE_4` passes this test with any shift. `LINE_8` passes this test only with a zero shift. It fails for non-zero shifts, most likely because the methods to draw the contour in `fillPoly` and `polylines` differ for `LINE_8` with non-zero shifts. |
You are an expert OpenCV code reviewer specializing in performance optimization. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/core/include/opencv2/core/hal/intrin_math.hpp
**Change Type:** modified
**Context:** PR #25892: Add support for v_sin and v_cos (Sine and Cosine)
**Review Line:** 410
**Code Changes:**
```diff
}
//! @}
+//! @name Sine and Cosine
+//! @{
+template<typename _TpVec16F, typename _TpVec16S>
+inline void v_sincos_default_16f(const _TpVec16F &x, _TpVec16F &ysin, _TpVec16F &ycos) {
+ const _TpVec16F v_cephes_FOPI = v_setall_<_TpVec16F>(hfloat(1.27323954473516f)); // 4 / M_PI
+ const _TpVec16F v_minus_DP1 = v_setall_<_TpVec16F>(hfloat(-0.78515625f));
+ const _TpVec16F v_minus_DP2 = v_setall_<_TpVec16F>(hfloat(-2.4187564849853515625E-4f));
+ const _TpVec16F v_minus_DP3 = v_setall_<_TpVec16F>(hfloat(-3.77489497744594108E-8f));
``` | It'll be great to add reference to the algorithm source/description and m.b. how the coefficients are generated. |
You are an expert OpenCV code reviewer specializing in performance optimization. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/core/include/opencv2/core/hal/intrin_math.hpp
**Change Type:** modified
**Context:** PR #25892: Add support for v_sin and v_cos (Sine and Cosine)
**Review Line:** 410
**Code Changes:**
```diff
}
//! @}
+//! @name Sine and Cosine
+//! @{
+template<typename _TpVec16F, typename _TpVec16S>
+inline void v_sincos_default_16f(const _TpVec16F &x, _TpVec16F &ysin, _TpVec16F &ycos) {
+ const _TpVec16F v_cephes_FOPI = v_setall_<_TpVec16F>(hfloat(1.27323954473516f)); // 4 / M_PI
+ const _TpVec16F v_minus_DP1 = v_setall_<_TpVec16F>(hfloat(-0.78515625f));
+ const _TpVec16F v_minus_DP2 = v_setall_<_TpVec16F>(hfloat(-2.4187564849853515625E-4f));
+ const _TpVec16F v_minus_DP3 = v_setall_<_TpVec16F>(hfloat(-3.77489497744594108E-8f));
``` | I can't find the original algorithm, the approximate implementations are the same and they refer to (it's already existed in the `intrin_math.hpp` ``` /* Universal Intrinsics implementation of sin, cos, exp and log Inspired by Intel Approximate Math library, and based on the corresponding algorithms of the cephes math library */ /* Copyright (C) 2010,2011 RJVB - extensions */ /* Copyright (C) 2011 Julien Pommier ``` The explanation is my own interpretation. The basic idea involves leveraging periodicity and trigonometric identities to scale the input, followed by the use of a Taylor series for calculation. The coefficients are nearly identical to those in the Taylor series, with some adjustments. |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/core/test/ocl/test_arithm.cpp
**Change Type:** modified
**Context:** PR #26256: extended Norm tests to prove that cv::norm() already supports all the…
**Review Line:** 2041
**Code Changes:**
```diff
@@ -2038,7 +2038,7 @@ OCL_INSTANTIATE_TEST_CASE_P(Arithm, Magnitude, Combine(::testing::Values(CV_32F,
OCL_INSTANTIATE_TEST_CASE_P(Arithm, Flip, Combine(OCL_ALL_DEPTHS, OCL_ALL_CHANNELS, Bool()));
OCL_INSTANTIATE_TEST_CASE_P(Arithm, MinMaxIdx, Combine(OCL_ALL_DEPTHS, OCL_ALL_CHANNELS, Bool()));
OCL_INSTANTIATE_TEST_CASE_P(Arithm, MinMaxIdx_Mask, Combine(OCL_ALL_DEPTHS, ::testing::Values(Channels(1)), Bool()));
-OCL_INSTANTIATE_TEST_CASE_P(Arithm, Norm, Combine(OCL_ALL_DEPTHS_16F, OCL_ALL_CHANNELS, Bool()));
+OCL_INSTANTIATE_TEST_CASE_P(Arithm, Norm, Combine(OCL_ABSOLUTELY_ALL_DEPTHS, OCL_ALL_CHANNELS, Bool()));
OCL_INSTANTIATE_TEST_CASE_P(Arithm, Sqrt, Combine(::testing::Values(CV_32F, CV_64F), OCL_ALL_CHANNELS, Bool()));
OCL_INSTANTIATE_TEST_CASE_P(Arithm, Normalize, Combine(OCL_ALL_DEPTHS, Values(Channels(1)), Bool()));
OCL_INSTANTIATE_TEST_CASE_P(Arithm, InRange, Combine(OCL_ALL_DEPTHS, OCL_ALL_CHANNELS, Bool(), Bool()));
``` | `OCL_ABSOLUTELY_ALL_DEPTHS` => `OCL_ALL_NUMERICAL_DEPTHS`, because bool is not there. |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/core/test/ocl/test_arithm.cpp
**Change Type:** modified
**Context:** PR #26256: extended Norm tests to prove that cv::norm() already supports all the…
**Review Line:** 2041
**Code Changes:**
```diff
@@ -2038,7 +2038,7 @@ OCL_INSTANTIATE_TEST_CASE_P(Arithm, Magnitude, Combine(::testing::Values(CV_32F,
OCL_INSTANTIATE_TEST_CASE_P(Arithm, Flip, Combine(OCL_ALL_DEPTHS, OCL_ALL_CHANNELS, Bool()));
OCL_INSTANTIATE_TEST_CASE_P(Arithm, MinMaxIdx, Combine(OCL_ALL_DEPTHS, OCL_ALL_CHANNELS, Bool()));
OCL_INSTANTIATE_TEST_CASE_P(Arithm, MinMaxIdx_Mask, Combine(OCL_ALL_DEPTHS, ::testing::Values(Channels(1)), Bool()));
-OCL_INSTANTIATE_TEST_CASE_P(Arithm, Norm, Combine(OCL_ALL_DEPTHS_16F, OCL_ALL_CHANNELS, Bool()));
+OCL_INSTANTIATE_TEST_CASE_P(Arithm, Norm, Combine(OCL_ABSOLUTELY_ALL_DEPTHS, OCL_ALL_CHANNELS, Bool()));
OCL_INSTANTIATE_TEST_CASE_P(Arithm, Sqrt, Combine(::testing::Values(CV_32F, CV_64F), OCL_ALL_CHANNELS, Bool()));
OCL_INSTANTIATE_TEST_CASE_P(Arithm, Normalize, Combine(OCL_ALL_DEPTHS, Values(Channels(1)), Bool()));
OCL_INSTANTIATE_TEST_CASE_P(Arithm, InRange, Combine(OCL_ALL_DEPTHS, OCL_ALL_CHANNELS, Bool(), Bool()));
``` | added norm for Bool too |
You are an expert OpenCV code reviewer specializing in testing and validation. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/core/include/opencv2/core/hal/intrin_cpp.hpp
**Change Type:** modified
**Context:** PR #25891: Resolve Compilation Error for v_func Function in SIMD Emulator
**Code Changes:**
```diff
@@ -263,7 +263,7 @@ Most of these operations return only one value.
### Other math
-- Some frequent operations: @ref v_sqrt, @ref v_invsqrt, @ref v_magnitude, @ref v_sqr_magnitude, @ref v_exp,
+- Some frequent operations: @ref v_sqrt, @ref v_invsqrt, @ref v_magnitude, @ref v_sqr_magnitude, @ref v_exp, @ref v_log,
@ref v_erf
- Absolute values: @ref v_abs, @ref v_absdiff, @ref v_absdiffs
@@ -2801,7 +2801,8 @@ inline void v_transpose4x4( v_reg<_Tp, n>& a0, const v_reg<_Tp, n>& a1,
``` | It is expected that tests like `hal_intrin*CPP_EMULATOR` call the code from `intrin_cpp.hpp`. But they don't. To debug modify `intrin_cpp.hpp`: ```.diff #define OPENCV_HAL_IMPL_MATH_FUNC(func, cfunc, _Tp2) \ template<typename _Tp, int n> inline v_reg<_Tp2, n> func(const v_reg<_Tp, n>& a) \ { \ + printf(#func " is called\n"); \ v_reg<_Tp2, n> c; \ for( int i = 0; i < n; i++ ) \ c.s[i] = cfunc(a.s[i]); \ ``` Run tests: `./bin/opencv_test_core --gtest_filter=*intrin*EMULATOR*` ``` [ RUN ] hal_intrin128.float32x4_CPP_EMULATOR SIMD128: void opencv_test::hal::intrin128::opt_EMULATOR_CPP::test_hal_intrin_float32() v_abs is called v_sqrt is called v_abs is called <<<<<<< missing v_exp call through generic C++ exp() >>>>>>>>> v_abs is called v_abs is called v_abs is called ... ``` (both build configurations: with/without -DOPENCV_EXTRA_FLAGS="-DCV_FORCE_SIMD128_CPP=1") --- BTW, without this PR the correct version is called (in "default" build): ``` [ RUN ] hal_intrin128.float32x4_CPP_EMULATOR SIMD128: void opencv_test::hal::intrin128::opt_EMULATOR_CPP::test_hal_intrin_float32() v_abs is called v_sqrt is called v_abs is called v_exp is called v_exp is called v_exp is called v_exp is called v_exp is called ... v_log is called ... ``` |
You are an expert OpenCV code reviewer specializing in header file design and interface. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/core/include/opencv2/core/hal/intrin_math.hpp
**Change Type:** modified
**Context:** PR #25891: Resolve Compilation Error for v_func Function in SIMD Emulator
**Code Changes:**
```diff
@@ -2,10 +2,6 @@
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html
-// This header is not standalone. Don't include directly, use "intrin.hpp" instead.
-#ifdef OPENCV_HAL_INTRIN_HPP // defined in intrin.hpp
-
-namespace CV__SIMD_NAMESPACE {
/* Universal Intrinsics implementation of sin, cos, exp and log
``` | I propose to use templates here. v_int##TpSuffix and v_float##TpSuffix will be template arguments. |
You are an expert OpenCV code reviewer specializing in header file design and interface. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/core/include/opencv2/core/hal/intrin_math.hpp
**Change Type:** modified
**Context:** PR #25891: Resolve Compilation Error for v_func Function in SIMD Emulator
**Code Changes:**
```diff
@@ -2,10 +2,6 @@
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html
-// This header is not standalone. Don't include directly, use "intrin.hpp" instead.
-#ifdef OPENCV_HAL_INTRIN_HPP // defined in intrin.hpp
-
-namespace CV__SIMD_NAMESPACE {
/* Universal Intrinsics implementation of sin, cos, exp and log
``` | OK, but it will introduce many parameters and may use the macro to maintain the code. |
You are an expert OpenCV code reviewer specializing in header file design and interface. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/core/include/opencv2/core/hal/intrin_math.hpp
**Change Type:** modified
**Context:** PR #25891: Resolve Compilation Error for v_func Function in SIMD Emulator
**Code Changes:**
```diff
@@ -2,10 +2,6 @@
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html
-// This header is not standalone. Don't include directly, use "intrin.hpp" instead.
-#ifdef OPENCV_HAL_INTRIN_HPP // defined in intrin.hpp
-
-namespace CV__SIMD_NAMESPACE {
/* Universal Intrinsics implementation of sin, cos, exp and log
``` | Wouldn't wide intrinsics like `vx_setall_f32` work here? Or maybe we can introduce traits type (or extend existing ones) which would map `_setall_` to corresponding types. |
You are an expert OpenCV code reviewer specializing in header file design and interface. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/core/include/opencv2/core/hal/intrin_lasx.hpp
**Change Type:** modified
**Context:** PR #25891: Resolve Compilation Error for v_func Function in SIMD Emulator
**Review Line:** 563
**Code Changes:**
```diff
inline _Tpvec v256_setall_##suffix(_Tp v) \
{ return _Tpvec(__lasx_xvreplgr2vr_##ssuffix((ctype_s)v)); } \
+ template <> inline _Tpvec v_setzero_() \
+ { return v256_setzero_##suffix(); } \
+ template <> inline _Tpvec v_setall_(_Tp v) \
+ { return v256_setall_##suffix(v); } \
OPENCV_HAL_IMPL_LASX_CAST(_Tpvec, v_uint8x32, suffix, OPENCV_HAL_NOP) \
OPENCV_HAL_IMPL_LASX_CAST(_Tpvec, v_int8x32, suffix, OPENCV_HAL_NOP) \
OPENCV_HAL_IMPL_LASX_CAST(_Tpvec, v_uint16x16, suffix, OPENCV_HAL_NOP) \
@@ -588,7 +592,11 @@ inline __m256d _lasx_256_castsi256_pd(const __m256i &v)
inline _Tpvec v256_setzero_##suffix() \
``` | if you copy-paste code 3+ times, when we have anti-pattern and design should be changed. |
You are an expert OpenCV code reviewer specializing in header file design and interface. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/core/include/opencv2/core/hal/intrin_avx.hpp
**Change Type:** modified
**Context:** PR #25891: Resolve Compilation Error for v_func Function in SIMD Emulator
**Code Changes:**
```diff
@@ -447,6 +447,10 @@ OPENCV_HAL_IMPL_AVX_LOADSTORE_FLT(v_float64x4, double, pd, __m128d)
{ return _Tpvec(_mm256_setzero_si256()); } \
inline _Tpvec v256_setall_##suffix(_Tp v) \
{ return _Tpvec(_mm256_set1_##ssuffix((ctype_s)v)); } \
+ template <> inline _Tpvec v_setzero_() \
+ { return v256_setzero_##suffix(); } \
+ template <> inline _Tpvec v_setall_(_Tp v) \
+ { return v256_setall_##suffix(v); } \
OPENCV_HAL_IMPL_AVX_CAST(_Tpvec, v_uint8x32, suffix, OPENCV_HAL_NOP) \
OPENCV_HAL_IMPL_AVX_CAST(_Tpvec, v_int8x32, suffix, OPENCV_HAL_NOP) \
``` | > `_Tpvec /*unused*/` Template should be used instead. Static code analyzers dislike passing of uninitialized vars. |
You are an expert OpenCV code reviewer specializing in header file design and interface. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/core/include/opencv2/core/hal/intrin_avx.hpp
**Change Type:** modified
**Context:** PR #25891: Resolve Compilation Error for v_func Function in SIMD Emulator
**Review Line:** 451
**Code Changes:**
```diff
@@ -447,6 +447,10 @@ OPENCV_HAL_IMPL_AVX_LOADSTORE_FLT(v_float64x4, double, pd, __m128d)
{ return _Tpvec(_mm256_setzero_si256()); } \
inline _Tpvec v256_setall_##suffix(_Tp v) \
{ return _Tpvec(_mm256_set1_##ssuffix((ctype_s)v)); } \
+ template <> inline _Tpvec v_setzero_() \
+ { return v256_setzero_##suffix(); } \
+ template <> inline _Tpvec v_setall_(_Tp v) \
+ { return v256_setall_##suffix(v); } \
OPENCV_HAL_IMPL_AVX_CAST(_Tpvec, v_uint8x32, suffix, OPENCV_HAL_NOP) \
OPENCV_HAL_IMPL_AVX_CAST(_Tpvec, v_int8x32, suffix, OPENCV_HAL_NOP) \
OPENCV_HAL_IMPL_AVX_CAST(_Tpvec, v_uint16x16, suffix, OPENCV_HAL_NOP) \
``` | Mess of v256_ / v_ (which is used for 128-bit) |
You are an expert OpenCV code reviewer specializing in header file design and interface. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/calib/include/opencv2/calib.hpp
**Change Type:** modified
**Context:** PR #26221: Reworked multiview calibration interface
**Code Changes:**
```diff
@@ -449,7 +449,7 @@ enum { CALIB_USE_INTRINSIC_GUESS = 0x00001, //!< Use user provided intrinsics as
// for stereo rectification
CALIB_ZERO_DISPARITY = 0x00400, //!< Deprecated synonim of @ref STEREO_ZERO_DISPARITY. See @ref stereoRectify.
CALIB_USE_LU = (1 << 17), //!< use LU instead of SVD decomposition for solving. much faster but potentially less precise
- CALIB_USE_EXTRINSIC_GUESS = (1 << 22), //!< For stereo calibration only. Use user provided extrinsics (R, T) as initial point for optimization
+ CALIB_USE_EXTRINSIC_GUESS = (1 << 22), //!< For stereo and multi-view calibration. Use user provided extrinsics (R, T) as initial point for optimization
// fisheye only flags
CALIB_RECOMPUTE_EXTRINSIC = (1 << 23), //!< For fisheye model only. Recompute board position on each calibration iteration
CALIB_CHECK_COND = (1 << 24), //!< For fisheye model only. Check SVD decomposition quality for each frame during extrinsics estimation
@@ -1236,16 +1236,14 @@ CV_EXPORTS_W double registerCameras( InputArrayOfArrays objectPoints1,
``` | `std::vector<Size>` => `const std::vector<Size>&`? Also, shall I specify size for each single image even if they are the same? Can I just pass a vector of a single Size? |
You are an expert OpenCV code reviewer specializing in performance optimization. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/calib/src/multiview_calibration.cpp
**Change Type:** modified
**Context:** PR #26221: Reworked multiview calibration interface
**Review Line:** 510
**Code Changes:**
```diff
- const std::vector<Size> &imageSize, InputArray detectionMask,
- OutputArrayOfArrays Rs, OutputArrayOfArrays Ts, std::vector<Mat> &Ks, std::vector<Mat> &distortions,
- OutputArrayOfArrays rvecs0, OutputArrayOfArrays tvecs0, InputArray isFisheye,
- OutputArray perFrameErrors, OutputArray initializationPairs, bool useIntrinsicsGuess, InputArray flagsForIntrinsics) {
+//TODO: use Input/OutputArrays for imagePoints(?)
+double calibrateMultiview(
+ InputArrayOfArrays objPoints, const std::vector<std::vector<Mat>> &imagePoints,
+ const std::vector<cv::Size>& imageSize, InputArray detectionMask, InputArray models,
+ InputOutputArrayOfArrays Rs, InputOutputArrayOfArrays Ts,
+ InputOutputArrayOfArrays Ks, InputOutputArrayOfArrays distortions,
+ int flags, InputArray flagsForIntrinsics,
``` | Does this algorithm requires all images at once? If not, it would be more convenient (and efficient) to make iterative interface, e.g.: ```.cpp MultiviewCalib calib(...); for(...) { calib.addFrame(...); } SomeResult res = calib.getResults(); ``` |
You are an expert OpenCV code reviewer specializing in API design and compatibility. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/calib/src/multiview_calibration.cpp
**Change Type:** modified
**Context:** PR #26221: Reworked multiview calibration interface
**Review Line:** 510
**Code Changes:**
```diff
- const std::vector<Size> &imageSize, InputArray detectionMask,
- OutputArrayOfArrays Rs, OutputArrayOfArrays Ts, std::vector<Mat> &Ks, std::vector<Mat> &distortions,
- OutputArrayOfArrays rvecs0, OutputArrayOfArrays tvecs0, InputArray isFisheye,
- OutputArray perFrameErrors, OutputArray initializationPairs, bool useIntrinsicsGuess, InputArray flagsForIntrinsics) {
+//TODO: use Input/OutputArrays for imagePoints(?)
+double calibrateMultiview(
+ InputArrayOfArrays objPoints, const std::vector<std::vector<Mat>> &imagePoints,
+ const std::vector<cv::Size>& imageSize, InputArray detectionMask, InputArray models,
+ InputOutputArrayOfArrays Rs, InputOutputArrayOfArrays Ts,
+ InputOutputArrayOfArrays Ks, InputOutputArrayOfArrays distortions,
+ int flags, InputArray flagsForIntrinsics,
``` | The algorithm does not use frames, but point coordinates only. The first step calibrates intrinsics and build spanning tree. The second step makes global optimization for all frames. So iterative API is not possible here. |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **File:** samples/cpp/multiview_calibration_sample.cpp
**Change Type:** modified
**Context:** PR #25022: Add Charuco board support to multiview calibration sample (C++)
**Code Changes:**
```diff
@@ -7,12 +7,14 @@
#include <opencv2/calib3d.hpp>
#include <opencv2/imgcodecs.hpp>
#include <opencv2/imgproc.hpp>
+#include <opencv2/objdetect.hpp>
#include <iostream>
#include <fstream>
// ! [detectPointsAndCalibrate_signature]
-static void detectPointsAndCalibrate (cv::Size pattern_size, float pattern_scale, const std::string &pattern_type,
``` | It does not work, if not all Charuco corners are detected/labeled correctly. corners array will contain (-1,-1) and it'll be used in calibration pipeline. |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **File:** samples/cpp/multiview_calibration_sample.cpp
**Change Type:** modified
**Context:** PR #25022: Add Charuco board support to multiview calibration sample (C++)
**Code Changes:**
```diff
@@ -7,12 +7,14 @@
#include <opencv2/calib3d.hpp>
#include <opencv2/imgcodecs.hpp>
#include <opencv2/imgproc.hpp>
+#include <opencv2/objdetect.hpp>
#include <iostream>
#include <fstream>
// ! [detectPointsAndCalibrate_signature]
-static void detectPointsAndCalibrate (cv::Size pattern_size, float pattern_scale, const std::string &pattern_type,
``` | I put it to be (-1, -1) on purpose, as internally, I would check whether the point is inside the image frame x in (0, width-1), y in (0, height-1). If not, this point will be discarded. I design the input of the method to be like this so that I only need to feed in a single copy of the objective points. Otherwise, I would need to have a copy of the objective function for every frame and for every camera |
You are an expert OpenCV code reviewer specializing in code quality and best practices. Review the provided code changes and provide specific, actionable feedback. | **File:** doc/tutorials/dnn/dnn_yolo/dnn_yolo.markdown
**Change Type:** modified
**Context:** PR #25710: Merged yolo_detector and object detection sample
**Code Changes:**
```diff
@@ -150,13 +150,12 @@ Once we have our ONNX graph of the model, we just simply can run with OpenCV's s
3. Run the following command:
@code{.cpp}
-./bin/example_dnn_yolo_detector --input=<path_to_your_input_file> \
- --classes=<path_to_class_names_file> \
+./bin/example_dnn_object_detection <model_name> --input=<path_to_your_input_file> \
+ --labels=<path_to_class_names_file> \
--thr=<confidence_threshold> \
--nms=<non_maximum_suppression_threshold> \
``` | Yolo detector sample was removed in the PR. |
You are an expert OpenCV code reviewer specializing in testing and validation. Review the provided code changes and provide specific, actionable feedback. | **File:** samples/dnn/object_detection.cpp
**Change Type:** modified
**Context:** PR #25710: Merged yolo_detector and object detection sample
**Code Changes:**
```diff
@@ -1,68 +1,114 @@
+//![includes]
#include <fstream>
#include <sstream>
#include <opencv2/dnn.hpp>
#include <opencv2/imgproc.hpp>
+#include <opencv2/imgcodecs.hpp>
#include <opencv2/highgui.hpp>
``` | `test_name` -> `yolo_name` or something similar. |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **File:** samples/dnn/object_detection.cpp
**Change Type:** modified
**Context:** PR #25710: Merged yolo_detector and object detection sample
**Code Changes:**
```diff
@@ -1,68 +1,114 @@
+//![includes]
#include <fstream>
#include <sstream>
#include <opencv2/dnn.hpp>
#include <opencv2/imgproc.hpp>
+#include <opencv2/imgcodecs.hpp>
#include <opencv2/highgui.hpp>
``` | postrpocessing type from yaml file should be used here to support yolonas like models. |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **File:** samples/dnn/object_detection.cpp
**Change Type:** modified
**Context:** PR #25710: Merged yolo_detector and object detection sample
**Code Changes:**
```diff
@@ -1,68 +1,114 @@
+//![includes]
#include <fstream>
#include <sstream>
#include <opencv2/dnn.hpp>
#include <opencv2/imgproc.hpp>
+#include <opencv2/imgcodecs.hpp>
#include <opencv2/highgui.hpp>
``` | The same relevant for python code. Also there conditions are different. |
You are an expert OpenCV code reviewer specializing in header file design and interface. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/imgcodecs/include/opencv2/imgcodecs.hpp
**Change Type:** modified
**Context:** PR #26152: Documentation update for imagecodecs
**Code Changes:**
```diff
@@ -222,9 +222,9 @@ enum ImwriteHDRCompressionFlags {
@anchor imread
-The function imread loads an image from the specified file and returns it. If the image cannot be
-read (because of missing file, improper permissions, unsupported or invalid format), the function
-returns an empty matrix ( Mat::data==NULL ).
+The `imread` function loads an image from the specified file and returns OpenCV matrix. If the image cannot be
+read (because of a missing file, improper permissions, or unsupported/invalid format), the function
+returns an empty matrix.
``` | `Mat::data = NULL` is bad check. `Mat::empty()` should be used instead. |
You are an expert OpenCV code reviewer specializing in testing and validation. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/imgcodecs/src/grfmt_sunras.cpp
**Change Type:** modified
**Context:** PR #26152: Documentation update for imagecodecs
**Review Line:** 25
**Code Changes:**
```diff
#include "grfmt_sunras.hpp"
@@ -60,6 +22,7 @@ SunRasterDecoder::SunRasterDecoder()
m_encoding = RAS_STANDARD;
m_maptype = RMT_NONE;
m_maplength = 0;
+ m_buf_supported = true;
}
@@ -82,7 +45,12 @@ bool SunRasterDecoder::readHeader()
{
``` | Please extend existing test to cover the new feature. |
You are an expert OpenCV code reviewer specializing in testing and validation. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/imgcodecs/src/grfmt_sunras.cpp
**Change Type:** modified
**Context:** PR #26152: Documentation update for imagecodecs
**Review Line:** 25
**Code Changes:**
```diff
#include "grfmt_sunras.hpp"
@@ -60,6 +22,7 @@ SunRasterDecoder::SunRasterDecoder()
m_encoding = RAS_STANDARD;
m_maptype = RMT_NONE;
m_maplength = 0;
+ m_buf_supported = true;
}
@@ -82,7 +45,12 @@ bool SunRasterDecoder::readHeader()
{
``` | when `m_buf_supported = false;` imencode function writes the data into a temporary file. so tests already cover the functionality of `m_buf_supported = true;` |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.