nareshmlx/opencv-pr huggingface dataset:
**File:** modules/imgproc/src/median_blur.simd.hpp
**Change Type:** modified
**Context:** PR #27299: imgproc: medianblur: Performance improvement

**Code Changes:**
```diff
@@ -13,6 +13,7 @@
 // Copyright (C) 2000-2008, 2018, Intel Corporation, all rights reserved.
 // Copyright (C) 2009, Willow Garage Inc., all rights reserved.
 // Copyright (C) 2014-2015, Itseez Inc., all rights reserved.
+// Copyright (C) 2025, Advanced Micro Devices, all rights reserved.
 // Third party copyrights are property of their respective owners.
 //
 // Redistribution and use in source and binary forms, with or without modification,
@@ -693,8 +694,16 @@ medianBlur_SortNet( const Mat& _src, Mat& _dst, int m )
 #else
```

Review comment:
If you meant to take care of the tail with vectorization, you should take a look at this trick (line 161 to 166): https://github.com/opencv/opencv/blob/cb87f05e4bbae077e266d15b571ed8b23598d265/modules/core/src/convert.simd.hpp#L157-L171
**File:** modules/imgproc/src/median_blur.simd.hpp
**Change Type:** modified
**Context:** PR #27299: imgproc: medianblur: Performance improvement

**Code Changes:**
```diff
@@ -13,6 +13,7 @@
 // Copyright (C) 2000-2008, 2018, Intel Corporation, all rights reserved.
 // Copyright (C) 2009, Willow Garage Inc., all rights reserved.
 // Copyright (C) 2014-2015, Itseez Inc., all rights reserved.
+// Copyright (C) 2025, Advanced Micro Devices, all rights reserved.
 // Third party copyrights are property of their respective owners.
 //
 // Redistribution and use in source and binary forms, with or without modification,
@@ -693,8 +694,16 @@ medianBlur_SortNet( const Mat& _src, Mat& _dst, int m )
 #else
```

Review comment:
this will not be skipped. when cols <= 2* lanes, - limit gets increased after this loop. "limit = size.width" - then it gets done in "for( ; j < limit; j++ )" loop above.
**File:** modules/imgproc/src/median_blur.simd.hpp
**Change Type:** modified
**Context:** PR #27299: imgproc: medianblur: Performance improvement

**Code Changes:**
```diff
@@ -13,6 +13,7 @@
 // Copyright (C) 2000-2008, 2018, Intel Corporation, all rights reserved.
 // Copyright (C) 2009, Willow Garage Inc., all rights reserved.
 // Copyright (C) 2014-2015, Itseez Inc., all rights reserved.
+// Copyright (C) 2025, Advanced Micro Devices, all rights reserved.
 // Third party copyrights are property of their respective owners.
 //
 // Redistribution and use in source and binary forms, with or without modification,
@@ -693,8 +694,16 @@ medianBlur_SortNet( const Mat& _src, Mat& _dst, int m )
 #else
```

Review comment:
I meant to handle the tail with the same main vector path by allowing overwriting in the next row.
**File:** modules/imgproc/src/median_blur.simd.hpp
**Change Type:** modified
**Context:** PR #27299: imgproc: medianblur: Performance improvement

**Code Changes:**
```diff
@@ -13,6 +13,7 @@
 // Copyright (C) 2000-2008, 2018, Intel Corporation, all rights reserved.
 // Copyright (C) 2009, Willow Garage Inc., all rights reserved.
 // Copyright (C) 2014-2015, Itseez Inc., all rights reserved.
+// Copyright (C) 2025, Advanced Micro Devices, all rights reserved.
 // Third party copyrights are property of their respective owners.
 //
 // Redistribution and use in source and binary forms, with or without modification,
@@ -693,8 +694,16 @@ medianBlur_SortNet( const Mat& _src, Mat& _dst, int m )
 #else
```

Review comment:
Well, the starting index for j entering this loop should be cn (m=3) or cn*2 (m=5). So, the corrected version is as below. ```.diff diff --git a/modules/imgproc/src/median_blur.simd.hpp b/modules/imgproc/src/median_blur.simd.hpp index 7cc0aa693c..6185f5f9fd 100644 --- a/modules/imgproc/src/median_blur.simd.hpp +++ b/modules/imgproc/src/median_blur.simd.hpp @@ -693,8 +693,15 @@ medianBlur_SortNet( const Mat& _src, Mat& _dst, int m ) #else int nlanes = 1; #endif - for( ; j <= size.width - nlanes - cn; j += nlanes ) + for (; j < size.width - cn; j += nlanes) { + if ( j > size.width - cn - nlanes ) { + if (j == cn || src == dst) { + break; + } + j = size.width - cn - nlanes; + } + VT p0 = vop.load(row0+j-cn), p1 = vop.load(row0+j), p2 = vop.load(row0+j+cn); VT p3 = vop.load(row1+j-cn), p4 = vop.load(row1+j), p5 = vop.load(row1+j+cn); VT p6 = vop.load(row2+j-cn), p7 = vop.load(row2+j), p8 = vop.load(row2+j+cn); @@ -798,8 +805,17 @@ medianBlur_SortNet( const Mat& _src, Mat& _dst, int m ) #else int nlanes = 1; #endif - for( ; j <= size.width - nlanes - cn*2; j += nlanes ) + // for( ; j <= size.width - nlanes - cn*2; j += nlanes ) + // { + for (; j < size.width - cn*2; j += nlanes) { + if ( j > size.width - cn*2 - nlanes ) { + if (j == cn*2 || src == dst) { + break; + } + j = size.width - cn*2 - nlanes; + } + VT p0 = vop.load(row[0]+j-cn*2), p5 = vop.load(row[1]+j-cn*2), p10 = vop.load(row[2]+j-cn*2), p15 = vop.load(row[3]+j-cn*2), p20 = vop.load(row[4]+j-cn*2); VT p1 = vop.load(row[0]+j-cn*1), p6 = vop.load(row[1]+j-cn*1), p11 = vop.load(row[2]+j-cn*1), p16 = vop.load(row[3]+j-cn*1), p21 = vop.load(row[4]+j-cn*1); VT p2 = vop.load(row[0]+j-cn*0), p7 = vop.load(row[1]+j-cn*0), p12 = vop.load(row[2]+j-cn*0), p17 = vop.load(row[3]+j-cn*0), p22 = vop.load(row[4]+j-cn*0); ``` Performance is the same.
**File:** modules/imgproc/src/median_blur.simd.hpp
**Change Type:** modified
**Context:** PR #27299: imgproc: medianblur: Performance improvement

**Code Changes:**
```diff
@@ -13,6 +13,7 @@
 // Copyright (C) 2000-2008, 2018, Intel Corporation, all rights reserved.
 // Copyright (C) 2009, Willow Garage Inc., all rights reserved.
 // Copyright (C) 2014-2015, Itseez Inc., all rights reserved.
+// Copyright (C) 2025, Advanced Micro Devices, all rights reserved.
 // Third party copyrights are property of their respective owners.
 //
 // Redistribution and use in source and binary forms, with or without modification,
@@ -693,8 +694,16 @@ medianBlur_SortNet( const Mat& _src, Mat& _dst, int m )
 #else
```

Review comment:
Adjusting the start index fixes the issue. Yes, performance is the same as before. Do you wish to commit/author this? This tail handling method is better.
**File:** modules/imgproc/src/median_blur.simd.hpp
**Change Type:** modified
**Context:** PR #27299: imgproc: medianblur: Performance improvement

