Fix build error with clang (#326)

Signed-off-by: ZhangXiang <Xiang.Zhang@verisilicon.com>
This commit is contained in:
Sven 2022-03-22 14:51:12 +08:00 committed by GitHub
parent 6412bd4ea5
commit 08500158ba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 2 deletions

View File

@ -29,7 +29,7 @@
namespace tim {
namespace vx {
struct CompileOption;
class CompileOption;
class Graph;
class Context {
public:

View File

@ -45,6 +45,13 @@ static vx_status derive_kernel_init(vx_node node, const vx_reference* param,
static std::map<void*, CustomOpBase*> node_base_map_;
namespace {
typedef struct DynamicArrayOfKernelParam_ {
uint32_t size_;
vsi_nn_kernel_node_param_t params_[1];
} DynamicArrayOfKernelParam;
}
CustomOpBase::CustomOpBase(Graph* graph, uint32_t input_num,
uint32_t output_num, int32_t kernel_id,
const char* kernel_name)
@ -162,7 +169,10 @@ vsi_bool op_compute(vsi_nn_node_t* self, vsi_nn_tensor_t** inputs,
auto node = vsi_nn_KernelCreateNodeExt(self->graph, kernel, resource);
if (node) {
vsi_nn_kernel_node_param_t node_params[param_num] = {NULL};
vsi_nn_kernel_node_param_t* node_params = nullptr;
DynamicArrayOfKernelParam* node_params_array = (DynamicArrayOfKernelParam*)malloc(sizeof(DynamicArrayOfKernelParam) + sizeof(vsi_nn_kernel_node_param_t)*(param_num - 1) );
node_params_array->size_ = param_num;
node_params = &node_params_array->params_[0];
vsi_nn_kernel_node_pack_io(node_params, param_num, inputs,
op_this->input_num_, outputs,
op_this->output_num_);
@ -198,6 +208,8 @@ vsi_bool op_compute(vsi_nn_node_t* self, vsi_nn_tensor_t** inputs,
for (uint32_t i = 0; i < param_num; i++) {
vsi_nn_kernel_scalar_release(&node_params[input_start + i]);
}
free(node_params_array);
}
self->n = (vx_node)node;