1
// Tencent is pleased to support the open source community by making ncnn available.
3
// Copyright (C) 2018 THL A29 Limited, a Tencent company. All rights reserved.
5
// Licensed under the BSD 3-Clause License (the "License"); you may not use this file except
6
// in compliance with the License. You may obtain a copy of the License at
8
// https://opensource.org/licenses/BSD-3-Clause
10
// Unless required by applicable law or agreed to in writing, software distributed
11
// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
12
// CONDITIONS OF ANY KIND, either express or implied. See the License for the
13
// specific language governing permissions and limitations under the License.
22
support_inplace = false;
25
int Reorg::load_param(const ParamDict& pd)
27
stride = pd.get(0, 1);
33
int Reorg::forward(const Mat& bottom_blob, Mat& top_blob, const Option& opt) const
35
int w = bottom_blob.w;
36
int h = bottom_blob.h;
37
int channels = bottom_blob.c;
38
size_t elemsize = bottom_blob.elemsize;
40
int outw = w / stride;
41
int outh = h / stride;
42
int outc = channels * stride * stride;
44
top_blob.create(outw, outh, outc, elemsize, opt.blob_allocator);
48
#pragma omp parallel for num_threads(opt.num_threads)
49
for (int q = 0; q < channels; q++)
51
const Mat m = bottom_blob.channel(q);
53
for (int sh = 0; sh < stride; sh++)
55
for (int sw = 0; sw < stride; sw++)
59
p = q * stride * stride + sh * stride + sw;
60
else // if (mode == 1)
61
p = (sh * stride + sw) * channels + q;
63
float* outptr = top_blob.channel(p);
65
for (int i = 0; i < outh; i++)
67
const float* sptr = m.row(i * stride + sh) + sw;
68
for (int j = 0; j < outw; j++)