Elffuss BraidHub

kikocis/ncnn public

master · 1.9 KiBRawPermalink
1// Tencent is pleased to support the open source community by making ncnn available.
2//
3// Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved.
4//
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
7//
8// https://opensource.org/licenses/BSD-3-Clause
9//
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.
14
15static void pooling2x2s2_max_pack16_avx512(const Mat& bottom_blob, Mat& top_blob, const Option& opt)
16{
17 int w = bottom_blob.w;
18 int inch = bottom_blob.c;
19
20 int outw = top_blob.w;
21 int outh = top_blob.h;
22
23 const int tailstep = (w - 2 * outw + w) * 16;
24
25 #pragma omp parallel for num_threads(opt.num_threads)
26 for (int q = 0; q < inch; q++)
27 {
28 const Mat img0 = bottom_blob.channel(q);
29 float* outptr = top_blob.channel(q);
30
31 const float* r0 = img0.row(0);
32 const float* r1 = img0.row(1);
33
34 for (int i = 0; i < outh; i++)
35 {
36 int j = 0;
37
38 for (; j < outw; j++)
39 {
40 __m512 _r00 = _mm512_loadu_ps(r0);
41 __m512 _r01 = _mm512_loadu_ps(r0 + 16);
42 __m512 _r10 = _mm512_loadu_ps(r1);
43 __m512 _r11 = _mm512_loadu_ps(r1 + 16);
44
45 __m512 _max0 = _mm512_max_ps(_r00, _r01);
46 __m512 _max1 = _mm512_max_ps(_r10, _r11);
47 __m512 _max = _mm512_max_ps(_max0, _max1);
48
49 _mm512_storeu_ps(outptr, _max);
50
51 r0 += 32;
52 r1 += 32;
53 outptr += 16;
54 }
55
56 r0 += tailstep;
57 r1 += tailstep;
58 }
59 }
60}