← Back to Pull requests

[Snippets][CPU][ARM] Enable bitwise ops in snippets #38245

Open
aobolensk opened this pull request with 318 lines diff across 14 files
View on GitHub
aobolensk aobolensk commented on Sep 18, 2026 03:59 UTC
Author

Details:


Enabled AArch64 Snippets ops: BitwiseAnd, BitwiseOr, BitwiseXor, and BitwiseNot

Tickets:


- N/A

AI Assistance:


- AI assistance used: yes
- Implementation is assisted and after that manually tested and reviewed

Diff: 318 lines (+275 / -43) across 14 files Reviewer: v-Golubev Review duration: 36150m
All Vouch review confidence checks passed
Residual risk 0.08 = Change Risk (0.57) × (1 − Review Confidence (0.86)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.57 · 318 lines diff across 14 files
0.57
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.87 · 5 substantive comment(s)
0.87
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 50%
86%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size diff_size
0.345
Real PR Conversation Timeline
17 items
allnes allnes commented on Sep 18, 2026 18:46 UTC
Contributor

build_jenkins

aobolensk aobolensk commented on Oct 04, 2026 09:26 UTC
Author

@v-Golubev please take a look

v-Golubev v-Golubev commented on code on Oct 05, 2026 18:08 UTC
Code Review
src/common/snippets/tests/src/pass/collapse_subgraph.cpp:1
@@ -6,18 +6,69 @@
 
 #include <gtest/gtest.h>
 
+#include <memory>
 #include <pass/collapse_subgraph.hpp>
 #include <subgraph_common_parent.hpp>
 #include <subgraph_converts.hpp>
 #include <subgraph_fq.hpp>
 #include <subgraph_simple.hpp>
 
+#include "common_test_utils/ov_test_utils.hpp"
+#include "openvino/core/model.hpp"
+#include "openvino/core/partial_shape.hpp"
+#include "openvino/core/type/element_type.hpp"
+#include "openvino/op/bitwise_and.hpp"
+#include "openvino/op/bitwise_not.hpp"
+#include "openvino/op/bitwise_or.hpp"
+#include "openvino/op/bitwise_xor.hpp"
+#include "openvino/op/parameter.hpp"
+#include "snippets/op/result.hpp"
+#include "snippets/op/subgraph.hpp"
+#include "snippets/pass/tokenization.hpp"
+#include "snippets_helpers.hpp"
 #include "utils.hpp"
 
 namespace ov {
 namespace test {
 namespace snippets {
 
+namespace {
+class BitwiseFunction : public SnippetsFunctionBase {

Let's move BitwiseFunction into its own header/cpp alongside EltwiseFunction (e.g. a new subgraph_bitwise.hpp), and take the input shapes as a constructor parameter instead of hardcoding {2, 16}

v-Golubev v-Golubev commented on code on Oct 05, 2026 18:08 UTC
Code Review
src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/eltwise.cpp:1
@@ -303,6 +303,12 @@ static const std::vector<CPUSpecificParams>& bitwiseCpuParams() {
         CPUSpecificParams({nchw, nchw}, {nchw}, {}, bitwiseExpectedPrimitive())};
     return params;
 }
+#if defined(OPENVINO_ARCH_ARM64)
+static const std::vector<CPUSpecificParams>& bitwiseSnippetsCpuParams() {

Let's move bitwiseSnippetsCpuParams() and the three new *_Snippets instantiations below to instances/arm/eltwise.cpp instead of wrapping them in #if defined(OPENVINO_ARCH_ARM64) here

v-Golubev v-Golubev commented on code on Oct 05, 2026 18:18 UTC
Code Review
src/plugins/intel_cpu/src/transformations/transformation_pipeline.cpp:1
@@ -1607,25 +1611,30 @@ void Transformations::MainSnippets() {
             ExtractReshapesFromMHA);
     }
 
-    CPU_SET_CALLBACK_COMMON(
-        snippetsManager,
-        [&](const std::shared_ptr<const ov::Node>& n) -> bool {
-            if (!ignoreCallback) {
-                if (n->is_dynamic() || !is_supported_op(n))
-                    return true;
+    auto tokenize_snippets_callback = [&](const std::shared_ptr<const ov::Node>& n) -> bool {
+#if !defined(OPENVINO_ARCH_ARM64)
+        if (ov::is_type_any_of<const ov::op::util::BinaryElementwiseBitwise, const ov::op::v13::BitwiseNot>(n)) {

Let's better put this condition in dedicated is_supported_op lambda

allnes allnes commented on Oct 05, 2026 18:36 UTC
Contributor

build_jenkins

allnes allnes commented on Oct 05, 2026 18:37 UTC
Contributor

build_jenkins

aobolensk aobolensk commented on code on Oct 05, 2026 19:42 UTC
Code Review
src/plugins/intel_cpu/src/transformations/transformation_pipeline.cpp:1
@@ -1607,25 +1611,30 @@ void Transformations::MainSnippets() {
             ExtractReshapesFromMHA);
     }
 
-    CPU_SET_CALLBACK_COMMON(
-        snippetsManager,
-        [&](const std::shared_ptr<const ov::Node>& n) -> bool {
-            if (!ignoreCallback) {
-                if (n->is_dynamic() || !is_supported_op(n))
-                    return true;
+    auto tokenize_snippets_callback = [&](const std::shared_ptr<const ov::Node>& n) -> bool {
+#if !defined(OPENVINO_ARCH_ARM64)
+        if (ov::is_type_any_of<const ov::op::util::BinaryElementwiseBitwise, const ov::op::v13::BitwiseNot>(n)) {

moved

aobolensk aobolensk commented on code on Oct 05, 2026 19:42 UTC
Code Review
src/common/snippets/tests/src/pass/collapse_subgraph.cpp:1
@@ -6,18 +6,69 @@
 
 #include <gtest/gtest.h>
 
+#include <memory>
 #include <pass/collapse_subgraph.hpp>
 #include <subgraph_common_parent.hpp>
 #include <subgraph_converts.hpp>
 #include <subgraph_fq.hpp>
 #include <subgraph_simple.hpp>
 
+#include "common_test_utils/ov_test_utils.hpp"
+#include "openvino/core/model.hpp"
+#include "openvino/core/partial_shape.hpp"
+#include "openvino/core/type/element_type.hpp"
+#include "openvino/op/bitwise_and.hpp"
+#include "openvino/op/bitwise_not.hpp"
+#include "openvino/op/bitwise_or.hpp"
+#include "openvino/op/bitwise_xor.hpp"
+#include "openvino/op/parameter.hpp"
+#include "snippets/op/result.hpp"
+#include "snippets/op/subgraph.hpp"
+#include "snippets/pass/tokenization.hpp"
+#include "snippets_helpers.hpp"
 #include "utils.hpp"
 
 namespace ov {
 namespace test {
 namespace snippets {
 
+namespace {
+class BitwiseFunction : public SnippetsFunctionBase {

done

aobolensk aobolensk commented on code on Oct 05, 2026 19:42 UTC
Code Review
src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/eltwise.cpp:1
@@ -303,6 +303,12 @@ static const std::vector<CPUSpecificParams>& bitwiseCpuParams() {
         CPUSpecificParams({nchw, nchw}, {nchw}, {}, bitwiseExpectedPrimitive())};
     return params;
 }
+#if defined(OPENVINO_ARCH_ARM64)
+static const std::vector<CPUSpecificParams>& bitwiseSnippetsCpuParams() {

done

v-Golubev v-Golubev commented on code on Oct 06, 2026 16:35 UTC
Code Review
src/plugins/intel_cpu/src/transformations/transformation_pipeline.cpp:1
@@ -1447,7 +1451,15 @@ void Transformations::MainSnippets() {
     };
 #endif  // OPENVINO_ARCH_X86_64
 
-    auto is_supported_op = []([[maybe_unused]] const std::shared_ptr<const ov::Node>& n) -> bool {
+    auto is_supported_op = [ignoreCallback]([[maybe_unused]] const std::shared_ptr<const ov::Node>& n) -> bool {
+#if !defined(OPENVINO_ARCH_ARM64)
+        if (ov::is_type_any_of<const ov::op::util::BinaryElementwiseBitwise, const ov::op::v13::BitwiseNot>(n)) {
+            return false;
+        }
+#endif
+        if (ignoreCallback) {
+            return true;
+        }

I'd like to understand why we have to handle ignoreCallback here. Do I understand correctly that BinaryElementwiseBitwise must be included to "unsupported" list regardless of the ignoreCallback value, whereas the rest "unsupported" nodes are included to the unsupported list only when ignoreCallback is false?

allnes allnes commented on Oct 06, 2026 19:21 UTC
Contributor

build_jenkins

aobolensk aobolensk commented on code on Oct 08, 2026 03:18 UTC
Code Review
src/plugins/intel_cpu/src/transformations/transformation_pipeline.cpp:1
@@ -1447,7 +1451,15 @@ void Transformations::MainSnippets() {
     };
 #endif  // OPENVINO_ARCH_X86_64
 
-    auto is_supported_op = []([[maybe_unused]] const std::shared_ptr<const ov::Node>& n) -> bool {
+    auto is_supported_op = [ignoreCallback]([[maybe_unused]] const std::shared_ptr<const ov::Node>& n) -> bool {
+#if !defined(OPENVINO_ARCH_ARM64)
+        if (ov::is_type_any_of<const ov::op::util::BinaryElementwiseBitwise, const ov::op::v13::BitwiseNot>(n)) {
+            return false;
+        }
+#endif
+        if (ignoreCallback) {
+            return true;
+        }

Yes, bitwise ops still need to be rejected on non-ARM because their Snippets emitters are registered only

v-Golubev v-Golubev commented on Oct 08, 2026 09:04 UTC
Contributor

build_jenkins

aobolensk aobolensk commented on Oct 10, 2026 19:18 UTC
Author

@v-Golubev it seems jenkins part should be just restarted

v-Golubev v-Golubev commented on code on Oct 12, 2026 10:18 UTC
Code Review
src/plugins/intel_cpu/src/transformations/transformation_pipeline.cpp:1
@@ -1447,7 +1451,15 @@ void Transformations::MainSnippets() {
     };
 #endif  // OPENVINO_ARCH_X86_64
 
-    auto is_supported_op = []([[maybe_unused]] const std::shared_ptr<const ov::Node>& n) -> bool {
+    auto is_supported_op = [ignoreCallback]([[maybe_unused]] const std::shared_ptr<const ov::Node>& n) -> bool {
+#if !defined(OPENVINO_ARCH_ARM64)
+        if (ov::is_type_any_of<const ov::op::util::BinaryElementwiseBitwise, const ov::op::v13::BitwiseNot>(n)) {
+            return false;
+        }
+#endif
+        if (ignoreCallback) {
+            return true;
+        }

It looks to me that is_unsupported lambda must be always checked (because the snippets would just fail if such op is tokenized), regardless of the ignoreCallback value. The ignoreCallback should be taken into account only for is_unsupported_by_common_tokenization. Do you think it makes sense?

Reviewers
Assignees
aobolensk aobolensk
Labels
risk: low confidence: 86.1% reviewed
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 56.5% (MEDIUM) · Higher = larger blast radius
56.5%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 86.1% · Lower = rushed or shallow review
86.1%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 7.8% · Safe to merge
7.8%