mirror of https://github.com/opencv/opencv.git
Merge pull request #24122 from fengyuentau:remove_tengine
dnn: cleanup of tengine backend #24122 🚀 Cleanup for OpenCV 5.0. Tengine backend is added for convolution layer speedup on ARM CPUs, but it is not maintained and the convolution layer on our default backend has reached similar performance to that of Tengine. Tengine backend related PRs: - https://github.com/opencv/opencv/pull/16724 - https://github.com/opencv/opencv/pull/18323 ### 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 CMakepull/24138/head
parent
7d59db4ec4
commit
ba70ec99b3
10 changed files with 3 additions and 696 deletions
@ -1,80 +0,0 @@ |
|||||||
# COPYRIGHT |
|
||||||
# Licensed to the Apache Software Foundation (ASF) under one |
|
||||||
# or more contributor license agreements. See the NOTICE file |
|
||||||
# distributed with this work for additional information |
|
||||||
# regarding copyright ownership. The ASF licenses this file |
|
||||||
# to you under the Apache License, Version 2.0 (the |
|
||||||
# License); you may not use this file except in compliance |
|
||||||
# with the License. You may obtain a copy of the License at |
|
||||||
# |
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0 |
|
||||||
# |
|
||||||
# Unless required by applicable law or agreed to in writing, |
|
||||||
# software distributed under the License is distributed on an |
|
||||||
# AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
|
||||||
# KIND, either express or implied. See the License for the |
|
||||||
# specific language governing permissions and limitations |
|
||||||
# under the License. |
|
||||||
# |
|
||||||
# Copyright (c) 2020, OPEN AI LAB |
|
||||||
# Author: qtang@openailab.com or https://github.com/BUG1989 |
|
||||||
# qli@openailab.com |
|
||||||
# sqfu@openailab.com |
|
||||||
|
|
||||||
SET(TENGINE_COMMIT_VERSION "e89cf8870de2ff0a80cfe626c0b52b2a16fb302e") |
|
||||||
SET(OCV_TENGINE_DIR "${OpenCV_BINARY_DIR}/3rdparty/libtengine") |
|
||||||
SET(OCV_TENGINE_SOURCE_PATH "${OCV_TENGINE_DIR}/Tengine-${TENGINE_COMMIT_VERSION}") |
|
||||||
|
|
||||||
IF(EXISTS "${OCV_TENGINE_SOURCE_PATH}") |
|
||||||
MESSAGE(STATUS "Tengine is exist already at: ${OCV_TENGINE_SOURCE_PATH}") |
|
||||||
|
|
||||||
SET(Tengine_FOUND ON) |
|
||||||
SET(BUILD_TENGINE ON) |
|
||||||
ELSE() |
|
||||||
SET(OCV_TENGINE_FILENAME "${TENGINE_COMMIT_VERSION}.zip")#name |
|
||||||
SET(OCV_TENGINE_URL "https://github.com/OAID/Tengine/archive/") #url |
|
||||||
SET(tengine_md5sum 23f61ebb1dd419f1207d8876496289c5) #md5sum |
|
||||||
|
|
||||||
ocv_download(FILENAME ${OCV_TENGINE_FILENAME} |
|
||||||
HASH ${tengine_md5sum} |
|
||||||
URL |
|
||||||
"${OPENCV_TENGINE_URL}" |
|
||||||
"$ENV{OPENCV_TENGINE_URL}" |
|
||||||
"${OCV_TENGINE_URL}" |
|
||||||
DESTINATION_DIR "${OCV_TENGINE_DIR}" |
|
||||||
ID TENGINE |
|
||||||
STATUS res |
|
||||||
UNPACK RELATIVE_URL) |
|
||||||
|
|
||||||
if (NOT res) |
|
||||||
MESSAGE(STATUS "TENGINE DOWNLOAD FAILED. Turning Tengine_FOUND off.") |
|
||||||
SET(Tengine_FOUND OFF) |
|
||||||
else () |
|
||||||
MESSAGE(STATUS "TENGINE DOWNLOAD success . ") |
|
||||||
|
|
||||||
SET(Tengine_FOUND ON) |
|
||||||
SET(BUILD_TENGINE ON) |
|
||||||
endif() |
|
||||||
ENDIF() |
|
||||||
|
|
||||||
if(BUILD_TENGINE) |
|
||||||
SET(HAVE_TENGINE 1) |
|
||||||
|
|
||||||
if(NOT ANDROID) |
|
||||||
# linux system |
|
||||||
if(CMAKE_SYSTEM_PROCESSOR STREQUAL arm) |
|
||||||
SET(TENGINE_TOOLCHAIN_FLAG "-march=armv7-a") |
|
||||||
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL aarch64) ## AARCH64 |
|
||||||
SET(TENGINE_TOOLCHAIN_FLAG "-march=armv8-a") |
|
||||||
endif() |
|
||||||
endif() |
|
||||||
|
|
||||||
SET(BUILT_IN_OPENCV ON) ## set for tengine compile discern . |
|
||||||
SET(Tengine_INCLUDE_DIR "${OCV_TENGINE_SOURCE_PATH}/include" CACHE INTERNAL "") |
|
||||||
if(EXISTS "${OCV_TENGINE_SOURCE_PATH}/CMakeLists.txt") |
|
||||||
add_subdirectory("${OCV_TENGINE_SOURCE_PATH}" "${OCV_TENGINE_DIR}/build") |
|
||||||
else() |
|
||||||
message(WARNING "TENGINE: Missing 'CMakeLists.txt' in source code package: ${OCV_TENGINE_SOURCE_PATH}") |
|
||||||
endif() |
|
||||||
SET(Tengine_LIB "tengine" CACHE INTERNAL "") |
|
||||||
endif() |
|
@ -1,78 +0,0 @@ |
|||||||
# COPYRIGHT |
|
||||||
# Licensed to the Apache Software Foundation (ASF) under one |
|
||||||
# or more contributor license agreements. See the NOTICE file |
|
||||||
# distributed with this work for additional information |
|
||||||
# regarding copyright ownership. The ASF licenses this file |
|
||||||
# to you under the Apache License, Version 2.0 (the |
|
||||||
# License); you may not use this file except in compliance |
|
||||||
# with the License. You may obtain a copy of the License at |
|
||||||
# |
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0 |
|
||||||
# |
|
||||||
# Unless required by applicable law or agreed to in writing, |
|
||||||
# software distributed under the License is distributed on an |
|
||||||
# AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
|
||||||
# KIND, either express or implied. See the License for the |
|
||||||
# specific language governing permissions and limitations |
|
||||||
# under the License. |
|
||||||
# |
|
||||||
# Copyright (c) 2020, OPEN AI LAB |
|
||||||
# Author: qtang@openailab.com or https://github.com/BUG1989 |
|
||||||
# |
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------- |
|
||||||
# Path for Tengine binaries |
|
||||||
# ---------------------------------------------------------------------------- |
|
||||||
set(OPENCV_LIBTENGINE_ROOT_DIR "" CACHE PATH "Path to TENGINE binaries installation") |
|
||||||
|
|
||||||
IF(OPENCV_LIBTENGINE_ROOT_DIR AND NOT BUILD_TENGINE) |
|
||||||
|
|
||||||
MESSAGE(STATUS "TENGINE:-- Use binaries at ${OPENCV_LIBTENGINE_ROOT_DIR}") |
|
||||||
|
|
||||||
SET(Tengine_FOUND ON) |
|
||||||
set(BUILD_TENGINE OFF) |
|
||||||
|
|
||||||
SET(Tengine_INCLUDE_DIR "${OPENCV_LIBTENGINE_ROOT_DIR}/include" CACHE PATH "TENGINE include dir") |
|
||||||
SET(Tengine_LIB "${OPENCV_LIBTENGINE_ROOT_DIR}/lib/libtengine.a" CACHE PATH "TENGINE library dir") |
|
||||||
|
|
||||||
ELSE() |
|
||||||
IF(ANDROID) |
|
||||||
IF(OPENCV_TENGINE_FORCE_ANDROID) |
|
||||||
# nothing, use Android |
|
||||||
ELSEIF(OPENCV_TENGINE_SKIP_ANDROID) |
|
||||||
set(Tengine_FOUND OFF) |
|
||||||
set(HAVE_TENGINE FALSE) |
|
||||||
return() |
|
||||||
ELSEIF(NOT DEFINED ANDROID_NDK_REVISION) |
|
||||||
MESSAGE(STATUS "Android NDK version Tengine not support: ANDROID_NDK_REVISION is not defined") |
|
||||||
set(Tengine_FOUND OFF) |
|
||||||
set(HAVE_TENGINE FALSE) |
|
||||||
return() |
|
||||||
ELSEIF(ANDROID_NDK_REVISION VERSION_LESS 14) |
|
||||||
MESSAGE(STATUS "Android NDK version Tengine not support: ANDROID_NDK_REVISION=${ANDROID_NDK_REVISION}") |
|
||||||
set(Tengine_FOUND OFF) |
|
||||||
set(HAVE_TENGINE FALSE) |
|
||||||
return() |
|
||||||
ENDIF() |
|
||||||
ENDIF() |
|
||||||
MESSAGE(STATUS "TENGINE:-- Build Tengine from source code. ") |
|
||||||
include("${OpenCV_SOURCE_DIR}/3rdparty/libtengine/tengine.cmake") |
|
||||||
ENDIF() |
|
||||||
|
|
||||||
IF(NOT Tengine_LIB) |
|
||||||
SET(Tengine_FOUND OFF) |
|
||||||
MESSAGE(STATUS "#### Could not find Tengine lib. Turning Tengine_FOUND off") |
|
||||||
ENDIF() |
|
||||||
|
|
||||||
IF (Tengine_FOUND) |
|
||||||
MESSAGE(STATUS "Found Tengine include: ${Tengine_INCLUDE_DIR}") |
|
||||||
MESSAGE(STATUS "Found Tengine libraries: ${Tengine_LIB}") |
|
||||||
set(HAVE_TENGINE 1) |
|
||||||
set(TENGINE_LIBRARIES ${Tengine_LIB}) |
|
||||||
set(TENGINE_INCLUDE_DIRS ${Tengine_INCLUDE_DIR}) |
|
||||||
ENDIF (Tengine_FOUND) |
|
||||||
|
|
||||||
MARK_AS_ADVANCED( |
|
||||||
Tengine_INCLUDE_DIR |
|
||||||
Tengine_LIB |
|
||||||
) |
|
@ -1,53 +0,0 @@ |
|||||||
/*
|
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one |
|
||||||
* or more contributor license agreements. See the NOTICE file |
|
||||||
* distributed with this work for additional information |
|
||||||
* regarding copyright ownership. The ASF licenses this file |
|
||||||
* to you under the Apache License, Version 2.0 (the |
|
||||||
* License); you may not use this file except in compliance |
|
||||||
* with the License. You may obtain a copy of the License at |
|
||||||
* |
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
* |
|
||||||
* Unless required by applicable law or agreed to in writing, |
|
||||||
* software distributed under the License is distributed on an |
|
||||||
* AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
|
||||||
* KIND, either express or implied. See the License for the |
|
||||||
* specific language governing permissions and limitations |
|
||||||
* under the License. |
|
||||||
*/ |
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (c) 2020, OPEN AI LAB |
|
||||||
* Author: qtang@openailab.com |
|
||||||
*/ |
|
||||||
|
|
||||||
#ifndef TENGINE_GRAPH_CONVOLUTION_HPP |
|
||||||
#define TENGINE_GRAPH_CONVOLUTION_HPP |
|
||||||
|
|
||||||
#define FLOAT_TO_REALSIZE (4) |
|
||||||
#ifdef HAVE_TENGINE |
|
||||||
|
|
||||||
#include "tengine_c_api.h" |
|
||||||
|
|
||||||
namespace cv |
|
||||||
{ |
|
||||||
namespace dnn |
|
||||||
{ |
|
||||||
// pad_h0: pad_top
|
|
||||||
// pad_h1: pad_bottom
|
|
||||||
// pad_w0: pad_left
|
|
||||||
// pad_w1: pad_right
|
|
||||||
teng_graph_t tengine_init(const char* name , float* input_, int inch, int group, int in_h, int in_w, |
|
||||||
float *output_, int out_b, int outch, int out_h, int out_w, |
|
||||||
float *kernel_,int kernel_s , int kernel_h, int kernel_w, |
|
||||||
float *teg_bias, int stride_h, int stride_w, |
|
||||||
int pad_h0, int pad_h1, int pad_w0, int pad_w1, int dilation_h, int dilation_w, |
|
||||||
size_t wstep, const std::string padMode , teng_graph_t& graph, int nstripes) ; |
|
||||||
|
|
||||||
bool tengine_forward(teng_graph_t& graph) ; |
|
||||||
bool tengine_release(teng_graph_t& graph) ; |
|
||||||
} |
|
||||||
} |
|
||||||
#endif |
|
||||||
#endif /* TENGINE_GRAPH_CONVOLUTION_HPP */ |
|
Loading…
Reference in new issue