**Code Changes:**
```diff
@@ -13,6 +13,7 @@
 // Copyright (C) 2000-2008, 2018, Intel Corporation, all rights reserved.
 // Copyright (C) 2009, Willow Garage Inc., all rights reserved.
 // Copyright (C) 2014-2015, Itseez Inc., all rights reserved.
+// Copyright (C) 2025, Advanced Micro Devices, all rights reserved.
 // Third party copyrights are property of their respective owners.
 //
 // Redistribution and use in source and binary forms, with or without modification,
@@ -693,8 +694,16 @@ medianBlur_SortNet( const Mat& _src, Mat& _dst, int m )
 #else
```

Review comment:
This trick is originally from Halide, IIRC. It is widely used in the codebase. I suggest to use the same to keep consistency and readability. You are welcome to do the change.
**File:** modules/videoio/include/opencv2/videoio.hpp
**Change Type:** modified
**Context:** PR #27284: Java VideoCapture buffered stream constructor

**Code Changes:**
```diff
@@ -726,8 +726,14 @@ class CV_EXPORTS_W IStreamReader
 public:
     virtual ~IStreamReader();
 
-    /** @brief Read bytes from stream */
-    virtual long long read(char* buffer, long long size) = 0;
+    /** @brief Read bytes from stream
+     *
+     * @param buffer already allocated buffer of at least @p size bytes
+     * @param size maximum number of bytes to read
```

Review comment:
I don't know if it may break ObjC bindings introduced in https://github.com/opencv/opencv/pull/25584
**File:** modules/videoio/include/opencv2/videoio.hpp
**Change Type:** modified
**Context:** PR #27284: Java VideoCapture buffered stream constructor

**Code Changes:**
```diff
@@ -726,8 +726,14 @@ class CV_EXPORTS_W IStreamReader
 public:
     virtual ~IStreamReader();
 
-    /** @brief Read bytes from stream */
-    virtual long long read(char* buffer, long long size) = 0;
+    /** @brief Read bytes from stream
+     *
+     * @param buffer already allocated buffer of at least @p size bytes
+     * @param size maximum number of bytes to read
```

Review comment:
IMHO, It should be kept wrapped as arguments of binding functions rely on this type. What is the error? Can we override behavior in java/gen_dict.json?
**File:** modules/videoio/include/opencv2/videoio.hpp
**Change Type:** modified
**Context:** PR #27284: Java VideoCapture buffered stream constructor

**Code Changes:**
```diff
@@ -726,8 +726,14 @@ class CV_EXPORTS_W IStreamReader
 public:
     virtual ~IStreamReader();
 
-    /** @brief Read bytes from stream */
-    virtual long long read(char* buffer, long long size) = 0;
+    /** @brief Read bytes from stream
+     *
+     * @param buffer already allocated buffer of at least @p size bytes
+     * @param size maximum number of bytes to read
```

Review comment:
Without `CV_EXPORTS_W` we also loose Python type hints.
**File:** modules/videoio/include/opencv2/videoio.hpp
**Change Type:** modified
**Context:** PR #27284: Java VideoCapture buffered stream constructor

**Code Changes:**
```diff
@@ -726,8 +726,14 @@ class CV_EXPORTS_W IStreamReader
 public:
     virtual ~IStreamReader();
 
-    /** @brief Read bytes from stream */
-    virtual long long read(char* buffer, long long size) = 0;
+    /** @brief Read bytes from stream
+     *
+     * @param buffer already allocated buffer of at least @p size bytes
+     * @param size maximum number of bytes to read
```

Review comment:
There is a minor error in gen_java but I were able to fix it. Let me try use a generated bindings again.
**File:** modules/videoio/misc/java/test/VideoCaptureTest.java
**Change Type:** modified
**Context:** PR #27284: Java VideoCapture buffered stream constructor

**Code Changes:**
```diff
@@ -1,27 +1,41 @@
 package org.opencv.test.videoio;
 
 import java.util.List;
+import java.io.File;
+import java.io.RandomAccessFile;
+import java.io.IOException;
+import java.io.FileNotFoundException;
 
+import org.opencv.core.Mat;
```

Review comment:
What is `0` used for?
**File:** modules/videoio/misc/java/test/VideoCaptureTest.java
**Change Type:** modified
**Context:** PR #27284: Java VideoCapture buffered stream constructor

**Code Changes:**
```diff
@@ -1,27 +1,41 @@
 package org.opencv.test.videoio;
 
 import java.util.List;
+import java.io.File;
+import java.io.RandomAccessFile;
+import java.io.IOException;
+import java.io.FileNotFoundException;
 
+import org.opencv.core.Mat;
```

Review comment:
Native object address, not used actually. Shall we hide it?
**File:** modules/videoio/misc/java/test/VideoCaptureTest.java
**Change Type:** modified
**Context:** PR #27284: Java VideoCapture buffered stream constructor
**Review Line:** 106

**Code Changes:**
```diff
+
+        IStreamReader stream = new IStreamReader()
+        {
+            @Override
+            public long read(byte[] buffer, long size)
+            {
+                assertEquals(buffer.length, size);
+                try
+                {
+                    return Math.max(f.read(buffer), 0);
+                }
```

Review comment:
I propose to add check if buffer length equal to size. Just to highlight bugs.
**File:** modules/videoio/misc/java/src/cpp/videoio_converters.hpp
**Change Type:** added
**Context:** PR #27284: Java VideoCapture buffered stream constructor
**Review Line:** 12

**Code Changes:**
```diff
+#include "opencv2/videoio/videoio.hpp"
+
+class JavaStreamReader : public cv::IStreamReader
+{
+public:
+    JavaStreamReader(JNIEnv* env, jobject obj);
+    ~JavaStreamReader();
+    long long read(char* buffer, long long size) CV_OVERRIDE;
+    long long seek(long long offset, int way) CV_OVERRIDE;
+
+private:
```

Review comment:
> The JNIEnv is used for thread-local storage. For this reason, you cannot share a JNIEnv between threads. If a piece of code has no other way to get its JNIEnv, you should share the JavaVM, and use GetEnv to discover the thread's JNIEnv. (Assuming it has one; see AttachCurrentThread below.) Source: https://developer.android.com/training/articles/perf-jni?hl=en Looks like the adapter should handle the threading model in smarter way.
**File:** modules/videoio/misc/java/test/VideoCaptureTest.java
**Change Type:** modified
**Context:** PR #27284: Java VideoCapture buffered stream constructor

**Code Changes:**
```diff
@@ -1,27 +1,41 @@
 package org.opencv.test.videoio;
 
 import java.util.List;
+import java.io.File;
+import java.io.RandomAccessFile;
+import java.io.IOException;
+import java.io.FileNotFoundException;
 
+import org.opencv.core.Mat;
```

Review comment:
Fixed by `ManualFuncs`
**File:** modules/videoio/misc/java/test/VideoCaptureTest.java
**Change Type:** modified
**Context:** PR #27284: Java VideoCapture buffered stream constructor
**Review Line:** 106

**Code Changes:**
```diff
+
+        IStreamReader stream = new IStreamReader()
+        {
+            @Override
+            public long read(byte[] buffer, long size)
+            {
+                assertEquals(buffer.length, size);
+                try
+                {
+                    return Math.max(f.read(buffer), 0);
+                }
```

Review comment:
Sure. Also make sense to highlight in docstring that it's pre-allocated
**File:** modules/videoio/misc/java/src/cpp/videoio_converters.cpp
**Change Type:** added
**Context:** PR #27284: Java VideoCapture buffered stream constructor
**Review Line:** 58

**Code Changes:**
```diff
+    if (!m_read)
+        return 0;
+    JNIEnvHandler handler(vm);
+    JNIEnv* env = handler.env;
+    if (!env)
+        return 0;
+    jbyteArray jBuffer = env->NewByteArray(static_cast<jsize>(size));
+    if (!jBuffer)
+        return 0;
+    jlong res = env->CallLongMethod(obj, m_read, jBuffer, size);
+    env->GetByteArrayRegion(jBuffer, 0, static_cast<jsize>(size), reinterpret_cast<jbyte*>(buffer));
```

Review comment:
In general these callbacks are called from FFmpeg non-Java threads. `JNIEnv` may be not available for native threads. Should we use `AttachCurrentThread` in that case instead of `return 0` ? Docs: > For example, a thread started with pthread_create() or std::thread can be attached using the AttachCurrentThread() or AttachCurrentThreadAsDaemon() functions. Until a thread is attached, it has no JNIEnv, and cannot make JNI calls. But there is dedicated issue with detaching of such threads.
**File:** modules/videoio/misc/java/src/cpp/videoio_converters.cpp
**Change Type:** added
**Context:** PR #27284: Java VideoCapture buffered stream constructor
**Review Line:** 58

**Code Changes:**
```diff
+    if (!m_read)
+        return 0;
+    JNIEnvHandler handler(vm);
+    JNIEnv* env = handler.env;
+    if (!env)
+        return 0;
+    jbyteArray jBuffer = env->NewByteArray(static_cast<jsize>(size));
+    if (!jBuffer)
+        return 0;
+    jlong res = env->CallLongMethod(obj, m_read, jBuffer, size);
+    env->GetByteArrayRegion(jBuffer, 0, static_cast<jsize>(size), reinterpret_cast<jbyte*>(buffer));
```

Review comment:
Added `AttachCurrentThread` if `GetEnv` returns specific `JNI_EDETACHED` error.
**File:** modules/videoio/misc/java/src/cpp/videoio_converters.cpp
**Change Type:** added
**Context:** PR #27284: Java VideoCapture buffered stream constructor
**Review Line:** 58

**Code Changes:**
```diff
+    if (!m_read)
+        return 0;
+    JNIEnvHandler handler(vm);
+    JNIEnv* env = handler.env;
+    if (!env)
+        return 0;
+    jbyteArray jBuffer = env->NewByteArray(static_cast<jsize>(size));
+    if (!jBuffer)
+        return 0;
+    jlong res = env->CallLongMethod(obj, m_read, jBuffer, size);
+    env->GetByteArrayRegion(jBuffer, 0, static_cast<jsize>(size), reinterpret_cast<jbyte*>(buffer));
```

Review comment:
> But there is dedicated issue with detaching of such threads. Do you mean there is some bug in JNI or we also responsible for `DetachCurrentThread` call?
**File:** modules/videoio/misc/java/src/cpp/videoio_converters.cpp
**Change Type:** added
**Context:** PR #27284: Java VideoCapture buffered stream constructor
**Review Line:** 58

**Code Changes:**
```diff
+    if (!m_read)
+        return 0;
+    JNIEnvHandler handler(vm);
+    JNIEnv* env = handler.env;
+    if (!env)
+        return 0;
+    jbyteArray jBuffer = env->NewByteArray(static_cast<jsize>(size));
+    if (!jBuffer)
+        return 0;
+    jlong res = env->CallLongMethod(obj, m_read, jBuffer, size);
+    env->GetByteArrayRegion(jBuffer, 0, static_cast<jsize>(size), reinterpret_cast<jbyte*>(buffer));
```

Review comment:
> we also responsible this.
**File:** modules/videoio/misc/java/src/cpp/videoio_converters.cpp
**Change Type:** added
**Context:** PR #27284: Java VideoCapture buffered stream constructor
**Review Line:** 24

**Code Changes:**
```diff
+
+    ~JNIEnvHandler()
+    {
+        if (env && detach)
+        {
+            vm->DetachCurrentThread();
+        }
+    }
+
+    JavaVM* vm;
+    JNIEnv* env = nullptr;
```

Review comment:
BTW, this could significantly slowdown execution through attach-detach on each callback call.
**File:** modules/videoio/misc/java/src/cpp/videoio_converters.cpp
**Change Type:** added
**Context:** PR #27284: Java VideoCapture buffered stream constructor
**Review Line:** 58

