1
0
mirror of https://github.com/opencv/opencv_contrib.git synced 2025-10-20 12:55:15 +08:00
Files
opencv_contrib/modules/fastcv/perf/perf_matmul.cpp
adsha-quic 385bd6f35c Merge pull request #3891 from CodeLinaro:3rdPost
FastCV extension 3rd Post #3891

Adding FastCV extensions for merge, split, gemm and arithm APIs add, subtract

### 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
- [ ] The PR is proposed to the proper branch
- [ ] There is a reference to the original bug report and related work
- [ ] There is accuracy test, performance test and test data in opencv_extra repository, if applicable
      Patch to opencv_extra has the same branch name.
- [ ] The feature is well documented and sample code can be built with the project CMake
2025-03-19 11:11:29 +03:00

74 lines
2.1 KiB
C++

/*
* Copyright (c) 2024-2025 Qualcomm Innovation Center, Inc. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*/
#include "perf_precomp.hpp"
namespace opencv_test {
typedef std::tuple<int /*rows1*/, int /*cols1*/, int /*cols2*/> MatMulPerfParams;
typedef perf::TestBaseWithParam<MatMulPerfParams> MatMulPerfTest;
typedef std::tuple<int /*rows1*/, int /*cols1*/, int /*cols2*/, float> MatMulGemmPerfParams;
typedef perf::TestBaseWithParam<MatMulGemmPerfParams> MatMulGemmPerfTest;
PERF_TEST_P(MatMulPerfTest, run,
::testing::Combine(::testing::Values(8, 16, 128, 256), // rows1
::testing::Values(8, 16, 128, 256), // cols1
::testing::Values(8, 16, 128, 256)) // cols2
)
{
auto p = GetParam();
int rows1 = std::get<0>(p);
int cols1 = std::get<1>(p);
int cols2 = std::get<2>(p);
RNG& rng = cv::theRNG();
Mat src1(rows1, cols1, CV_8SC1), src2(cols1, cols2, CV_8SC1);
cvtest::randUni(rng, src1, Scalar::all(-128), Scalar::all(128));
cvtest::randUni(rng, src2, Scalar::all(-128), Scalar::all(128));
Mat dst;
while(next())
{
startTimer();
cv::fastcv::matmuls8s32(src1, src2, dst);
stopTimer();
}
SANITY_CHECK_NOTHING();
}
PERF_TEST_P(MatMulGemmPerfTest, run,
::testing::Combine(::testing::Values(8, 16, 128, 256), // rows1
::testing::Values(8, 16, 128, 256), // cols1
::testing::Values(8, 16, 128, 256), // cols2
::testing::Values(2.5, 5.8)) // alpha
)
{
auto p = GetParam();
int rows1 = std::get<0>(p);
int cols1 = std::get<1>(p);
int cols2 = std::get<2>(p);
float alpha = std::get<3>(p);
RNG& rng = cv::theRNG();
Mat src1(rows1, cols1, CV_32FC1), src2(cols1, cols2, CV_32FC1);
cvtest::randUni(rng, src1, Scalar::all(-128.0), Scalar::all(128.0));
cvtest::randUni(rng, src2, Scalar::all(-128.0), Scalar::all(128.0));
Mat dst;
while (next())
{
startTimer();
cv::fastcv::gemm(src1, src2, dst, alpha, noArray(), 0);
stopTimer();
}
SANITY_CHECK_NOTHING();
}
} // namespace