Introduce CMAKE option TIM_VX_DBG_DISABLE_TENSOR_HNDL=OFF
Enable/Disable tensorFromHandle usage Signed-off-by: ZhangXiang <Xiang.Zhang@verisilicon.com>
This commit is contained in:
parent
ea4ba66b94
commit
1c6041c394
|
|
@ -12,6 +12,7 @@ option(TIM_VX_BUILD_EXAMPLES "Build demos show general usage"
|
|||
option(TIM_VX_ENABLE_VIPLITE "Enable lite driver api support" OFF)
|
||||
option(TIM_VX_ENABLE_40BIT "Enable large memory support" OFF)
|
||||
option(TIM_VX_ENABLE_PLATFORM "Enable multi devices support" OFF)
|
||||
option(TIM_VX_DBG_ENABLE_TENSOR_HNDL "Enable built-in tensor from handle: use malloced memory instead of VideoMemory by kernel driver" ON)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 14)
|
||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||
|
|
@ -23,6 +24,12 @@ if(${TIM_VX_CODE_COVERAGE})
|
|||
set(CMAKE_C_FLAGS "-g -O0 --coverage -fprofile-arcs -ftest-coverage")
|
||||
endif()
|
||||
|
||||
if(${TIM_VX_DBG_ENABLE_TENSOR_HNDL})
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DENABLE_TENSOR_HNDL=1")
|
||||
else()
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DENABLE_TENSOR_HNDL=0")
|
||||
endif()
|
||||
|
||||
include(GNUInstallDirs)
|
||||
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
|
||||
set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/install" CACHE PATH "" FORCE)
|
||||
|
|
|
|||
|
|
@ -31,6 +31,10 @@
|
|||
#include "type_utils.h"
|
||||
#include "vsi_nn_pub.h"
|
||||
|
||||
#ifndef ENABLE_TENSOR_HNDL
|
||||
#define ENABLE_TENSOR_HNDL 1
|
||||
#endif
|
||||
|
||||
namespace {
|
||||
|
||||
void PackTensorDtype(tim::vx::TensorSpec& spec, vsi_nn_dtype_t* dtype) {
|
||||
|
|
@ -282,6 +286,10 @@ void TensorImpl::unmap() {
|
|||
bool TensorImpl::Init(void *external_cache) {
|
||||
vsi_nn_tensor_attr_t attr;
|
||||
|
||||
#if (!ENABLE_TENSOR_HNDL)
|
||||
(void)external_cache;
|
||||
#endif
|
||||
|
||||
memset(&attr, 0x00, sizeof(attr));
|
||||
attr.dim_num = spec_.shape_.size();
|
||||
attr.is_const = static_cast<bool>(spec_.attr_ & TensorAttribute::CONSTANT);
|
||||
|
|
@ -299,6 +307,7 @@ bool TensorImpl::Init(void *external_cache) {
|
|||
|
||||
PackTensorDtype(spec_, &attr.dtype);
|
||||
|
||||
#if(ENABLE_TENSOR_HNDL)
|
||||
if ((spec_.attr_ & TensorAttribute::INPUT) ||
|
||||
(spec_.attr_ & TensorAttribute::OUTPUT)) {
|
||||
#ifdef VX_CREATE_TENSOR_SUPPORT_PHYSICAL
|
||||
|
|
@ -322,6 +331,7 @@ bool TensorImpl::Init(void *external_cache) {
|
|||
#endif
|
||||
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
id_ = vsi_nn_AddTensor(graph_->graph(), VSI_NN_TENSOR_ID_AUTO, &attr,
|
||||
nullptr);
|
||||
|
|
|
|||
Loading…
Reference in New Issue