mirror of
https://github.com/opencv/opencv.git
synced 2026-07-29 23:33:05 +04:00
Merge pull request #28859 from abhishek-gola:fuse_attention
Added Attention fusion and thin gemm support #28859 Merge with: https://github.com/opencv/opencv_extra/pull/1350 Performance numbers after these optimizations: For Device: Intel(R) Core(TM) i9-14900KS, x86, 32 Cores, ubuntu 24.04, | Model | `ENGINE_NEW (Before)` | `ENGINE_NEW (After)` | `ENGINE_ORT` | | :--- | :--- | :--- | :--- | | **BERT** |26.3 ms| 9.15 ms| 9.13 ms| | **ViT** | 79.65 ms| 63.23 ms| 32.3 ms| ### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [x] The PR is proposed to the proper branch - [x] There is a reference to the original bug report and related work - [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [x] The feature is well documented and sample code can be built with the project CMake
This commit is contained in:
@@ -406,6 +406,22 @@ PERF_TEST_P_(DNNTestNetwork, VIT_B_32)
|
||||
processNet("dnn/onnx/models/vit_b_32.onnx", "", cv::Size(224, 224));
|
||||
}
|
||||
|
||||
PERF_TEST_P_(DNNTestNetwork, BERT)
|
||||
{
|
||||
const int seq_len = 9;
|
||||
int64_t input_ids_data[seq_len] = {101, 1996, 103, 2938, 2006, 1996, 13523, 1012, 102};
|
||||
int64_t attention_mask_data[seq_len] = {1, 1, 1, 1, 1, 1, 1, 1, 1};
|
||||
int64_t token_type_ids_data[seq_len] = {0, 0, 0, 0, 0, 0, 0, 0, 0};
|
||||
int shp[2] = {1, seq_len};
|
||||
Mat input_ids(2, shp, CV_64S, input_ids_data);
|
||||
Mat attention_mask(2, shp, CV_64S, attention_mask_data);
|
||||
Mat token_type_ids(2, shp, CV_64S, token_type_ids_data);
|
||||
processNet("dnn/onnx/models/bert.onnx", "",
|
||||
{std::make_tuple(input_ids, "input_ids"),
|
||||
std::make_tuple(attention_mask, "attention_mask"),
|
||||
std::make_tuple(token_type_ids, "token_type_ids")});
|
||||
}
|
||||
|
||||
PERF_TEST_P_(DNNTestNetwork, VIT_Base_Patch16_224)
|
||||
{
|
||||
applyTestTag(CV_TEST_TAG_MEMORY_512MB);
|
||||
|
||||
Reference in New Issue
Block a user