mirror of
https://github.com/opencv/opencv_contrib.git
synced 2025-10-20 12:55:15 +08:00

CANN (Compute Architecture of Neural Networks), developped by Huawei, is a heterogeneous computing architecture for AI. Opencv DNN has already suppoted CANN backend [#22634](https://github.com/opencv/opencv/pull/22634). There are more and more users using [Ascend NPU](https://www.hiascend.com/) and programming with CANN, and the number is still growing rapidly. AI training and inference are inseparable from data preprocessing. When users use OpenCV to work with CANN backend, data preprocessing can only run on CPUs, resulting in inefficiency. The purpose of this commit is to enable OpenCV operators on CANN backend. The usage of CANN backend is consistent, Please refer to OpenCV DNN: [CANN backend manual] (https://gist.github.com/fengyuentau/083f7f339592545c1f1d2c1fde6a53dc#file-a_ocv_cann-md): 1. [Install dependencies] (https://gist.github.com/fengyuentau/083f7f339592545c1f1d2c1fde6a53dc#install-dependencies) 2. [Install CANN] (https://gist.github.com/fengyuentau/083f7f339592545c1f1d2c1fde6a53dc#install-cann) 3. [Compile OpenCV with CANN] (https://gist.github.com/fengyuentau/083f7f339592545c1f1d2c1fde6a53dc#build-opencv-with-cann) The CANN backend is used in a similar way to CUDA: | Object | CANN | CUDA | | --------- | ------------ | -------- | | Namespace | cv::cann | cv::cuda | | Matrix | AscendMat | GpuMat | | Stream | AscendStream | Stream | | Event | AscendEvent | Event | The current commit provides CANN backend operator support framework, In order to make code viewing easy, only a few basic interfaces are implemented, all of the following operators are tested and compared result with CPU backend. More operators will continue implement in new independent commits. Co-authored-by: CaoMengqing <cmq0113@163.com>
34 lines
1.5 KiB
C++
34 lines
1.5 KiB
C++
// 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.
|
|
|
|
#ifndef OPENCV_CANNOPS_CANN_PRIVATE_HPP
|
|
#define OPENCV_CANNOPS_CANN_PRIVATE_HPP
|
|
#include "opencv2/cann.hpp"
|
|
|
|
namespace cv
|
|
{
|
|
namespace cann
|
|
{
|
|
void arithm_op(const AscendMat& src1, const AscendMat& src2, AscendMat& dst, const char* op,
|
|
AscendStream& stream);
|
|
void arithm_op(const AscendMat& src, const Scalar& sc, AscendMat& dst, const char* op,
|
|
AscendStream& stream);
|
|
void arithm_op(const Scalar& sc, const AscendMat& src, AscendMat& dst, const char* op,
|
|
AscendStream& stream);
|
|
void arithm_op(const AscendMat& src, AscendMat& dst, const char* op, AscendStream& stream);
|
|
void arithm_op(const AscendMat& src, float scalar, AscendMat& dst, const char* op,
|
|
AscendStream& stream);
|
|
void transpose(const AscendMat& src, int64_t* perm, AscendMat& dst, AscendStream& stream);
|
|
void flip(const AscendMat& src, std::vector<int32_t>& asixs, AscendMat& dst, AscendStream& stream);
|
|
void crop(const AscendMat& src, AscendMat& dst, const AscendMat& sizeSrcNpu, int64_t* offset,
|
|
AscendStream& stream);
|
|
void transData(const AscendMat& src, AscendMat& dst, const char* from, const char* to,
|
|
AscendStream& stream);
|
|
void resize(const AscendMat& src, AscendMat& dst, int32_t* dstSize, int interpolation,
|
|
AscendStream& stream);
|
|
} // namespace cann
|
|
} // namespace cv
|
|
|
|
#endif // OPENCV_CANNOPS_CANN_PRIVATE_HPP
|