Fix build if lowlevel driver doesn't support DMABuffer fd (#224)

* Fix build if lowlevel driver doesn't support DMABuffer fd

Signed-off-by: xiang.zhang <xiang.zhang@verisilicon.com>
This commit is contained in:
Sven 2021-11-23 11:34:03 +08:00 committed by GitHub
parent 9b115ca25b
commit bc42f7987c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 17 additions and 4 deletions

View File

@ -23,8 +23,6 @@
*****************************************************************************/
#include "tim/vx/tensor.h"
#include <VX/vx_khr_cnn.h>
#include <algorithm>
#include "graph_private.h"
@ -191,11 +189,26 @@ bool TensorImpl::Init() {
if ((spec_.attr_ & TensorAttribute::INPUT) ||
(spec_.attr_ & TensorAttribute::OUTPUT)) {
id_ = vsi_nn_AddTensorFromHandle(graph_->graph(), VSI_NN_TENSOR_ID_AUTO, // DMABUF's fd is created by TensorFromHandle as input or output,
&attr, fd_ != -1 ? (uint8_t*)fd_ : nullptr);// and cannot be set to const
#ifdef VX_CREATE_TENSOR_SUPPORT_PHYSICAL
if (fd_ != -1) {
attr.vsi_memory_type = VSI_MEMORY_TYPE_DMABUF;
}
id_ = vsi_nn_AddTensorFromHandle(
graph_->graph(),
VSI_NN_TENSOR_ID_AUTO, // DMABUF's fd is created by TensorFromHandle as input or output,
&attr,
fd_ != -1 ? (uint8_t*)fd_ : nullptr); // and cannot be set to const
#else
if (-1 == fd) {
id_ = vsi_nn_AddTensorFromHandle(graph_->graph(), VSI_NN_TENSOR_ID_AUTO,
&attr, nullptr);
} else {
id_ = 0xFFFFFFFF;
VSILOGE("Create tensor fail: low-level driver doesn't support dmabuffer");
}
#endif
} else {
id_ = vsi_nn_AddTensor(graph_->graph(), VSI_NN_TENSOR_ID_AUTO, &attr,
nullptr);