**Code Changes:**
```diff
+    if (!m_read)
+        return 0;
+    JNIEnvHandler handler(vm);
+    JNIEnv* env = handler.env;
+    if (!env)
+        return 0;
+    jbyteArray jBuffer = env->NewByteArray(static_cast<jsize>(size));
+    if (!jBuffer)
+        return 0;
+    jlong res = env->CallLongMethod(obj, m_read, jBuffer, size);
+    env->GetByteArrayRegion(jBuffer, 0, static_cast<jsize>(size), reinterpret_cast<jbyte*>(buffer));
```

Review comment:
Added in the latest commit for every read/seek call
**File:** modules/videoio/misc/java/src/cpp/videoio_converters.cpp
**Change Type:** added
**Context:** PR #27284: Java VideoCapture buffered stream constructor
**Review Line:** 24

**Code Changes:**
```diff
+
+    ~JNIEnvHandler()
+    {
+        if (env && detach)
+        {
+            vm->DetachCurrentThread();
+        }
+    }
+
+    JavaVM* vm;
+    JNIEnv* env = nullptr;
```

Review comment:
I can move it to the wrapper class, just few minutes
**File:** modules/videoio/misc/java/src/cpp/videoio_converters.cpp
**Change Type:** added
**Context:** PR #27284: Java VideoCapture buffered stream constructor
**Review Line:** 24

**Code Changes:**
```diff
+
+    ~JNIEnvHandler()
+    {
+        if (env && detach)
+        {
+            vm->DetachCurrentThread();
+        }
+    }
+
+    JavaVM* vm;
+    JNIEnv* env = nullptr;
```

Review comment:
There is no guarantee that wrapper class uses the same thread,
**File:** modules/videoio/misc/java/src/cpp/videoio_converters.cpp
**Change Type:** added
**Context:** PR #27284: Java VideoCapture buffered stream constructor
**Review Line:** 24

**Code Changes:**
```diff
+
+    ~JNIEnvHandler()
+    {
+        if (env && detach)
+        {
+            vm->DetachCurrentThread();
+        }
+    }
+
+    JavaVM* vm;
+    JNIEnv* env = nullptr;
```

Review comment:
I propose to add some wording into docs that callbacks are called from the "creation thread" (this is how FFmpeg works for now), so we would not handle case with unknown "native threads" here.
**File:** modules/videoio/misc/java/src/cpp/videoio_converters.cpp
**Change Type:** added
**Context:** PR #27284: Java VideoCapture buffered stream constructor
**Review Line:** 24

**Code Changes:**
```diff
+
+    ~JNIEnvHandler()
+    {
+        if (env && detach)
+        {
+            vm->DetachCurrentThread();
+        }
+    }
+
+    JavaVM* vm;
+    JNIEnv* env = nullptr;
```

Review comment:
Agree, actually, I have concern that even if read/seek were used in the thread that requires `AttachCurrentThread`, the destructor of `JavaStreamReader` might be called in the main thread
**File:** hal/riscv-rvv/src/imgproc/common.hpp
**Change Type:** added
**Context:** PR #27301: hal/riscv-rvv: refactor the building process

**Code Changes:**
```diff
@@ -0,0 +1,76 @@
+// 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.
+//
+// Copyright (C) 2025, SpaceMIT Inc., all rights reserved.
+// Copyright (C) 2025, Institute of Software, Chinese Academy of Sciences.
+// Third party copyrights are property of their respective owners.
+
+#ifndef OPENCV_HAL_RVV_IMGPROC_COMMON_HPP_INCLUDED
```

Review comment:
Please use CV_HAL_BORDER_XXX constants from `modules/core/include/opencv2/core/hal/interface.h`
**File:** hal/ipp/src/sum_ipp.cpp
**Change Type:** added
**Context:** PR #27346: New HAL entry for cv::sum and IPP adoption
**Review Line:** 1

