Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cpu: aarch64: add brgemm bwd data support for block size 8 and 16 #2865

Merged
merged 1 commit into from
Mar 26, 2025

Conversation

rpushkarr
Copy link
Contributor

Description

This pull request adds support for BRGEMM backward data (BWD) on CPU for the AArch64 architecture, specifically for block sizes 8 and 16. The following changes have been made to enable this support:

New Files Added:

  • jit_brgemm_bwd_data.cpp – Implements the JIT kernel for BRGEMM backward data.

  • jit_brgemm_bwd_data.hpp – Defines the interface and data structures for the BRGEMM backward data kernel.

Template Changes:
The brgemm_convolution_fwd_t template has been updated to support inversion by adding a boolean parameter.

Checklist

General

  • [ ✓] Do all unit and benchdnn tests (make test and make test_benchdnn_*) pass locally for each commit?
  • [ ✓] Have you formatted the code using clang-format?

@rpushkarr rpushkarr requested review from a team as code owners March 12, 2025 10:20
@github-actions github-actions bot added the platform:cpu-aarch64 Codeowner: @oneapi-src/onednn-cpu-aarch64 label Mar 12, 2025
@Radu2k Radu2k self-assigned this Mar 12, 2025
template struct brgemm_convolution_fwd_t<sve_256>;
template struct brgemm_convolution_fwd_t<sve_256, true>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use_inversion was moved to convolution op_desc some time ago. I would highly appreciate if you replace a templated argument of the implementation with a code relying on a member of the op_desc.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dzarukin Thank you for the suggestion. I haven’t worked much on this file yet, so I’d prefer to keep the current implementation as is for now since the PR works without modifying use_inversion. Also, updating use_inversion would require changes in other files, which we can address as a future task. Let me know if that works!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, updating use_inversion would require changes in other files

I don't see it used in other files. The further it delayed the harder it's going to remove it. I don't see why would it take too long to make the code better. Thanks.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dzarukin Thank you for the feedback. I've made the changes now — you can review them at your convenience. Let me know if you have any further suggestions.

@rpushkarr rpushkarr requested review from a team as code owners March 18, 2025 07:24
@rpushkarr rpushkarr force-pushed the jit_aarch64_brgemm_bwd_data branch from cb520db to 92ce79e Compare March 18, 2025 07:40

brgemm_convolution_bwd_t(const pd_t *apd) : primitive_t(apd) {};

~brgemm_convolution_bwd_t() = default;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
~brgemm_convolution_bwd_t() = default;
~brgemm_convolution_bwd_t() override = default;

@@ -0,0 +1,80 @@
/*******************************************************************************
* Copyright 2022-2024 Intel Corporation
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Intel copyright is not needed here and for the new file above.

*******************************************************************************/

#include "common/c_types_map.hpp"
#include "common/compiler_workarounds.hpp"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one shouldn't be needed here.

@rpushkarr rpushkarr force-pushed the jit_aarch64_brgemm_bwd_data branch from 0b7d56a to a892566 Compare March 20, 2025 04:27
@rpushkarr
Copy link
Contributor Author

@dzarukin Thank you for the approval! I've updated the files/code based on your suggestion

@rpushkarr rpushkarr requested a review from dzarukin March 20, 2025 05:00
@rpushkarr
Copy link
Contributor Author

@Radu2k Could you please review this PR at your earliest convenience?

Copy link
Contributor

@Radu2k Radu2k left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks for the contribution!

@rpushkarr
Copy link
Contributor Author

@dzarukin Thanks for the approval! I've made the updates based on your suggestions. Could you please re-review and approve the PR?

#include "cpu/cpu_convolution_pd.hpp"

#include "cpu/aarch64/jit_brgemm_1x1_conv.hpp"
#include "cpu/aarch64/jit_brgemm_conv.hpp"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: seems these two can move to cpp-file instead.

*******************************************************************************/

#ifndef CPU_X64_JIT_BRGEMM_CONV_BWD_HPP
#define CPU_X64_JIT_BRGEMM_CONV_BWD_HPP
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#define CPU_X64_JIT_BRGEMM_CONV_BWD_HPP
#define CPU_AARCH64_JIT_BRGEMM_CONV_BWD_HPP

break; // non-1x1 implementation found
}
}
if (it == it.end()) { return status::unimplemented; }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (it == it.end()) { return status::unimplemented; }
VDISPATCH_CONV(it != it.end(), "Implementation wasn't found");

@rpushkarr rpushkarr force-pushed the jit_aarch64_brgemm_bwd_data branch from 53de57f to 3e6e67b Compare March 24, 2025 03:39
@rpushkarr
Copy link
Contributor Author

@dzarukin @Radu2k I've implemented all the suggested changes. Thank you!

@rpushkarr
Copy link
Contributor Author

@dzarukin I've updated all the changes as requested. Please review and proceed with the merge if there are no further issues. Thank you!

@Sqvid Sqvid merged commit 068b775 into uxlfoundation:main Mar 26, 2025
20 of 21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform:cpu-aarch64 Codeowner: @oneapi-src/onednn-cpu-aarch64
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants