1 /** 2 * Copyright 2023 Huawei Technologies Co., Ltd 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef NNACL_KERNEL_CONCAT_H_ 18 #define NNACL_KERNEL_CONCAT_H_ 19 20 #include "nnacl/op_base.h" 21 #include "nnacl/tensor_c.h" 22 #include "nnacl/kernel.h" 23 24 typedef struct ConcatBlockBoundaryInfo { 25 int begin_input_; // input-index of upper boundary 26 int end_input_; // input-index of lower boundary. 27 int64_t begin_point_; // offset of begin-input. 28 int64_t end_point_; // required size of end-input. 29 } ConcatBlockBoundaryInfo; 30 31 typedef struct ConcatStruct { 32 KernelBase base_; 33 int64_t outer_size_; 34 uint8_t *output_; 35 TypeIdC data_type_; 36 37 bool *is_with_data_; /* size = in_tensor_size */ 38 uint8_t **inputs_ptr_; /* size = in_tensor_size */ 39 int64_t *inner_sizes_; // byte-inner-size (including axis) of each input and the last one is output's. 40 41 ConcatBlockBoundaryInfo block_boundary_infos_[MAX_THREAD_NUM]; /* dynamic block size */ 42 int64_t block_splits_[MAX_THREAD_NUM]; /* dynamic block size */ 43 size_t block_size_; /* dynamic block size = actual thread number */ 44 } ConcatStruct; 45 46 KernelBase *CreateConcat(OpParameter *param, int data_type); 47 int DoConcat(ConcatStruct *concat, int task_id); 48 int ConcatPepare(KernelBase *self); 49 int ConcatRelease(KernelBase *self); 50 int ConcatResize(KernelBase *self); 51 52 #endif // NNACL_KERNEL_CONCAT_H_ 53