**Code Changes:**
```diff
@@ -0,0 +1,55 @@
+#include "ipp_hal_core.hpp"
+
+#include <opencv2/core.hpp>
+#include <opencv2/core/base.hpp>
+
+#if IPP_VERSION_X100 >= 700
```

Review comment:
License header.
**File:** modules/core/src/sum.dispatch.cpp
**Change Type:** modified
**Context:** PR #27346: New HAL entry for cv::sum and IPP adoption

**Code Changes:**
```diff
@@ -10,14 +10,6 @@
 #include "sum.simd.hpp"
 #include "sum.simd_declarations.hpp" // defines CV_CPU_DISPATCH_MODES_ALL=AVX2,...,BASELINE based on CMakeLists.txt content
 
-#ifndef OPENCV_IPP_SUM
-#undef HAVE_IPP
-#undef CV_IPP_RUN_FAST
-#define CV_IPP_RUN_FAST(f, ...)
-#undef CV_IPP_RUN
-#define CV_IPP_RUN(c, f, ...)
```

Review comment:
`CV_CheckLE` is preferable,
**File:** hal/ipp/src/sum_ipp.cpp
**Change Type:** added
**Context:** PR #27346: New HAL entry for cv::sum and IPP adoption
**Review Line:** 1

**Code Changes:**
```diff
@@ -0,0 +1,55 @@
+#include "ipp_hal_core.hpp"
+
+#include <opencv2/core.hpp>
+#include <opencv2/core/base.hpp>
+
+#if IPP_VERSION_X100 >= 700
```

Review comment:
There are no license headers in IPP HAL for now. I'll fix it with another PR.
**File:** modules/dnn/src/layers/attention_layer.cpp
**Change Type:** modified
**Context:** PR #27238: Rotary positional embeddings

**Code Changes:**
```diff
@@ -24,6 +24,105 @@ static void packWeight(size_t num_heads, size_t head_size, size_t input_hidden_s
     }
 }
 
+
+static void rotationKernel(
+    float* data, const float* rotation_table,
+    size_t seq_len, size_t d
+)
+{
```

Review comment:
No need to duplicate tail and scalar core. You can just close `#if (CV_SIMD || CV_SIMD_SCALABLE)` condition right after vectorized loop and extract `d` from ifdef.. In case, if vector intrinsics are not available, d = 0 and "tail" will be just main loop.
**File:** modules/dnn/src/layers/attention_layer.cpp
**Change Type:** modified
**Context:** PR #27238: Rotary positional embeddings

**Code Changes:**
```diff
@@ -24,6 +24,105 @@ static void packWeight(size_t num_heads, size_t head_size, size_t input_hidden_s
     }
 }
 
+
+static void rotationKernel(
+    float* data, const float* rotation_table,
+    size_t seq_len, size_t d
+)
+{
```

Review comment:
We have `v_sincos` to optimize it: https://docs.opencv.org/5.x/df/d91/group__core__hal__intrin.html#gaebe923bb2935eae727994a359c8c49c0
**File:** modules/dnn/test/test_layers.cpp
**Change Type:** modified
**Context:** PR #27238: Rotary positional embeddings
**Review Line:** 746

**Code Changes:**
```diff
@@ -743,6 +743,32 @@ TEST_F(Layer_RNN_Test, get_set_test)
     EXPECT_EQ(shape(outputs[1]), shape(nT, nS, nH));
 }
 
+TEST(Layer_MHARoPe_Test_Accuracy_with_, Pytorch)
+{
+    Mat QKV = blobFromNPY(_tf("mha_rope.QKV.npy"));
+    Mat QKV_bias = blobFromNPY(_tf("mha_rope.QKV_bias.npy"));
+    std::vector<int> qkv_hidden_sizes = { 256, 256, 256 };
+    LayerParams mhaParams;
```

Review comment:
It'll be great, if the test imports ONNX, but not create the attention layer in code. It allows to check parser and ensure that the implementation handles feasible graph.