// Tencent is pleased to support the open source community by making ncnn available. // // Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. // // Licensed under the BSD 3-Clause License (the "License"); you may not use this file except // in compliance with the License. You may obtain a copy of the License at // // https://opensource.org/licenses/BSD-3-Clause // // Unless required by applicable law or agreed to in writing, software distributed // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR // CONDITIONS OF ANY KIND, either express or implied. See the License for the // specific language governing permissions and limitations under the License. #include "concat_arm.h" #include #include "layer_type.h" namespace ncnn { DEFINE_LAYER_CREATOR(Concat_arm) Concat_arm::Concat_arm() { #if __ARM_NEON support_packing = true; packing_pack4 = 0; #endif // __ARM_NEON } int Concat_arm::create_pipeline(const Option& opt) { #if __ARM_NEON if (opt.use_packing_layout) { { packing_pack4 = ncnn::create_layer(ncnn::LayerType::Packing); ncnn::ParamDict pd; pd.set(0, 4); packing_pack4->load_param(pd); packing_pack4->create_pipeline(opt); } } #endif // __ARM_NEON return 0; } int Concat_arm::destroy_pipeline(const Option& opt) { #if __ARM_NEON if (opt.use_packing_layout) { if (packing_pack4) { packing_pack4->destroy_pipeline(opt); delete packing_pack4; packing_pack4 = 0; } } #endif // __ARM_NEON return 0; } int Concat_arm::forward(const std::vector& bottom_blobs, std::vector& top_blobs, const Option& opt) const { int dims = bottom_blobs[0].dims; #if __ARM_NEON if (opt.use_packing_layout) { if (dims == 1) // axis == 0 { // concat vector // total length size_t elemsize = bottom_blobs[0].elemsize; int elempack = bottom_blobs[0].elempack; int top_w = 0; for (size_t b=0; bforward(top_blob_unpacked, top_blob, opt); } return 0; } if (dims == 2 && axis == 1) { // interleave image row int h = bottom_blobs[0].h; size_t elemsize = bottom_blobs[0].elemsize; int elempack = bottom_blobs[0].elempack; // total width int top_w = 0; for (size_t b=0; bforward(top_blob_unpacked, top_blob, opt); } return 0; } if (dims == 3 && axis == 1) { // interleave dim height int w = bottom_blobs[0].w; int channels = bottom_blobs[0].c; size_t elemsize = bottom_blobs[0].elemsize; int elempack = bottom_blobs[0].elempack; // total height int top_h = 0; for (size_t b=0; b