From 98966dac9c54641912a14f06d68413cfaa09300c Mon Sep 17 00:00:00 2001 From: Antkillerfarm Date: Wed, 30 Aug 2023 14:25:45 +0800 Subject: [PATCH] build fix for export Swap Handle API (#643) PR #635 build error fix Type: bug fix Signed-off-by: Tang Jing --- include/tim/vx/tensor.h | 2 -- src/tim/vx/tensor.cc | 8 ++++++-- src/tim/vx/tensor_private.h | 4 ---- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/include/tim/vx/tensor.h b/include/tim/vx/tensor.h index 8ba8861..2623501 100644 --- a/include/tim/vx/tensor.h +++ b/include/tim/vx/tensor.h @@ -154,9 +154,7 @@ class Tensor { virtual bool SwapHandle(void* new_ptr, bool is_new_ptr_malloc_by_ovxlib, void** old_ptr) = 0; virtual bool SwapHandle(std::shared_ptr tensor) = 0; -#ifdef VSI_SWAP_HANDLE_CACHE_SUPPORT virtual bool SwapHandleWithCache(std::shared_ptr tensor) = 0; -#endif virtual bool FlushCacheForHandle() = 0; virtual bool InvalidateCacheForHandle() = 0; virtual void* map(bool invalidate_cpu_cache = false) = 0; diff --git a/src/tim/vx/tensor.cc b/src/tim/vx/tensor.cc index 4386b08..ccde1f4 100644 --- a/src/tim/vx/tensor.cc +++ b/src/tim/vx/tensor.cc @@ -249,8 +249,8 @@ bool TensorImpl::SwapHandle(std::shared_ptr tensor) { return retn; } -#ifdef VSI_SWAP_HANDLE_CACHE_SUPPORT bool TensorImpl::SwapHandleWithCache(std::shared_ptr tensor) { +#ifdef VSI_SWAP_HANDLE_CACHE_SUPPORT bool retn = true; if (VSI_NN_TENSOR_ID_NA != id_) { retn = false; @@ -266,8 +266,12 @@ bool TensorImpl::SwapHandleWithCache(std::shared_ptr tensor) { } } return retn; -} +#else + (void)tensor; + VSILOGE("Your ovxlib DO NOT support vsi_nn_SwapTensorHandleWithCache API"); + return false; #endif +} bool TensorImpl::FlushCacheForHandle() { if (!(spec_.attr_ & TensorAttribute::INPUT)) { diff --git a/src/tim/vx/tensor_private.h b/src/tim/vx/tensor_private.h index 5e14d75..d76cbef 100644 --- a/src/tim/vx/tensor_private.h +++ b/src/tim/vx/tensor_private.h @@ -51,9 +51,7 @@ class TensorImpl : public Tensor { bool SwapHandle(void* new_ptr, bool is_new_ptr_malloc_by_ovxlib, void** old_ptr) override; bool SwapHandle(std::shared_ptr tensor) override; -#ifdef VSI_SWAP_HANDLE_CACHE_SUPPORT bool SwapHandleWithCache(std::shared_ptr tensor) override; -#endif bool FlushCacheForHandle() override; bool InvalidateCacheForHandle() override; void* map(bool invalidate_cpu_cache = false) override; @@ -101,12 +99,10 @@ class TensorPlaceholder : public Tensor { (void)tensor; return false; } -#ifdef VSI_SWAP_HANDLE_CACHE_SUPPORT bool SwapHandleWithCache(std::shared_ptr tensor) override { (void)tensor; return false; } -#endif bool InvalidateCacheForHandle() override { return false; } bool FlushCacheForHandle() override { return false; } void* map(bool invalidate_cpu_cache = false) override {